Описание серилизаторов плюс карта
This commit is contained in:
1 parent
fd2644a2d6
commit
def0372449
10 files changed
+59
-286
No files matched your search
@@ -82,8 +82,7 @@ class User(AbstractBaseUser, PermissionsMixin):
|
||||
def fio(self):
|
||||
|
||||
return self.user.login
|
||||
# return ShortUserSerializer(DictEmployee.objects.get(login=self.username)).data
|
||||
# return DictEmployee.objects.using('user_directory').get(login=self.username).fio
|
||||
|
||||
|
||||
def names(self):
|
||||
return DictEmployee.objects.get(login=self.username)
|
||||
|
||||
@@ -14,7 +14,6 @@ urlpatterns = [
|
||||
path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
|
||||
path('token/verify/', TokenVerifyView.as_view(), name='token_access'),
|
||||
path('getuser/', getuserAPIView.as_view(), name='getuserAPIView', ),
|
||||
path('test/', testView.as_view(), name='test')
|
||||
|
||||
|
||||
]
|
||||
@@ -1,86 +1,26 @@
|
||||
from rest_framework import status
|
||||
from rest_framework.permissions import AllowAny, IsAuthenticated
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
from .renderers import UserJSONRenderer
|
||||
from userauth.models import *
|
||||
from navigation.models import *
|
||||
from navigation.serializers import *
|
||||
from userauth.serializers import *
|
||||
from .models import *
|
||||
from .serializers import *
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class testView(APIView):
|
||||
|
||||
def get(self, request):
|
||||
"""Пример"""
|
||||
|
||||
|
||||
newsqueryset = News.objects.all().order_by('cdate')
|
||||
|
||||
|
||||
|
||||
for x in newsqueryset:
|
||||
a=model_to_dict(x)
|
||||
# a['link']= str(x.link.url)
|
||||
# a['show'] = False
|
||||
# a['showComment'] = False
|
||||
# a['author'] = model_to_dict(DictEmployee.objects.using('user_directory').get(login=x.author.username))
|
||||
a['scores'] = [{"score":y.score, "user":y.author.username} for y in x.get_news.all()]
|
||||
a['comment'] = [{"author":model_to_dict(k.author.user),
|
||||
"cdate":k.cdate,
|
||||
"text":k.text,
|
||||
"id": k.pk
|
||||
} for k in x.get_comment_news.all()
|
||||
]
|
||||
|
||||
return Response(NewsSerializer(newsqueryset, many=True).data)
|
||||
# from .serializers import RegistrationSerializer
|
||||
|
||||
# class RegistrationAPIView(APIView):
|
||||
# """
|
||||
# Разрешить всем пользователям (аутентифицированным и нет) доступ к данному эндпоинту.
|
||||
# """
|
||||
# permission_classes = (AllowAny,)
|
||||
# serializer_class = RegistrationSerializer
|
||||
# renderer_classes = (UserJSONRenderer,)
|
||||
|
||||
# def post(self, request):
|
||||
# user = request.data.get("user",{})
|
||||
# # Паттерн создания сериализатора, валидации и сохранения - довольно
|
||||
# # стандартный, и его можно часто увидеть в реальных проектах.
|
||||
|
||||
# serializer = self.serializer_class(data=user)
|
||||
# serializer.is_valid(raise_exception=True)
|
||||
# serializer.save()
|
||||
|
||||
# return Response(serializer.data, status=status.HTTP_201_CREATED)
|
||||
|
||||
class UserAPIView(APIView):
|
||||
permission_classes = (IsAuthenticated,)
|
||||
# serializer_class = RegistrationSerializer
|
||||
def get(self, request):
|
||||
# serializer = self.serializer_class(data=request.user)
|
||||
# serializer.is_valid(raise_exception=True)
|
||||
return Response('user')
|
||||
|
||||
class getuserAPIView(APIView):
|
||||
permission_classes = (AllowAny,)
|
||||
|
||||
|
||||
|
||||
|
||||
def get(self, request):
|
||||
"""
|
||||
Параметр: userlogin
|
||||
Пример: GET /api/accounts/getuser/?userlogin=9966-00-107
|
||||
Результат: Выдает все данные о пользователе
|
||||
"""
|
||||
dt=datetime.now()
|
||||
|
||||
queryset = DictEmployee.objects.get(login=request.query_params.get('userlogin'))
|
||||
r=CardUserSerializer(queryset).data
|
||||
|
||||
|
||||
|
||||
return Response(CardUserSerializer(queryset).data)
|
||||
|
||||
@@ -48,7 +48,7 @@ class CommentNewsSerializer(serializers.ModelSerializer):
|
||||
fields = '__all__'
|
||||
|
||||
def get_user(self, obj):
|
||||
return ShortUserSerializer(DictEmployee.objects.get(login=obj.author.username)).data
|
||||
return InfoUserCardSerializer(DictEmployee.objects.get(login=obj.author.username)).data
|
||||
|
||||
|
||||
class NewsSerializer(serializers.ModelSerializer):
|
||||
|
||||
@@ -102,8 +102,6 @@ class NewsCrossroadAPIView(ListAPIView):
|
||||
|
||||
newsqueryset = newsqueryset[:10]
|
||||
else:
|
||||
|
||||
|
||||
pagesel = int(request.GET.get("page"))*int(request.GET.get("countpage"))
|
||||
|
||||
newsqueryset =newsqueryset[pagesel:pagesel+int(request.GET.get("countpage"))]
|
||||
|
||||
@@ -35,12 +35,15 @@ class OrderResponsibilitySerializer(serializers.ModelSerializer):
|
||||
return ResponsibilityUsersSerializer(data,many=True).data
|
||||
|
||||
class Committee1FilesSerializer(serializers.ModelSerializer):
|
||||
|
||||
"""Забирает названия файлов и их актуальность
|
||||
Используется в
|
||||
"""
|
||||
class Meta:
|
||||
model = Committee1Files
|
||||
exclude=['id_committee1']
|
||||
|
||||
class Committee1Serializer(serializers.ModelSerializer):
|
||||
""" Забирает всю информацию по комиссиям с типом """
|
||||
typs = serializers.CharField(source='id_dict_committee_type.name')
|
||||
files = serializers.SerializerMethodField('get_files')
|
||||
|
||||
@@ -89,10 +92,12 @@ class Committee2Serializer(serializers.ModelSerializer):
|
||||
return Committee1FilesSerializer(data, many=True).data
|
||||
|
||||
class CardUserSerializer(serializers.ModelSerializer):
|
||||
"""Собирает все данные о пользователе
|
||||
Используется в представлении getuserAPIView
|
||||
В компоненте AboutInspectionPage
|
||||
"""
|
||||
responsibility = serializers.SerializerMethodField('get_responsibility')
|
||||
committee = serializers.SerializerMethodField('get_committee')
|
||||
|
||||
# position=serializers.CharField(source='id_dict_employee.fio')
|
||||
|
||||
class Meta:
|
||||
|
||||
@@ -107,16 +112,7 @@ class CardUserSerializer(serializers.ModelSerializer):
|
||||
|
||||
|
||||
def get_committee(self, obj):
|
||||
return Committee2Serializer(obj.user_committe2.all(), many=True).data
|
||||
# [Committee2Serializer(x.id_dict_committee_position).data for x in obj.user_committe2.all()]
|
||||
# Committee2Serializer(obj.user_committe2.get().id_dict_committee_position).data
|
||||
|
||||
|
||||
class ShortUserSerializer(serializers.ModelSerializer):
|
||||
""" """
|
||||
class Meta:
|
||||
model = DictEmployee
|
||||
fields = ['familyname', 'name', 'parentname', 'id', 'login', 'post', 'department']
|
||||
return Committee2Serializer(obj.user_committe2.all(), many=True).data
|
||||
|
||||
|
||||
class InfoUserCardSerializer(serializers.ModelSerializer):
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
<template>
|
||||
<v-row lg="12" class="mt-10 ml-13">
|
||||
<v-col lg="5" no-gutters class="d-flex justify-end align-start">
|
||||
|
||||
<v-card :width="640" :height="600" :elevation="5">
|
||||
<div style="width:640px;height:600px; ">
|
||||
|
||||
|
||||
<l-map :zoom="13" :min-zoom="13" :center="[55.83451, 37.40848]">
|
||||
<l-tile-layer :url="`${baseURL}media/Tiles/{z}/{x}/{y}.png`"></l-tile-layer>
|
||||
<l-marker :lat-lng="[55.83451, 37.40848]" :icon="icon_cod"> </l-marker>
|
||||
<l-marker :lat-lng="[55.83309, 37.39933]" :icon="icon_mcd"> </l-marker>
|
||||
<l-marker :lat-lng="[55.83463, 37.38335]" :icon="icon_metro"> </l-marker>
|
||||
<l-marker :lat-lng="[55.83213, 37.38247]" :icon="icon_mcd"> </l-marker>
|
||||
<l-marker :lat-lng="[55.82741, 37.43715]" :icon="icon_metro"> </l-marker>
|
||||
<l-marker :lat-lng="[55.82705, 37.4411]" :icon="icon_mcd"> </l-marker>
|
||||
<l-marker :lat-lng="[55.8496, 37.43925]" :icon="icon_metro"> </l-marker>
|
||||
<l-marker :lat-lng="[55.8252, 37.3853]" :icon="icon_metro"> </l-marker>
|
||||
<l-marker v-for="x in markers" :key="x" :lat-lng="x.coordinate" :icon="icon(x.icon)"> </l-marker>
|
||||
</l-map>
|
||||
</div>
|
||||
|
||||
</v-card>
|
||||
</v-col>
|
||||
<v-col lg="6" no-gutters class="d-flex flex-column ml-16">
|
||||
@@ -55,7 +50,7 @@ import { baseURL } from '@/utils/axios-api'
|
||||
import "leaflet/dist/leaflet.css";
|
||||
import { LMap, LTileLayer, LMarker } from "@vue-leaflet/vue-leaflet";
|
||||
import { L, icon } from "leaflet"
|
||||
|
||||
import { ref } from 'vue'
|
||||
export default {
|
||||
components: {
|
||||
LMap,
|
||||
@@ -65,27 +60,48 @@ export default {
|
||||
icon
|
||||
},
|
||||
setup() {
|
||||
return {
|
||||
icon_cod: icon({
|
||||
iconUrl: `${baseURL}media/map_icons/fns.png`,
|
||||
iconSize: [30, 30],
|
||||
iconAnchor: [16, 40]
|
||||
}),
|
||||
|
||||
icon_mcd: icon({
|
||||
iconUrl: `${baseURL}media/map_icons/mcd_d2.png`,
|
||||
const pathbuild=(icon)=>{
|
||||
return `${baseURL}media/map_icons/${icon}.png`
|
||||
}
|
||||
const icons = {
|
||||
icon_cod:{
|
||||
iconUrl: pathbuild(`fns`),
|
||||
iconSize: [30, 30],
|
||||
iconAnchor: [16, 40]
|
||||
},
|
||||
icon_metro:{
|
||||
iconUrl: pathbuild(`mos_metro`),
|
||||
iconSize: [30, 25],
|
||||
iconAnchor: [10, 20]
|
||||
},
|
||||
icon_mcd :{
|
||||
iconUrl: pathbuild(`mcd_d2`),
|
||||
iconSize: [32, 18],
|
||||
iconAnchor: [10, 20]
|
||||
}),
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
const markers= ref([{
|
||||
coordinate:[55.83451, 37.40848],icon:icons.icon_cod},
|
||||
{coordinate:[55.83309, 37.39933],icon:icons.icon_mcd },
|
||||
{coordinate:[55.83463, 37.38335],icon:icons.icon_metro },
|
||||
{coordinate:[55.83213, 37.38247],icon:icons.icon_mcd },
|
||||
{coordinate:[55.82741, 37.43715],icon:icons.icon_metro },
|
||||
{coordinate:[55.82705, 37.4411], icon:icons.icon_mcd},
|
||||
{coordinate:[55.8496, 37.43925], icon:icons.icon_metro },
|
||||
{coordinate:[55.8252, 37.3853], icon:icons.icon_metro }
|
||||
|
||||
|
||||
])
|
||||
return {
|
||||
markers,
|
||||
|
||||
|
||||
|
||||
icon_metro: icon({
|
||||
iconUrl: `${baseURL}media/map_icons/mos_metro.png`,
|
||||
iconSize: [30, 25],
|
||||
iconAnchor: [10, 20]
|
||||
}),
|
||||
address: {
|
||||
"building": "125373, Москва, Походный проезд, двл.3, стр 1",
|
||||
"phone": "Телефон: 8(495) 198-53 - 12"
|
||||
"phone": "Телефон: 8(495) 198-53-12"
|
||||
},
|
||||
address_pathes: [
|
||||
{ "path": "От станции метро «Волоколамская», 837 автобусом до остановки «Таксомоторный парк», или маршрутным такси № 441" },
|
||||
@@ -93,6 +109,7 @@ export default {
|
||||
{ "path": "От станции метро «Тушинская», последний вагон из центра, автобусы № 2, № 266 до остановки «пл. Трикотажная», автобусы № 88, №177 до остановки «17 Таксомоторный парк»" }
|
||||
],
|
||||
baseURL,
|
||||
icon
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
<template>
|
||||
<v-dialog
|
||||
v-model="getUserDialog"
|
||||
persistent
|
||||
width="600">
|
||||
<v-card >
|
||||
|
||||
|
||||
|
||||
|
||||
<v-card-actions class="align-self-end pt-0 ">
|
||||
<v-btn
|
||||
color="modal_btn"
|
||||
variant="text"
|
||||
@click="menusCloses()"
|
||||
>
|
||||
Закрыть {{UserDialog}}
|
||||
</v-btn>
|
||||
|
||||
|
||||
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import { clearAxios } from '@/utils/axios-api'
|
||||
import { ref, computed } from 'vue'
|
||||
import {useAccountStore} from '@/store/AccountStore'
|
||||
import {checkremote} from '@/utils/universal_functions'
|
||||
import { spravURL } from '@/utils/axios-api'
|
||||
|
||||
export default {
|
||||
|
||||
props: {
|
||||
UserDialog: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
|
||||
loging: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
setup(props, { emit }) {
|
||||
|
||||
const accountStore = useAccountStore()
|
||||
const userlinks = ref([])
|
||||
const tab = ref(false)
|
||||
|
||||
const loadlinksUser=async()=>{
|
||||
|
||||
const res = await clearAxios.get('api/accounts/getuser/?userlogin='+props.loging)
|
||||
userlinks.value=res.data
|
||||
}
|
||||
|
||||
const basicInformation = () => [
|
||||
{title: 'Отдел:', info: userlinks.value.department},
|
||||
{title: 'ФИО:', info: userlinks.value.fio},
|
||||
{title: 'Должность:', info: userlinks.value.post},
|
||||
]
|
||||
|
||||
const subInformation = () => [
|
||||
{title: 'E-mail: ', info: userlinks.value.email},
|
||||
{title: 'Телефон: ', info: userlinks.value.tel},
|
||||
{title: 'Комната: ', info: userlinks.value.room},
|
||||
{title: 'Логин: ', info: userlinks.value.login},
|
||||
]
|
||||
|
||||
function menusCloses() {
|
||||
props.UserDialog=false
|
||||
|
||||
}
|
||||
|
||||
const getUserDialog = computed({
|
||||
|
||||
get: () => props.UserDialog,
|
||||
set: (value) => emit('update:UserDialog', value)
|
||||
})
|
||||
|
||||
loadlinksUser()
|
||||
|
||||
return {
|
||||
menusCloses,
|
||||
userlinks,
|
||||
accountStore,
|
||||
basicInformation,
|
||||
subInformation,
|
||||
checkremote,
|
||||
spravURL,
|
||||
tab,
|
||||
getUserDialog,
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.custom_subtitle .v-list-item-subtitle {
|
||||
opacity: 1!important;
|
||||
}
|
||||
|
||||
.highttext {
|
||||
height: 400px;
|
||||
}
|
||||
|
||||
.isActiveTab {
|
||||
background-color: #68c3ff70;
|
||||
}
|
||||
</style>
|
||||
@@ -132,15 +132,14 @@
|
||||
import { axiosApiInstance } from '@/utils/axios-api'
|
||||
import {checkremote} from '@/utils/universal_functions'
|
||||
import { spravURL } from '@/utils/axios-api'
|
||||
import CardUsers from '@/components/cardUsers.vue'
|
||||
|
||||
import DialogSearch from './dialog-search.vue'
|
||||
import { baseURL } from '@/utils/axios-api'
|
||||
import {useAccountStore} from '@/store/AccountStore'
|
||||
export default {
|
||||
|
||||
components: {
|
||||
CardUsers,
|
||||
DialogSearch
|
||||
DialogSearch
|
||||
},
|
||||
|
||||
setup(){
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
|
||||
Сотрудники
|
||||
{{userlinks}}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import {pagecounter} from '@/utils/universal_functions'
|
||||
import {useAccountStore} from '@/store/AccountStore'
|
||||
import { clearAxios } from '@/utils/axios-api'
|
||||
import { ref } from 'vue'
|
||||
export default {
|
||||
|
||||
props: {
|
||||
|
||||
loging: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
|
||||
setup(props, context){
|
||||
const accountStore = useAccountStore()
|
||||
const userlinks = ref([])
|
||||
const login =ref('')
|
||||
|
||||
const loadlinksUser=async()=>{
|
||||
if (props.loging==""){
|
||||
login.value=accountStore.user.login
|
||||
}
|
||||
else {
|
||||
login.value=props.loging
|
||||
|
||||
}
|
||||
|
||||
const res = await clearAxios.get('api/accounts/getuser/?userlogin='+login.value)
|
||||
userlinks.value=res.data
|
||||
}
|
||||
|
||||
pagecounter()
|
||||
loadlinksUser()
|
||||
|
||||
|
||||
return {
|
||||
|
||||
userlinks,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
Reference in new issue
Block a user