Merge branch 'develop' into test

This commit is contained in:
Nukeap committed 2024-10-21 13:45:16 +03:00
commit b5fbb4b58d
6 files changed
+177 -69

No files matched your search

+13 -10
View File
@@ -2,27 +2,30 @@ from django.db import models
# Create your models here. # Create your models here.
class ThanksVote(models.Model): class ThanksVote(models.Model):
cand_name_id = models.IntegerField(blank=False) voted_user = models.CharField(blank=False, max_length=255)
cand_name = models.CharField(blank=False, default=None, max_length=255)
vote_thanks_date = models.DateTimeField(auto_now_add=True) vote_thanks_date = models.DateTimeField(auto_now_add=True)
class Meta: class Meta:
verbose_name = "Голосование отправить спасибо" unique_together = ('voted_user', 'cand_name')
verbose_name_plural = "Голосование отправить спасибо" verbose_name = "Голосование, хочу сказать спасибо!"
verbose_name_plural = "Голосование, хочу сказать спасибо!"
def __str__(self): def __str__(self):
return self.candidate_name return self.cand_name
class BestVote(models.Model): class BestVote(models.Model):
cand_name_id = models.IntegerField(blank=False) voted_user = models.CharField(blank=False, max_length=255)
cand_name = models.CharField(blank=False, default=None, max_length=255)
vote_best_date = models.DateTimeField(auto_now_add=True) vote_best_date = models.DateTimeField(auto_now_add=True)
class Meta: class Meta:
verbose_name = "Голосование лучший сотрудник" unique_together = ('voted_user', 'cand_name')
verbose_name_plural = "Голосование лучший сотрудник" verbose_name = "Голосование, мой коллега самый лучший"
verbose_name_plural = "Голосование, мой коллега самый лучший"
def __str__(self): def __str__(self):
return self.candidate_name return self.cand_name
+2 -2
View File
@@ -14,10 +14,10 @@ class GetEmpSerializer(serializers.ModelSerializer):
class ThanksVoteSerializer(serializers.ModelSerializer): class ThanksVoteSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = ThanksVote model = ThanksVote
fields = ('id', 'cand_name_id', 'vote_thanks_date') fields = ('id', 'voted_user', 'cand_name', 'vote_thanks_date')
class BestVoteSerializer(serializers.ModelSerializer): class BestVoteSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = BestVote model = BestVote
fields = ('id', 'cand_name_id', 'vote_best_date') fields = ('id', 'voted_user', 'cand_name', 'vote_best_date')
+20 -14
View File
@@ -1,5 +1,6 @@
from rest_framework.views import APIView from rest_framework.views import APIView
from rest_framework.response import Response from rest_framework.response import Response
from django.db.models import Count
from django.db.models import Q from django.db.models import Q
from .models import * from .models import *
from userauth.models import * from userauth.models import *
@@ -12,7 +13,7 @@ class GetForThn(APIView):
def get(self, request): def get(self, request):
user_login = request.GET.get('login') user_login = request.GET.get('login')
all_emps = DictEmployee.objects.exclude( all_emps = DictEmployee.objects.exclude(
login=user_login).exclude(post='Начальник инспекции') login=user_login).exclude(post='Начальник инспекции').exclude(deleted=1)
return Response(GetEmpSerializer(all_emps, many=True).data) return Response(GetEmpSerializer(all_emps, many=True).data)
@@ -21,32 +22,36 @@ class GetForBst(APIView):
user_login = request.GET.get('login') user_login = request.GET.get('login')
dep_id = request.GET.get('dep') dep_id = request.GET.get('dep')
emp_user = DictEmployee.objects.filter(Q(id_dict_department=dep_id), ~Q( emp_user = DictEmployee.objects.filter(Q(id_dict_department=dep_id), ~Q(
post="Начальник отдела"), ~Q(login=user_login)) post="Начальник отдела"), ~Q(login=user_login)).exclude(deleted=1)
return Response(GetEmpSerializer(emp_user, many=True).data) return Response(GetEmpSerializer(emp_user, many=True).data)
class SetThanks(APIView): class SetThanks(APIView):
def post(self, request): def post(self, request):
cand_thanks_id = request.GET.get('id') voted_user = request.data['voted_user']
ThanksVote.objects.update_or_create( cand_name = request.data['cand_name_id']
cand_name_id=cand_thanks_id, ThanksVote.objects.create(
defaults=None voted_user=voted_user,
cand_name=cand_name
) )
return Response("Ваш голос добавлен!") return Response("Ваш голос добавлен!")
class GetThanks(APIView): class GetThanks(APIView):
def get(self, request): def get(self, request):
all_thanks = ThanksVote.objects.all() # Группировка товаров по имени и подсчет каждого
return Response(ThanksVoteSerializer(all_thanks, many=True).data) count_thanks = ThanksVote.objects.values(
'cand_name').annotate(total=Count('id'))
return Response(count_thanks)
class SetBest(APIView): class SetBest(APIView):
def post(self, request): def post(self, request):
cand_best_id = request.GET.get('id') voted_user = request.data['voted_user']
BestVote.objects.update_or_create( cand_name = request.data['cand_name_id']
cand_name_id=cand_best_id, BestVote.objects.create(
defaults=None voted_user=voted_user,
cand_name=cand_name
) )
return Response("Ваш голос добавлен!") return Response("Ваш голос добавлен!")
@@ -54,5 +59,6 @@ class SetBest(APIView):
class GetBest(APIView): class GetBest(APIView):
def get(self, request): def get(self, request):
all_thanks = BestVote.objects.all() count_bests = ThanksVote.objects.values(
return Response(BestVoteSerializer(all_thanks, many=True).data) 'cand_name').annotate(total=Count('id'))
return Response(count_bests)
+68
View File
@@ -0,0 +1,68 @@
<template>
<v-card color="teal-darken-1" width="420" height="150" elevation="24">
<v-card-title>До конца голосования осталось:</v-card-title>
<div class="card-count">{{ displayDays }}:{{ displayHours }}:{{ displayMinutes }}</div>
<span class="card-sub-title ">дней : часов : минут</span>
</v-card>
</template>
<script>
export default {
data: () => ({
displayDays: 0,
displayHours: 0,
displayMinutes: 0
}),
computed: {
_seconds: () => 1000,
_minutes() {
return this._seconds * 60
},
_hours() {
return this._minutes * 60
},
_days() {
return this._hours * 24
}
},
mounted() {
this.countDown();
},
methods: {
countDown() {
const timer = setInterval(() => {
const now = new Date();
// здесь задается конец отчета (гггг, мм, дд, остальные цифры не меняются)
const end = new Date(2024, 11 - 1, 21, 10, 10, 10);
const distance = end.getTime() - now.getTime();
if (distance < 0) {
clearInterval(timer);
return
}
const days = Math.floor(distance / this._days);
const hours = Math.floor((distance % this._days) / this._hours);
const minutes = Math.floor((distance % this._hours) / this._minutes);
this.displayMinutes = minutes < 10 ? "0" + minutes : minutes;
this.displayHours = minutes < 10 & minutes > 10 ? "0" + hours : hours;
this.displayDays = days < 10 ? "0" + days : days;
}, 1000)
}
}
};
</script>
<style>
.card-count {
font-size: 3em;
}
.card-sub-title {
font-size: 1.2em;
}
</style>
+35 -9
View File
@@ -1,32 +1,43 @@
<template> <template>
<v-card height="520"> <v-form @submit="voteSend">
<v-virtual-scroll :items="vote_data" :height="500" :item-height="30"> <v-card height="520" variant="none">
<v-card-text v-for="item in vote_data">
<p>{{ item.fio }}</p> <v-virtual-scroll :items="vote_data" :height="500" :item-height="40">
</v-card-text> <template v-slot:default="{ item }">
</v-virtual-scroll> <v-checkbox id="vote" v-model="vote" :value="item.fio" :label="item.fio"> </v-checkbox>
</v-card> </template>
</v-virtual-scroll>
</v-card>
<v-card-actions class="justify-center vote-button-back">
<v-btn variant="elevated" color="teal-darken-1" type="submit">ПРОГОЛОСОВАТЬ</v-btn>
</v-card-actions>
</v-form>
</template> </template>
<script> <script scope>
import { ref } from "vue"; import { ref } from "vue";
import { clearAxios } from "@/utils/axios-api"; import { clearAxios } from "@/utils/axios-api";
import { useAccountStore } from '@/store/AccountStore'; import { useAccountStore } from '@/store/AccountStore';
export default { export default {
props: ['type_fetch'], props: ['type_fetch'],
setup(props) { setup(props) {
let account_login = useAccountStore().user.login; let account_login = useAccountStore().user.login;
let department_id = useAccountStore().user.id_dict_department; let department_id = useAccountStore().user.id_dict_department;
let type_fetch = props.type_fetch; let type_fetch = props.type_fetch;
let vote = ref();
let get_address = ref(); let get_address = ref();
let send_address = ref();
let vote_data = ref([]); let vote_data = ref([]);
if (type_fetch == "thn") { if (type_fetch == "thn") {
get_address = `api/vote/get_for_thn/?login=${account_login}`; get_address = `api/vote/get_for_thn/?login=${account_login}`;
send_address = `api/vote/setthanks/`;
} else if (type_fetch == "bst") { } else if (type_fetch == "bst") {
get_address = `api/vote/get_for_bst/?login=${account_login}&dep=${department_id}`; get_address = `api/vote/get_for_bst/?login=${account_login}&dep=${department_id}`;
send_address = `api/vote/setbest/`;
} }
const getVotesData = () => { const getVotesData = () => {
@@ -35,15 +46,30 @@ export default {
}); });
}; };
const voteSend = () => {
clearAxios.post(send_address, {
cand_name_id: vote.value,
voted_user: account_login
},
{
headers: {
'Content-Type': 'application/json'
}
}
);
};
getVotesData(); getVotesData();
return { return {
voteSend,
vote_data, vote_data,
vote,
} }
}, },
} }
</script> </script>
<style></style> <style></style>
+39 -34
View File
@@ -1,19 +1,31 @@
<template> <template>
<v-row justify="center" align="center"> <v-row justify="center" class="d-flex align-start h-100">
<v-col cols="12" class="h-15 d-flex justify-center proc-count_cell">
<v-col justify="center" align="center" cols="2">
<v-card color="teal-darken-1" width="200" height="100" elevation="24" class="procent-card-font">
<span>45%</span>
</v-card>
</v-col>
<v-col justify="center" align="center" cols="4" class="vote-cards_cell ">
<count-down />
</v-col>
<v-col justify="center" align="center" cols="2">
<v-card color="teal-darken-1" width="200" height="100" elevation="24" class="procent-card-font">
<span>55%</span>
</v-card>
</v-col>
</v-col>
<!-- Голосование Лучший сотрудник --> <!-- Голосование Лучший сотрудник -->
<v-col justify="center" align="center"> <v-col justify="center" align="center">
<div class="flip-card" :class="{ 'flipped': isFlipped1 }"> <div class="flip-card" :class="{ 'flipped': isFlipped1 }">
<div class="flip-card-inner"> <div class="flip-card-inner">
<div class="flip-card-front"> <div class="flip-card-front">
<!-- Передняя сторона карточки --> <!-- Передняя сторона карточки -->
<v-card class="justify-center elevation-24" image="@/assets/best_employee.jpg" width="500" <v-card class="justify-center elevation-24 " image="@/assets/best_employee.jpg" width="500"
height="700" variant="elevated"> height="700" variant="elevated">
<v-card-title class="vote-card-title"> <v-card-title class="vote-card-title">
ЛУЧШИЙ СОТРУДНИК &laquo;МОЙ КОЛЛЕГА САМЫЙ ЛУЧШИЙ&raquo;
</v-card-title> </v-card-title>
<!-- Кнопка активации поворота --> <!-- Кнопка активации поворота -->
<v-card-actions class="justify-center vote-button"> <v-card-actions class="justify-center vote-button">
<v-btn size="x-large" @click="toggleFlip1" variant="elevated" color="teal-darken-1" <v-btn size="x-large" @click="toggleFlip1" variant="elevated" color="teal-darken-1"
@@ -21,25 +33,18 @@
ГОЛОС!</v-btn> ГОЛОС!</v-btn>
</v-card-actions> </v-card-actions>
<!-- Кнопка активации поворота КОНЕЦ--> <!-- Кнопка активации поворота КОНЕЦ-->
</v-card> </v-card>
</div> </div>
<!-- Передняя сторона карточки КОНЕЦ--> <!-- Передняя сторона карточки КОНЕЦ-->
<div class="flip-card-back"> <div class="flip-card-back">
<!-- Задняя сторона карточки --> <!-- Задняя сторона карточки -->
<v-card class="justify-center elevation-24" width="500" height="700"> <v-card class="justify-center elevation-24" width="500" height="700">
<v-card-title> <v-card-title>
Лучший сотрудник &laquo;МОЙ КОЛЛЕГА САМЫЙ ЛУЧШИЙ&raquo;
</v-card-title> </v-card-title>
<v-card-text> <v-card-text>
<vote-form :type_fetch="'bst'" /> <vote-form :type_fetch="'bst'" />
</v-card-text> </v-card-text>
<!-- Кнопка активации поворота --> <!-- Кнопка активации поворота -->
<v-card-actions class="justify-center vote-button-back"> <v-card-actions class="justify-center vote-button-back">
<v-btn @click="toggleFlip1" variant="elevated" color="teal-darken-1" <v-btn @click="toggleFlip1" variant="elevated" color="teal-darken-1"
@@ -51,11 +56,8 @@
</div> </div>
</div> </div>
<!-- Задняя сторона карточки КОНЕЦ--> <!-- Задняя сторона карточки КОНЕЦ-->
</v-col> </v-col>
<!-- Голосование Лучший сотрудник КОНЕЦ--> <!-- Голосование Лучший сотрудник КОНЕЦ-->
<!-- Голосование Спасибо --> <!-- Голосование Спасибо -->
<v-col justify="center" align="center"> <v-col justify="center" align="center">
<div class="flip-card" :class="{ 'flipped': isFlipped2 }"> <div class="flip-card" :class="{ 'flipped': isFlipped2 }">
@@ -64,62 +66,53 @@
<!-- Передняя сторона карточки --> <!-- Передняя сторона карточки -->
<v-card class="justify-center elevation-24" image="@/assets/thanks.jpeg" width="500" height="700" <v-card class="justify-center elevation-24" image="@/assets/thanks.jpeg" width="500" height="700"
variant="elevated"> variant="elevated">
<v-card-title class="vote-card-title"> <v-card-title class="vote-card-title">
СПАСИБО! &laquo;ХОЧУ СКАЗАТЬ СПАСИБО!&raquo;
</v-card-title> </v-card-title>
<!-- Кнопка активации поворота --> <!-- Кнопка активации поворота -->
<v-card-actions class="justify-center vote-button"> <v-card-actions class="justify-center vote-button">
<v-btn size="x-large" @click="toggleFlip2" variant="elevated" color="teal-darken-1">ОТДАТЬ <v-btn size="x-large" @click="toggleFlip2" variant="elevated" color="teal-darken-1">ОТДАТЬ
ГОЛОС!</v-btn> ГОЛОС!</v-btn>
</v-card-actions> </v-card-actions>
<!-- Кнопка активации поворота КОНЕЦ--> <!-- Кнопка активации поворота КОНЕЦ-->
</v-card> </v-card>
</div> </div>
<!-- Передняя сторона карточки КОНЕЦ--> <!-- Передняя сторона карточки КОНЕЦ-->
<!-- Задняя сторона карточки --> <!-- Задняя сторона карточки -->
<div class="flip-card-back"> <div class="flip-card-back">
<v-card class="justify-center elevation-24" width="500" height="700" variant="elevated"> <v-card class="justify-center elevation-24" width="500" height="700" variant="elevated">
<v-card-title> <v-card-title>
СПАСИБО &laquo;ХОЧУ СКАЗАТЬ СПАСИБО!&raquo;
</v-card-title> </v-card-title>
<v-card-text> <v-card-text>
<vote-form :type_fetch="'thn'" /> <vote-form :type_fetch="'thn'" />
</v-card-text> </v-card-text>
<!-- Кнопка активации поворота --> <!-- Кнопка активации поворота -->
<v-card-actions class="justify-center vote-button-back"> <v-card-actions class="justify-center vote-button-back">
<v-btn @click="toggleFlip2" variant="elevated" color="teal-darken-1" <v-btn @click="toggleFlip2" variant="elevated" color="teal-darken-1"
type="button">назад</v-btn> type="button">назад</v-btn>
</v-card-actions> </v-card-actions>
<!-- Кнопка активации поворота КОНЕЦ--> <!-- Кнопка активации поворота КОНЕЦ-->
</v-card> </v-card>
</div> </div>
<!-- Задняя сторона карточки КОНЕЦ--> <!-- Задняя сторона карточки КОНЕЦ-->
</div> </div>
</div> </div>
</v-col> </v-col>
<!-- Голосование Спасибо КОНЕЦ-->
<!-- Голосование Спасибо КОНЕЦ-->
</v-row> </v-row>
</template> </template>
<script> <script>
import { ref } from "vue"; import { ref } from "vue";
import VoteForm from '@/components/VoteForm.vue'; import VoteForm from '@/components/VoteForm.vue';
import CountDown from '@/components/CountDown.vue';
export default { export default {
components: { components: {
VoteForm, VoteForm,
CountDown,
}, },
setup() { setup() {
@@ -183,10 +176,22 @@ export default {
} }
.vote-button { .vote-button {
margin-top: 580px; margin-top: 572px;
} }
.vote-button-back { .vote-cards_cell {
margin-top: 10%; height: 14% !important;
}
.proc-count_cell {
height: 18% !important;
}
.procent-card-font {
font-size: 4em;
}
.card-count {
font-size: 4em;
} }
</style> </style>