Добавлены запросы списков голосования из backend
This commit is contained in:
1 parent
98e7179a1e
commit
ec4d3774bc
4 files changed
+54
-14
No files matched your search
@@ -1,13 +1,22 @@
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from .models import *
|
from .models import *
|
||||||
|
from userauth.models import *
|
||||||
|
|
||||||
|
|
||||||
|
class GetEmpSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = DictEmployee
|
||||||
|
fields = ['id', 'id_dict_department',
|
||||||
|
'fio', 'post', 'department']
|
||||||
|
|
||||||
|
|
||||||
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', 'cand_name_id', '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', 'cand_name_id', 'vote_best_date')
|
||||||
@@ -3,8 +3,10 @@ from .views import *
|
|||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
path('get_for_thn/', GetForThn.as_view(),),
|
||||||
|
path('get_for_bst/', GetForBst.as_view(),),
|
||||||
path('setthanks/', SetThanks.as_view(), name=''),
|
path('setthanks/', SetThanks.as_view(), name=''),
|
||||||
path('getthanks/', GetThanks.as_view(), name=''),
|
path('getthanks/', GetThanks.as_view(), name=''),
|
||||||
path('setbest/', SetBest.as_view(), name=''),
|
path('setbest/', SetBest.as_view(), name=''),
|
||||||
path('getbest/', GetBest.as_view(), name=''),
|
path('getbest/', GetBest.as_view(), name=''),
|
||||||
]
|
]
|
||||||
+31
-7
@@ -1,19 +1,42 @@
|
|||||||
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 Q
|
||||||
from .models import *
|
from .models import *
|
||||||
|
from userauth.models import *
|
||||||
from .serializers import *
|
from .serializers import *
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
|
|
||||||
|
class GetForThn(APIView):
|
||||||
|
def get(self, request):
|
||||||
|
user_login = request.GET.get('login')
|
||||||
|
all_emps = DictEmployee.objects.exclude(
|
||||||
|
login=user_login).exclude(post='Начальник инспекции')
|
||||||
|
return Response(GetEmpSerializer(all_emps, many=True).data)
|
||||||
|
|
||||||
|
|
||||||
|
class GetForBst(APIView):
|
||||||
|
def get(self, request):
|
||||||
|
user_login = request.GET.get('login')
|
||||||
|
dep_id = request.GET.get('dep')
|
||||||
|
print(user_login)
|
||||||
|
print(dep_id)
|
||||||
|
emp_user = DictEmployee.objects.filter(Q(id_dict_department=dep_id), ~Q(
|
||||||
|
post="Начальник отдела"), ~Q(login=user_login))
|
||||||
|
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')
|
cand_thanks_id = request.GET.get('id')
|
||||||
ThanksVote.objects.update_or_create(
|
ThanksVote.objects.update_or_create(
|
||||||
cand_name_id = cand_thanks_id,
|
cand_name_id=cand_thanks_id,
|
||||||
defaults = None
|
defaults=None
|
||||||
)
|
)
|
||||||
return Response("Ваш голос добавлен!")
|
return Response("Ваш голос добавлен!")
|
||||||
|
|
||||||
|
|
||||||
class GetThanks(APIView):
|
class GetThanks(APIView):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
all_thanks = ThanksVote.objects.all()
|
all_thanks = ThanksVote.objects.all()
|
||||||
@@ -24,12 +47,13 @@ class SetBest(APIView):
|
|||||||
def post(self, request):
|
def post(self, request):
|
||||||
cand_best_id = request.GET.get('id')
|
cand_best_id = request.GET.get('id')
|
||||||
BestVote.objects.update_or_create(
|
BestVote.objects.update_or_create(
|
||||||
cand_name_id = cand_best_id,
|
cand_name_id=cand_best_id,
|
||||||
defaults = None
|
defaults=None
|
||||||
)
|
)
|
||||||
return Response("Ваш голос добавлен!")
|
return Response("Ваш голос добавлен!")
|
||||||
|
|
||||||
|
|
||||||
class GetBest(APIView):
|
class GetBest(APIView):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
all_thanks = BestVote.objects.all()
|
all_thanks = BestVote.objects.all()
|
||||||
return Response(BestVoteSerializer(all_thanks, many=True).data)
|
return Response(BestVoteSerializer(all_thanks, many=True).data)
|
||||||
@@ -27,9 +27,9 @@
|
|||||||
|
|
||||||
<!-- Передняя сторона карточки КОНЕЦ-->
|
<!-- Передняя сторона карточки КОНЕЦ-->
|
||||||
|
|
||||||
<!-- Задняя сторона карточки -->
|
|
||||||
<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>
|
||||||
@@ -105,13 +105,18 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
import { useAccountStore } from '@/store/AccountStore'
|
||||||
import { spravURL } from "@/utils/axios-api";
|
import { spravURL } from "@/utils/axios-api";
|
||||||
import { useDisplay } from "vuetify";
|
import { useDisplay } from "vuetify";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
const account_id = useAccountStore().login;
|
||||||
const isFlipped1 = ref(false);
|
const isFlipped1 = ref(false);
|
||||||
const isFlipped2 = ref(false);
|
const isFlipped2 = ref(false);
|
||||||
|
|
||||||
|
console.log(account_id);
|
||||||
const toggleFlip1 = () => {
|
const toggleFlip1 = () => {
|
||||||
isFlipped1.value = !isFlipped1.value;
|
isFlipped1.value = !isFlipped1.value;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user