P-52 решен вопрос с праздниками
This commit is contained in:
1 parent
96ceeb3252
commit
37599fc85a
6 files changed
+176
-71
No files matched your search
@@ -5,4 +5,5 @@ from .views import *
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('calendarEvents/', CalendarEventsAPIView.as_view(), name='calendarEvents'),
|
path('calendarEvents/', CalendarEventsAPIView.as_view(), name='calendarEvents'),
|
||||||
|
path('exclusionDatas/', ExclusionDatesAPIView.as_view(), name='exclusionDatas'),
|
||||||
]
|
]
|
||||||
@@ -4,11 +4,12 @@ from .models import *
|
|||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
import json
|
import json
|
||||||
|
from django.db.models.functions import TruncYear
|
||||||
|
|
||||||
class CalendarEventsAPIView(APIView):
|
class CalendarEventsAPIView(APIView):
|
||||||
|
|
||||||
def updateCreate(self, ev, calendar, bigname):
|
def updateCreate(self, ev, calendar, bigname):
|
||||||
print('2222222-- -----------------------------------------------------------------------2222', calendar)
|
|
||||||
CalendarEvents.objects.update_or_create(**ev,
|
CalendarEvents.objects.update_or_create(**ev,
|
||||||
defaults = {**calendar,
|
defaults = {**calendar,
|
||||||
'author': User.objects.get(pk=self.request.user.id),
|
'author': User.objects.get(pk=self.request.user.id),
|
||||||
@@ -35,8 +36,7 @@ class CalendarEventsAPIView(APIView):
|
|||||||
namecalendar, created = CalendarEventsName.objects.update_or_create(name=request.data['participants'],
|
namecalendar, created = CalendarEventsName.objects.update_or_create(name=request.data['participants'],
|
||||||
defaults = {'name':request.data['participants'],
|
defaults = {'name':request.data['participants'],
|
||||||
'author_id': self.request.user.id})
|
'author_id': self.request.user.id})
|
||||||
# print('22222222222', request.data)
|
|
||||||
# print('request.data', type(json.loads(request.POST.get("calendar"))))
|
|
||||||
if 'pk' in request.data['calendar']:
|
if 'pk' in request.data['calendar']:
|
||||||
# FilesEvent.objects.create(link = request.data['file'], event_id = json.loads(request.data['calendar'])['pk'])
|
# FilesEvent.objects.create(link = request.data['file'], event_id = json.loads(request.data['calendar'])['pk'])
|
||||||
print('22--------------------------------------------222222222', request.data['file'], json.loads(request.data['calendar'])['pk'])
|
print('22--------------------------------------------222222222', request.data['file'], json.loads(request.data['calendar'])['pk'])
|
||||||
@@ -45,7 +45,6 @@ class CalendarEventsAPIView(APIView):
|
|||||||
self.updateCreate(event, json.loads(request.data['calendar']), namecalendar)
|
self.updateCreate(event, json.loads(request.data['calendar']), namecalendar)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for cal in request.data['calendar']:
|
for cal in request.data['calendar']:
|
||||||
event = {"calendarname_id":namecalendar.pk,
|
event = {"calendarname_id":namecalendar.pk,
|
||||||
@@ -53,10 +52,17 @@ class CalendarEventsAPIView(APIView):
|
|||||||
"author_id": self.request.user.id}
|
"author_id": self.request.user.id}
|
||||||
self.updateCreate(event, cal, namecalendar)
|
self.updateCreate(event, cal, namecalendar)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Response('ru')
|
return Response('ru')
|
||||||
|
|
||||||
|
class ExclusionDatesAPIView(APIView):
|
||||||
|
def post(self, request):
|
||||||
|
|
||||||
|
# year = self.request.query_params.get('chapter', "fire" ,)
|
||||||
|
ex = ExclusionDates.objects.filter(exclusiondate__year=self.request.query_params['year'])
|
||||||
|
formonth ={}
|
||||||
|
for i in range(12):
|
||||||
|
formonth[i+1] = ex.filter(exclusiondate__month =i+1).values_list("exclusiondate", flat=True)
|
||||||
|
|
||||||
|
print(formonth, 'formonthformonthformonth')
|
||||||
|
|
||||||
|
return Response(formonth)
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
<template>
|
||||||
|
<v-row no-gutters>
|
||||||
|
<v-col class="flex-grow-0 d-flex flex-column">
|
||||||
|
<v-card class="h-100 rounded-0 d-flex flex-colmn" width="250">
|
||||||
|
<v-row no-gutters class="flex-column">
|
||||||
|
<v-col class="flex-grow-0">
|
||||||
|
<!-- <v-btn></v-btn> -->
|
||||||
|
</v-col>
|
||||||
|
<v-col class="w100" lg="3">
|
||||||
|
<v-locale-provider locale="ru">
|
||||||
|
<v-date-picker
|
||||||
|
ref="cal"
|
||||||
|
v-model="selectdate"
|
||||||
|
color="btn_text"
|
||||||
|
class="rounded-0 minCal"
|
||||||
|
max-width="250"
|
||||||
|
hide-header
|
||||||
|
show-adjacent-months
|
||||||
|
@click="CheckingStore"
|
||||||
|
@update:month="getMonth"
|
||||||
|
@update:year="getYear"
|
||||||
|
>
|
||||||
|
|
||||||
|
</v-date-picker>
|
||||||
|
<pre>
|
||||||
|
{{ week }}
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
</v-locale-provider>
|
||||||
|
</v-col>
|
||||||
|
<v-col></v-col>
|
||||||
|
</v-row>
|
||||||
|
<!-- <v-date-picker show-adjacent-months></v-date-picker> -->
|
||||||
|
</v-card></v-col
|
||||||
|
>
|
||||||
|
<v-col class="bg-green">
|
||||||
|
<v-btn @click="drawer_right = !drawer_right">
|
||||||
|
{{ drawer_right }}
|
||||||
|
</v-btn>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-navigation-drawer
|
||||||
|
v-model="drawer_right"
|
||||||
|
floating
|
||||||
|
permanent
|
||||||
|
location="right"
|
||||||
|
rail-width="400"
|
||||||
|
rail
|
||||||
|
>
|
||||||
|
</v-navigation-drawer>
|
||||||
|
</v-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { axiosApiInstance } from "@/utils/axios-api";
|
||||||
|
import { ref, onMounted } from "vue";
|
||||||
|
import { useWeekendsStore } from "@/store/WeekendsStore";
|
||||||
|
|
||||||
|
// const burl = baseURL.slice(0, -1);
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
const week = useWeekendsStore().week;
|
||||||
|
const drawer_right = ref(false);
|
||||||
|
const cal = ref(null);
|
||||||
|
const selectdate = ref(new Date());
|
||||||
|
const MyYear = ref(selectdate.value.getFullYear());
|
||||||
|
const MyMonth = ref(selectdate.value.getMonth() + 1);
|
||||||
|
|
||||||
|
function getWeekend() {
|
||||||
|
axiosApiInstance
|
||||||
|
.post(`api/calendar_of_events/exclusionDatas/?year=${MyYear.value}`, {})
|
||||||
|
.then((data) => {
|
||||||
|
week[MyYear.value] = data.data;
|
||||||
|
weekendsData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const getMonth = (month) => {
|
||||||
|
MyMonth.value = month + 1;
|
||||||
|
};
|
||||||
|
const getYear = (year) => {
|
||||||
|
MyYear.value = year;
|
||||||
|
};
|
||||||
|
|
||||||
|
const weekendsData = () => {
|
||||||
|
cal.value.$el
|
||||||
|
.querySelectorAll(".v-date-picker-month__day")
|
||||||
|
.forEach((e) => {
|
||||||
|
let datas = e.getAttribute("data-v-date");
|
||||||
|
let weeks =
|
||||||
|
new Date(datas).getDay() === 6 || new Date(datas).getDay() === 0;
|
||||||
|
if (weeks) {
|
||||||
|
e.querySelectorAll("span").forEach((n) => {
|
||||||
|
n.classList.add("text-red");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MyMonth.value in week[MyYear.value]) {
|
||||||
|
if (week[MyYear.value][MyMonth.value].includes(datas)) {
|
||||||
|
e.querySelectorAll("span").forEach((n) => {
|
||||||
|
n.classList.add("text-red");
|
||||||
|
if (n.classList.contains("text-red") && weeks) {
|
||||||
|
n.classList.replace("text-red", "text-black");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const CheckingStore = () => {
|
||||||
|
if (MyYear.value in week) {
|
||||||
|
weekendsData();
|
||||||
|
} else {
|
||||||
|
getWeekend();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
CheckingStore();
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
drawer_right,
|
||||||
|
selectdate,
|
||||||
|
cal,
|
||||||
|
getMonth,
|
||||||
|
getYear,
|
||||||
|
weekendsData,
|
||||||
|
week,
|
||||||
|
CheckingStore,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.minCal .v-date-picker-month__day {
|
||||||
|
height: 31px;
|
||||||
|
width: 31px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.minCal .v-btn--icon.v-btn--density-default {
|
||||||
|
width: calc(var(--v-btn-height) + 12px);
|
||||||
|
height: calc(var(--v-btn-height) + 6px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.minCal .v-btn__content {
|
||||||
|
font-weight: 410;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,48 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-row no-gutters>
|
|
||||||
<v-col class="flex-grow-0 d-flex flex-column"
|
|
||||||
><v-card class="h-100 rounded-0 d-flex flex-colmn" width="250">
|
|
||||||
<v-row no-gutters class="flex-column">
|
|
||||||
<v-col class="flex-grow-0">
|
|
||||||
<v-btn></v-btn>
|
|
||||||
</v-col>
|
|
||||||
<v-col class="w100" lg="3">
|
|
||||||
<v-locale-provider locale="ru">
|
|
||||||
<v-date-picker
|
|
||||||
ref="cal"
|
|
||||||
v-model="selectdate"
|
|
||||||
color="btn_text"
|
|
||||||
class="rounded-0 minCal"
|
|
||||||
max-width="250"
|
|
||||||
hide-header
|
|
||||||
show-adjacent-months
|
|
||||||
>
|
|
||||||
<v-btn @click="refpuk"> </v-btn>
|
|
||||||
</v-date-picker>
|
|
||||||
</v-locale-provider>
|
|
||||||
</v-col>
|
|
||||||
<v-col></v-col>
|
|
||||||
</v-row>
|
|
||||||
<!-- <v-date-picker show-adjacent-months></v-date-picker> -->
|
|
||||||
</v-card></v-col
|
|
||||||
>
|
|
||||||
<v-col class="bg-green">
|
|
||||||
<v-btn @click="drawer_right = !drawer_right">
|
|
||||||
{{ drawer_right }}
|
|
||||||
</v-btn>
|
|
||||||
</v-col>
|
|
||||||
|
|
||||||
<v-navigation-drawer
|
<div>
|
||||||
v-model="drawer_right"
|
|
||||||
floating
|
|
||||||
permanent
|
|
||||||
location="right"
|
|
||||||
rail-width="400"
|
|
||||||
rail
|
|
||||||
>
|
|
||||||
</v-navigation-drawer>
|
|
||||||
</v-row>
|
|
||||||
<!-- <div>
|
|
||||||
<v-btn @click="f_feedbackdata"> ical</v-btn>
|
<v-btn @click="f_feedbackdata"> ical</v-btn>
|
||||||
|
|
||||||
<v-file-input
|
<v-file-input
|
||||||
@@ -57,12 +15,12 @@
|
|||||||
accept=".ics"
|
accept=".ics"
|
||||||
@input="handleFilesUpload"
|
@input="handleFilesUpload"
|
||||||
/>
|
/>
|
||||||
</div> -->
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { axiosApiInstance } from "@/utils/axios-api";
|
import { axiosApiInstance } from "@/utils/axios-api";
|
||||||
import { ref, computed, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
|
|
||||||
import ical from "ical.js";
|
import ical from "ical.js";
|
||||||
import { useWeekendsStore } from '@/store/WeekendsStore'
|
import { useWeekendsStore } from '@/store/WeekendsStore'
|
||||||
@@ -167,17 +125,5 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.minCal .v-date-picker-month__day {
|
|
||||||
height: 31px;
|
|
||||||
width: 31px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.minCal .v-btn--icon.v-btn--density-default {
|
|
||||||
width: calc(var(--v-btn-height) + 12px);
|
|
||||||
height: calc(var(--v-btn-height) + 6px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.minCal .v-btn__content {
|
|
||||||
font-weight: 410;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
@@ -134,9 +134,9 @@ const routes = [
|
|||||||
path: "/ical",
|
path: "/ical",
|
||||||
name: "Calendar",
|
name: "Calendar",
|
||||||
component: () =>
|
component: () =>
|
||||||
import("@/components/calendar_of_events/load-ical.vue"),
|
import("@/components/calendar_of_events/BigCalendar.vue"),
|
||||||
meta: {
|
meta: {
|
||||||
title: "Для работы над календарем",
|
title: "Календарь",
|
||||||
ico: "mdi-account",
|
ico: "mdi-account",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import { ref } from 'vue'
|
|||||||
|
|
||||||
export const useWeekendsStore = defineStore('weekends', () => {
|
export const useWeekendsStore = defineStore('weekends', () => {
|
||||||
|
|
||||||
const week = ref({ '2024': {'05': '09'} })
|
// const week = ref({ '2024': {'5': ["2024-05-08", "2024-05-11"], '6': ["2024-06-08", "2024-06-11"]} })
|
||||||
|
const week = ref({})
|
||||||
|
|
||||||
return { week }
|
return { week }
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user