Восстановление повреждений
This commit is contained in:
1 parent
1c975365d5
commit
56fe677a73
3 files changed
+47
-38
No files matched your search
BIN
Binary file not shown.
+8
-12
@@ -11,25 +11,21 @@ from .models import *
|
||||
|
||||
class FormFeedAPI(LinkAPIView):
|
||||
def get(self, request):
|
||||
serializer_class = BaseCriteriaSerializer
|
||||
queryset = BaseCriteria.objects.all()
|
||||
serializer = serializer_class(queryset, many=True)
|
||||
return Response(serializer.data)
|
||||
serializer_class1 = BaseCriteriaSerializer
|
||||
serializer_class2 = UserCommentSerializer
|
||||
queryset1 = BaseCriteria.objects.all()
|
||||
queryset2 = UserComment.objects.filter(user_id=request.user.id)
|
||||
baseCriteria = serializer_class1(queryset1, many=True)
|
||||
userComment = serializer_class2(queryset2, many=True)
|
||||
return Response({'baseCriteria':baseCriteria.data, 'userComment':userComment.data})
|
||||
|
||||
class CommentAPI(ListCreateAPIView):
|
||||
# model = UserComment
|
||||
# serializer_class = UserCommentSerializer
|
||||
|
||||
|
||||
|
||||
def post(self, request):
|
||||
|
||||
comid = UserComment.objects.create(user_id = request.user.id, comment = request.data['usercomment'])
|
||||
# RatingStatus.objects.create(crit=request)
|
||||
|
||||
for x in request.data['ratingstatus']:
|
||||
print(x['id'])
|
||||
RatingStatus.objects.create(crit_id=x['id'], rating = x['rating'], usercom_id= comid.id)
|
||||
|
||||
return Response(print('Запись создана в таблицу feedback_usercomment'))
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<v-divider/>
|
||||
</v-row>
|
||||
<v-row
|
||||
v-for="(x, key) in btns"
|
||||
v-for="(x, key) in tab_baseCriteria"
|
||||
:key = key
|
||||
>
|
||||
<v-col class="flex-grow-0 pb-0">
|
||||
@@ -64,9 +64,10 @@
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
<!-- <small>вы оценили сайт на <pre>{{ rating }}</pre></small> -->
|
||||
|
||||
</v-card-text>
|
||||
<v-card-actions class="pt-0">
|
||||
<small class="pl-5">Вы оценили сайт на <span class="font-weight-black">{{average}}</span> {{myLabel()}} </small>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn
|
||||
color="blue-darken-1"
|
||||
@@ -107,16 +108,30 @@ export default {
|
||||
|
||||
setup(props, context) {
|
||||
const comment = ref("")
|
||||
const btns = ref([])
|
||||
const tab_baseCriteria = ref([])
|
||||
const tab_userComment = ref([])
|
||||
|
||||
onMounted(() => {
|
||||
axiosApiInstance.get('api/feedback/formfeed/')
|
||||
.then(data => btns.value = data.data)
|
||||
.then(data => {
|
||||
tab_baseCriteria.value = data.data.baseCriteria
|
||||
tab_userComment.value = data.data.userComment
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
function feedAll() {
|
||||
const feedObj = {}
|
||||
feedObj.ratingstatus = ratingStatus.value.decFeed
|
||||
feedObj.usercomment = comment.value
|
||||
// axiosApiInstance.post('api/feedback/comment/', feedObj)
|
||||
comment.value=""
|
||||
tab_baseCriteria.value.map(e=>e.rating=5)
|
||||
}
|
||||
|
||||
const ratingStatus = computed(() => {
|
||||
const decFeed = []
|
||||
btns.value.map(e =>
|
||||
tab_baseCriteria.value.map(e =>
|
||||
{
|
||||
const { id, rating } = {...e}
|
||||
decFeed.push({id:id, rating:rating})
|
||||
@@ -124,37 +139,35 @@ export default {
|
||||
return { decFeed }
|
||||
});
|
||||
|
||||
function feedAll() {
|
||||
const feedObj = {}
|
||||
feedObj.ratingstatus = ratingStatus.value.decFeed
|
||||
feedObj.usercomment = comment.value
|
||||
axiosApiInstance.post('api/feedback/comment/', feedObj)
|
||||
}
|
||||
const average = computed(()=> {
|
||||
const sum = tab_baseCriteria.value.reduce((total, obj)=> total + obj.rating, 0)
|
||||
const sumlen = sum/tab_baseCriteria.value.length
|
||||
const ukr = Number.isInteger(sumlen)?sumlen:sumlen.toFixed(1)
|
||||
return ukr
|
||||
})
|
||||
|
||||
function myLabel() {
|
||||
let labels = ''
|
||||
if (average.value > 0 && average.value <= 3)
|
||||
labels = 'УПС-С! Мы обязательно все исправим'
|
||||
else if (average.value > 2 && average.value <= 4)
|
||||
labels = 'Спасибо за обратную связь, мы обратим на это внимание'
|
||||
else if (average.value > 4 && average.value < 5)
|
||||
labels = 'Класс, будем стараться до 5'
|
||||
|
||||
return labels
|
||||
}
|
||||
|
||||
function menusCloses() {
|
||||
context.emit('menusClose')
|
||||
}
|
||||
|
||||
return {btns, comment, feedAll, menusCloses}
|
||||
return {tab_baseCriteria, tab_userComment, comment, average, feedAll, menusCloses, myLabel}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// function myLabel() {
|
||||
// let labels = ''
|
||||
// if (rating.value <= 1)
|
||||
// labels = 'Мы обязательно все исправим, с учего начать в первую очередь?'
|
||||
// if (rating.value > 1 && rating.value <= 2)
|
||||
// labels = 'УПС-С! А что вам не поравилось?'
|
||||
// if (rating.value > 2 && rating.value <= 3)
|
||||
// labels = 'Спасибо за обратную связь, что нам стоит улучшить?'
|
||||
// if (rating.value > 3 && rating.value <= 4)
|
||||
// labels = 'Мы рады, что портал вам понравился,скажите, за что вы поставили такую оценку?'
|
||||
// if (rating.value > 4 && rating.value <= 5)
|
||||
// labels = 'Класс, а что нам удалось сделать лучше всего?'
|
||||
|
||||
// return labels
|
||||
// }
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
Reference in new issue
Block a user