Удаление лишнего без ошибок
ч. 1
This commit is contained in:
1 parent
5c96958d1c
commit
fd2309c154
5 files changed
+14
-59
No files matched your search
BIN
Binary file not shown.
+5
-15
@@ -5,38 +5,28 @@ from .models import *
|
||||
|
||||
|
||||
class RatingStatusSerializer(serializers.ModelSerializer):
|
||||
# comment = UserCommentSerializer()
|
||||
|
||||
class Meta:
|
||||
model = RatingStatus
|
||||
fields = '__all__'
|
||||
# fields = ['id', 'crit', 'rating', 'comment']
|
||||
|
||||
class BaseCriteriaSerializer(serializers.ModelSerializer):
|
||||
|
||||
|
||||
|
||||
class Meta:
|
||||
model = BaseCriteria
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class UserCommentSerializer(serializers.ModelSerializer):
|
||||
|
||||
|
||||
|
||||
|
||||
class Meta:
|
||||
|
||||
model = UserComment
|
||||
fields = '__all__'
|
||||
fields = ['id', 'user', 'time_create']
|
||||
|
||||
# def create(self, validated_data):
|
||||
# print('---------------------------------ser', validated_data, self.context['request'].user.id)
|
||||
# parent = UserComment.objects.create(user_id=self.context['request'].user.id, comment=validated_data['comment'])
|
||||
# return parent
|
||||
|
||||
class UserGetSerializer(serializers.ModelSerializer):
|
||||
|
||||
get_rating = RatingStatusSerializer(many=True)
|
||||
|
||||
class Meta:
|
||||
fields = ['id', 'user', 'time_create', 'get_rating']
|
||||
fields = ['id', 'user', 'time_create', 'comment', 'get_rating']
|
||||
model = UserComment
|
||||
@@ -5,8 +5,6 @@ from .views import *
|
||||
urlpatterns = [
|
||||
path('baseCriteria/', BaseCriteriaAPI.as_view(), name='baseCriteria'),
|
||||
path('userComment/', UserCommentAPI.as_view(), name='userComment'),
|
||||
path('ratingStatus/', RatingStatusAPI.as_view(), name='ratingStatus'),
|
||||
|
||||
path('userCommentUp/<int:pk>/', UserCommentUpdateAPI.as_view(), name='userCommentUp'),
|
||||
|
||||
]
|
||||
+2
-16
@@ -15,40 +15,26 @@ class BaseCriteriaAPI(ListAPIView):
|
||||
serializer_class = BaseCriteriaSerializer
|
||||
|
||||
|
||||
|
||||
class UserCommentAPI(ListCreateAPIView):
|
||||
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
print('qqqqqqqqqqqqq', self.request.method)
|
||||
if self.request.method == 'GET':
|
||||
serializer_class = UserGetSerializer
|
||||
|
||||
|
||||
else:
|
||||
serializer_class = UserCommentSerializer
|
||||
kwargs.setdefault('context', self.get_serializer_context())
|
||||
kwargs.setdefault('context', self.get_serializer_context())
|
||||
return serializer_class(*args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
print('-----------Отправляю GET запрос в таблицу UserComment-----------')
|
||||
queryset = UserComment.objects.filter(user_id=self.request.user.id, time_create__contains=datetime.date.today())
|
||||
|
||||
# print(queryset, rating, '!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
# queryset = queryset.prefetch_related('get_rating')
|
||||
|
||||
|
||||
return queryset
|
||||
|
||||
def perform_create(self, serializer):
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
|
||||
usercom=serializer.save(user_id=self.request.user.id, comment=self.request.data['comment'])
|
||||
for x in self.request.data.get('ratingstatus'):
|
||||
RatingStatus.objects.create(usercom=usercom, **x)
|
||||
|
||||
class RatingStatusAPI(ListCreateAPIView):
|
||||
queryset = RatingStatus.objects.all()
|
||||
serializer_class = RatingStatusSerializer
|
||||
|
||||
class UserCommentUpdateAPI(UpdateAPIView):
|
||||
queryset = UserComment.objects.all()
|
||||
|
||||
@@ -65,19 +65,18 @@
|
||||
@click="menusCloses"
|
||||
/>
|
||||
<v-btn
|
||||
v-if="tab_userComment.length=0"
|
||||
color="blue-darken-1"
|
||||
variant="text"
|
||||
text="Отправить"
|
||||
@click="feedAll"
|
||||
:text="t_userComment.length==0?'Отправить':'Обновить'"
|
||||
@click="proba"
|
||||
/>
|
||||
<v-btn
|
||||
<!-- <v-btn
|
||||
v-else
|
||||
color="blue-darken-1"
|
||||
variant="text"
|
||||
text="Обновить"
|
||||
@click="proba"
|
||||
/>
|
||||
/> -->
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</template>
|
||||
@@ -123,21 +122,6 @@ export default {
|
||||
|
||||
})
|
||||
|
||||
function feedAll() {
|
||||
const feedObj = {}
|
||||
feedObj.ratingstatus = ratingStatus.value.decFeed
|
||||
feedObj.comment = comment.value
|
||||
axiosApiInstance.post('api/feedback/formfeed/', feedObj)
|
||||
comment.value=""
|
||||
t_baseCriteria.value.map(e=>e.rating=5)
|
||||
}
|
||||
|
||||
function feedUp() {
|
||||
const feedObj = {}
|
||||
feedObj.comment = comment.value
|
||||
feedObj.ratingstatus = ratingStatus.value.decFeed
|
||||
axiosApiInstance.put('api/feedback/formupdate/', feedObj)
|
||||
}
|
||||
|
||||
const ratingStatus = computed(() => {
|
||||
const decFeed = []
|
||||
@@ -174,24 +158,21 @@ export default {
|
||||
}
|
||||
|
||||
function proba() {
|
||||
f_userComment()
|
||||
// console.log(t_userComment.value, 't_userComment.value');
|
||||
// console.log(ratingStatus.value.decFeed, 'ratingStatus.value.decFeed');
|
||||
const feedObj = {}
|
||||
|
||||
feedObj.comment = comment.value
|
||||
feedObj.ratingstatus = ratingStatus.value.decFeed
|
||||
if (t_userComment.value.length==0) {
|
||||
console.log('111111111111111111');
|
||||
axiosApiInstance.post(`api/feedback/userComment/`, feedObj)
|
||||
}
|
||||
else {
|
||||
axiosApiInstance.put(`api/feedback/userCommentUp/${t_userComment.value[0].id}/`, feedObj)
|
||||
}
|
||||
console.log(t_userComment.value);
|
||||
f_userComment()
|
||||
console.log(t_userComment.value, '111111111111111111111111111111');
|
||||
}
|
||||
|
||||
return {t_baseCriteria, tab_userComment, comment, average, feedAll, feedUp, menusCloses, myLabel, proba}
|
||||
return {t_baseCriteria, t_userComment, tab_userComment, comment, average, menusCloses, myLabel, proba}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user