Обновление в БД

This commit is contained in:
iriska-gri committed 2023-09-08 12:26:38 +03:00
1 parent bc26a6a50d
commit 643d14c35d
4 files changed
+19 -5

No files matched your search

BIN
View File
Binary file not shown.
+1
View File
@@ -4,6 +4,7 @@ from .views import *
urlpatterns = [ urlpatterns = [
path('baseCriteria/', BaseCriteriaAPI.as_view(), name='baseCriteria'), path('baseCriteria/', BaseCriteriaAPI.as_view(), name='baseCriteria'),
path('userComment/', UserCommentAPI.as_view(), name='userComment'), path('userComment/', UserCommentAPI.as_view(), name='userComment'),
path('userCommentUp/<int:pk>/', UserCommentUpdateAPI.as_view(), name='userCommentUp'),
path('formfeed/', FormFeedAPI.as_view(), name='form'), path('formfeed/', FormFeedAPI.as_view(), name='form'),
path('formupdate/', FormUpdateAPI.as_view(), name='formupdate'), path('formupdate/', FormUpdateAPI.as_view(), name='formupdate'),
] ]
+8 -3
View File
@@ -23,9 +23,14 @@ class UserCommentAPI(ListCreateAPIView):
def perform_create(self, serializer): def perform_create(self, serializer):
serializer.save(user_id=self.request.user.id, comment=self.request.data['comment']) # updated after feedback serializer.save(user_id=self.request.user.id, comment=self.request.data['comment']) # updated after feedback
# class UserCommentUpdateAPI(UpdateAPIView): class UserCommentUpdateAPI(RetrieveUpdateDestroyAPIView):
# queryset = UserComment.objects.all() queryset = UserComment.objects.all()
# serializer_class = UserCommentSerializer serializer_class = UserCommentSerializer
print('--------------------updatellllllllllllllll')
# def perform_update(self, serializer):
# print('--------------------update')
# serializer.save(comment=self.request.data['comment'])
+10 -2
View File
@@ -164,11 +164,19 @@ export default {
} }
function proba() { function proba() {
const feedObj = {} const feedObj = {}
feedObj.comment = comment.value feedObj.comment = comment.value
axiosApiInstance.post(`api/feedback/userComment/`, feedObj) if (t_userComment.value.length==0) {
// console.log(t_userComment.value, 't_userComment.value'); axiosApiInstance.post(`api/feedback/userComment/`, feedObj)
}
else {
console.log('------------------yuiyui----/${t_userComment.value[0].id}------', );
axiosApiInstance.put(`api/feedback/userCommentUp/${t_userComment.value[0].id}/`, feedObj)
}
// console.log(t_userComment.value.length, 't_userComment.value');
} }
return {t_baseCriteria, tab_userComment, comment, average, feedAll, feedUp, menusCloses, myLabel, proba} return {t_baseCriteria, tab_userComment, comment, average, feedAll, feedUp, menusCloses, myLabel, proba}