P-52 решен вопрос с праздниками

This commit is contained in:
iriska-gri committed 2024-05-27 13:08:22 +03:00
1 parent 96ceeb3252
commit 37599fc85a
7 files changed
+179 -74

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@ class CalendarEventsName(models.Model):
# def get_choices(cls):
# return [(enum_.name, enum_.value) for enum_ in cls]
# class FrequencyEvents(EnumChoice):
# class FrequencyEvents(EnumChoice):
# default = "Без периода"
# daily = "Ежедневно"
# weekly = "Еженедельно"
+1
View File
@@ -5,4 +5,5 @@ from .views import *
urlpatterns = [
path('calendarEvents/', CalendarEventsAPIView.as_view(), name='calendarEvents'),
path('exclusionDatas/', ExclusionDatesAPIView.as_view(), name='exclusionDatas'),
]
+17 -11
View File
@@ -4,11 +4,12 @@ from .models import *
from rest_framework.views import APIView
from rest_framework.response import Response
import json
from django.db.models.functions import TruncYear
class CalendarEventsAPIView(APIView):
def updateCreate(self, ev, calendar, bigname):
print('2222222-- -----------------------------------------------------------------------2222', calendar)
CalendarEvents.objects.update_or_create(**ev,
defaults = {**calendar,
'author': User.objects.get(pk=self.request.user.id),
@@ -35,16 +36,14 @@ class CalendarEventsAPIView(APIView):
namecalendar, created = CalendarEventsName.objects.update_or_create(name=request.data['participants'],
defaults = {'name':request.data['participants'],
'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']:
# 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'])
event = {"calendarname_id":namecalendar.pk,
"pk": json.loads(request.data['calendar'])['pk'],}
self.updateCreate(event, json.loads(request.data['calendar']), namecalendar)
else:
for cal in request.data['calendar']:
@@ -52,11 +51,18 @@ class CalendarEventsAPIView(APIView):
"name": cal['name'],
"author_id": self.request.user.id}
self.updateCreate(event, cal, namecalendar)
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('ru')
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>
<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
v-model="drawer_right"
floating
permanent
location="right"
rail-width="400"
rail
>
</v-navigation-drawer>
</v-row>
<!-- <div>
<div>
<v-btn @click="f_feedbackdata"> ical</v-btn>
<v-file-input
@@ -57,12 +15,12 @@
accept=".ics"
@input="handleFilesUpload"
/>
</div> -->
</div>
</template>
<script>
import { axiosApiInstance } from "@/utils/axios-api";
import { ref, computed, onMounted } from "vue";
import { ref, onMounted } from "vue";
import ical from "ical.js";
import { useWeekendsStore } from '@/store/WeekendsStore'
@@ -167,17 +125,5 @@ export default {
</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>
+2 -2
View File
@@ -134,9 +134,9 @@ const routes = [
path: "/ical",
name: "Calendar",
component: () =>
import("@/components/calendar_of_events/load-ical.vue"),
import("@/components/calendar_of_events/BigCalendar.vue"),
meta: {
title: "Для работы над календарем",
title: "Календарь",
ico: "mdi-account",
},
},
+2 -2
View File
@@ -4,8 +4,8 @@ import { ref } from 'vue'
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 }
},