Merge branch 'Andr' into develop
This commit is contained in:
commit
22b045894c
6 files changed
+180
-72
No files matched your search
+16
-13
@@ -2,27 +2,30 @@ from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
|
||||
|
||||
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)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Голосование отправить спасибо"
|
||||
verbose_name_plural = "Голосование отправить спасибо"
|
||||
|
||||
unique_together = ('voted_user', 'cand_name')
|
||||
verbose_name = "Голосование, хочу сказать спасибо!"
|
||||
verbose_name_plural = "Голосование, хочу сказать спасибо!"
|
||||
|
||||
def __str__(self):
|
||||
return self.candidate_name
|
||||
|
||||
|
||||
return self.cand_name
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Голосование лучший сотрудник"
|
||||
verbose_name_plural = "Голосование лучший сотрудник"
|
||||
unique_together = ('voted_user', 'cand_name')
|
||||
verbose_name = "Голосование, мой коллега самый лучший"
|
||||
verbose_name_plural = "Голосование, мой коллега самый лучший"
|
||||
|
||||
def __str__(self):
|
||||
return self.candidate_name
|
||||
|
||||
return self.cand_name
|
||||
@@ -14,10 +14,10 @@ class GetEmpSerializer(serializers.ModelSerializer):
|
||||
class ThanksVoteSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = ThanksVote
|
||||
fields = ('id', 'cand_name_id', 'vote_thanks_date')
|
||||
fields = ('id', 'voted_user', 'cand_name', 'vote_thanks_date')
|
||||
|
||||
|
||||
class BestVoteSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = BestVote
|
||||
fields = ('id', 'cand_name_id', 'vote_best_date')
|
||||
fields = ('id', 'voted_user', 'cand_name', 'vote_best_date')
|
||||
+20
-14
@@ -1,5 +1,6 @@
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
from django.db.models import Count
|
||||
from django.db.models import Q
|
||||
from .models import *
|
||||
from userauth.models import *
|
||||
@@ -12,7 +13,7 @@ class GetForThn(APIView):
|
||||
def get(self, request):
|
||||
user_login = request.GET.get('login')
|
||||
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)
|
||||
|
||||
|
||||
@@ -21,32 +22,36 @@ class GetForBst(APIView):
|
||||
user_login = request.GET.get('login')
|
||||
dep_id = request.GET.get('dep')
|
||||
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)
|
||||
|
||||
|
||||
class SetThanks(APIView):
|
||||
def post(self, request):
|
||||
cand_thanks_id = request.GET.get('id')
|
||||
ThanksVote.objects.update_or_create(
|
||||
cand_name_id=cand_thanks_id,
|
||||
defaults=None
|
||||
voted_user = request.data['voted_user']
|
||||
cand_name = request.data['cand_name_id']
|
||||
ThanksVote.objects.create(
|
||||
voted_user=voted_user,
|
||||
cand_name=cand_name
|
||||
)
|
||||
return Response("Ваш голос добавлен!")
|
||||
|
||||
|
||||
class GetThanks(APIView):
|
||||
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):
|
||||
def post(self, request):
|
||||
cand_best_id = request.GET.get('id')
|
||||
BestVote.objects.update_or_create(
|
||||
cand_name_id=cand_best_id,
|
||||
defaults=None
|
||||
voted_user = request.data['voted_user']
|
||||
cand_name = request.data['cand_name_id']
|
||||
BestVote.objects.create(
|
||||
voted_user=voted_user,
|
||||
cand_name=cand_name
|
||||
)
|
||||
return Response("Ваш голос добавлен!")
|
||||
|
||||
@@ -54,5 +59,6 @@ class SetBest(APIView):
|
||||
|
||||
class GetBest(APIView):
|
||||
def get(self, request):
|
||||
all_thanks = BestVote.objects.all()
|
||||
return Response(BestVoteSerializer(all_thanks, many=True).data)
|
||||
count_bests = ThanksVote.objects.values(
|
||||
'cand_name').annotate(total=Count('id'))
|
||||
return Response(count_bests)
|
||||
@@ -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>
|
||||
@@ -1,32 +1,43 @@
|
||||
<template>
|
||||
<v-card height="520">
|
||||
<v-virtual-scroll :items="vote_data" :height="500" :item-height="30">
|
||||
<v-card-text v-for="item in vote_data">
|
||||
<p>{{ item.fio }}</p>
|
||||
</v-card-text>
|
||||
</v-virtual-scroll>
|
||||
</v-card>
|
||||
<v-form @submit="voteSend">
|
||||
<v-card height="520" variant="none">
|
||||
|
||||
<v-virtual-scroll :items="vote_data" :height="500" :item-height="40">
|
||||
<template v-slot:default="{ item }">
|
||||
<v-checkbox id="vote" v-model="vote" :value="item.fio" :label="item.fio"> </v-checkbox>
|
||||
</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>
|
||||
<script>
|
||||
<script scope>
|
||||
import { ref } from "vue";
|
||||
import { clearAxios } from "@/utils/axios-api";
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
|
||||
export default {
|
||||
|
||||
props: ['type_fetch'],
|
||||
|
||||
setup(props) {
|
||||
let account_login = useAccountStore().user.login;
|
||||
let department_id = useAccountStore().user.id_dict_department;
|
||||
let type_fetch = props.type_fetch;
|
||||
let vote = ref();
|
||||
let get_address = ref();
|
||||
let send_address = ref();
|
||||
let vote_data = ref([]);
|
||||
|
||||
|
||||
if (type_fetch == "thn") {
|
||||
get_address = `api/vote/get_for_thn/?login=${account_login}`;
|
||||
send_address = `api/vote/setthanks/`;
|
||||
} else if (type_fetch == "bst") {
|
||||
get_address = `api/vote/get_for_bst/?login=${account_login}&dep=${department_id}`;
|
||||
send_address = `api/vote/setbest/`;
|
||||
}
|
||||
|
||||
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();
|
||||
return {
|
||||
voteSend,
|
||||
vote_data,
|
||||
vote,
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
<style></style>
|
||||
@@ -1,19 +1,31 @@
|
||||
<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">
|
||||
<div class="flip-card" :class="{ 'flipped': isFlipped1 }">
|
||||
<div class="flip-card-inner">
|
||||
<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">
|
||||
|
||||
<v-card-title class="vote-card-title">
|
||||
ЛУЧШИЙ СОТРУДНИК
|
||||
«МОЙ КОЛЛЕГА САМЫЙ ЛУЧШИЙ»
|
||||
</v-card-title>
|
||||
|
||||
<!-- Кнопка активации поворота -->
|
||||
<v-card-actions class="justify-center vote-button">
|
||||
<v-btn size="x-large" @click="toggleFlip1" variant="elevated" color="teal-darken-1"
|
||||
@@ -21,25 +33,18 @@
|
||||
ГОЛОС!</v-btn>
|
||||
</v-card-actions>
|
||||
<!-- Кнопка активации поворота КОНЕЦ-->
|
||||
|
||||
|
||||
</v-card>
|
||||
</div>
|
||||
|
||||
<!-- Передняя сторона карточки КОНЕЦ-->
|
||||
|
||||
|
||||
<div class="flip-card-back">
|
||||
<!-- Задняя сторона карточки -->
|
||||
<v-card class="justify-center elevation-24" width="500" height="700">
|
||||
|
||||
<v-card-title>
|
||||
Лучший сотрудник
|
||||
«МОЙ КОЛЛЕГА САМЫЙ ЛУЧШИЙ»
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<vote-form :type_fetch="'bst'" />
|
||||
</v-card-text>
|
||||
|
||||
<!-- Кнопка активации поворота -->
|
||||
<v-card-actions class="justify-center vote-button-back">
|
||||
<v-btn @click="toggleFlip1" variant="elevated" color="teal-darken-1"
|
||||
@@ -51,11 +56,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- Задняя сторона карточки КОНЕЦ-->
|
||||
|
||||
</v-col>
|
||||
<!-- Голосование Лучший сотрудник КОНЕЦ-->
|
||||
|
||||
|
||||
<!-- Голосование Спасибо -->
|
||||
<v-col justify="center" align="center">
|
||||
<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"
|
||||
variant="elevated">
|
||||
|
||||
<v-card-title class="vote-card-title">
|
||||
СПАСИБО!
|
||||
«ХОЧУ СКАЗАТЬ СПАСИБО!»
|
||||
</v-card-title>
|
||||
|
||||
<!-- Кнопка активации поворота -->
|
||||
<v-card-actions class="justify-center vote-button">
|
||||
<v-btn size="x-large" @click="toggleFlip2" variant="elevated" color="teal-darken-1">ОТДАТЬ
|
||||
ГОЛОС!</v-btn>
|
||||
</v-card-actions>
|
||||
<!-- Кнопка активации поворота КОНЕЦ-->
|
||||
|
||||
</v-card>
|
||||
</div>
|
||||
<!-- Передняя сторона карточки КОНЕЦ-->
|
||||
|
||||
<!-- Задняя сторона карточки -->
|
||||
<div class="flip-card-back">
|
||||
<v-card class="justify-center elevation-24" width="500" height="700" variant="elevated">
|
||||
|
||||
<v-card-title>
|
||||
СПАСИБО
|
||||
«ХОЧУ СКАЗАТЬ СПАСИБО!»
|
||||
</v-card-title>
|
||||
|
||||
<v-card-text>
|
||||
|
||||
<vote-form :type_fetch="'thn'" />
|
||||
|
||||
</v-card-text>
|
||||
|
||||
<!-- Кнопка активации поворота -->
|
||||
<v-card-actions class="justify-center vote-button-back">
|
||||
<v-btn @click="toggleFlip2" variant="elevated" color="teal-darken-1"
|
||||
type="button">назад</v-btn>
|
||||
</v-card-actions>
|
||||
<!-- Кнопка активации поворота КОНЕЦ-->
|
||||
|
||||
</v-card>
|
||||
</div>
|
||||
|
||||
<!-- Задняя сторона карточки КОНЕЦ-->
|
||||
</div>
|
||||
</div>
|
||||
</v-col>
|
||||
<!-- Голосование Спасибо КОНЕЦ-->
|
||||
|
||||
<!-- Голосование Спасибо КОНЕЦ-->
|
||||
</v-row>
|
||||
</template>
|
||||
<script>
|
||||
import { ref } from "vue";
|
||||
import VoteForm from '@/components/VoteForm.vue';
|
||||
import CountDown from '@/components/CountDown.vue';
|
||||
|
||||
export default {
|
||||
|
||||
components: {
|
||||
VoteForm,
|
||||
CountDown,
|
||||
},
|
||||
|
||||
setup() {
|
||||
@@ -183,10 +176,22 @@ export default {
|
||||
}
|
||||
|
||||
.vote-button {
|
||||
margin-top: 580px;
|
||||
margin-top: 572px;
|
||||
}
|
||||
|
||||
.vote-button-back {
|
||||
margin-top: 10%;
|
||||
.vote-cards_cell {
|
||||
height: 14% !important;
|
||||
}
|
||||
|
||||
.proc-count_cell {
|
||||
height: 18% !important;
|
||||
}
|
||||
|
||||
.procent-card-font {
|
||||
font-size: 4em;
|
||||
}
|
||||
|
||||
.card-count {
|
||||
font-size: 4em;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user