Передача на бек
This commit is contained in:
1 parent
1347f2ee6e
commit
42ca24ed5a
7 files changed
+206
-120
No files matched your search
@@ -5,6 +5,10 @@ from django.conf import settings
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
from ckeditor_uploader.fields import RichTextUploadingField
|
from ckeditor_uploader.fields import RichTextUploadingField
|
||||||
|
|
||||||
|
class FilesEvent(models.Model):
|
||||||
|
name = models.CharField(max_length=300, verbose_name='Название файла')
|
||||||
|
link = models.FileField(upload_to='documents/%Y/%m/%d')
|
||||||
|
|
||||||
class CalendarEventsName(models.Model):
|
class CalendarEventsName(models.Model):
|
||||||
name=models.CharField(max_length=300, verbose_name='Название Календаря')
|
name=models.CharField(max_length=300, verbose_name='Название Календаря')
|
||||||
|
|
||||||
@@ -14,6 +18,7 @@ class EnumChoice(Enum):
|
|||||||
return [(enum_.name, enum_.value) for enum_ in cls]
|
return [(enum_.name, enum_.value) for enum_ in cls]
|
||||||
|
|
||||||
class FrequencyEvents(EnumChoice):
|
class FrequencyEvents(EnumChoice):
|
||||||
|
default = "Без периода"
|
||||||
daily = "Ежедневно"
|
daily = "Ежедневно"
|
||||||
weekly = "Еженедельно"
|
weekly = "Еженедельно"
|
||||||
monthly = "Ежемесячно"
|
monthly = "Ежемесячно"
|
||||||
@@ -25,9 +30,9 @@ class CalendarEvents(models.Model):
|
|||||||
description = RichTextUploadingField(null=True, blank= True, verbose_name='Описание события')
|
description = RichTextUploadingField(null=True, blank= True, verbose_name='Описание события')
|
||||||
cdate =models.DateTimeField(default=datetime.now, verbose_name='Дата создания')
|
cdate =models.DateTimeField(default=datetime.now, verbose_name='Дата создания')
|
||||||
enddate = models.DateTimeField(null=True, blank= True, default=datetime.now().replace(hour=23,minute=0,second=0,microsecond=0) + timedelta(days=7), verbose_name='Дата снятия с публикации')
|
enddate = models.DateTimeField(null=True, blank= True, default=datetime.now().replace(hour=23,minute=0,second=0,microsecond=0) + timedelta(days=7), verbose_name='Дата снятия с публикации')
|
||||||
frequency = models.CharField(verbose_name='Периодичность', max_length=255, db_index=True, choices=FrequencyEvents.get_choices())
|
frequency = models.CharField(verbose_name='Периодичность', max_length=255, db_index=True, choices=FrequencyEvents.get_choices(), default="default")
|
||||||
author = models.ForeignKey(settings.AUTH_USER_MODEL, editable=False, on_delete=models.PROTECT, verbose_name='Автор события')
|
author = models.ForeignKey(settings.AUTH_USER_MODEL, editable=False, on_delete=models.PROTECT, verbose_name='Автор события')
|
||||||
docfile = models.FileField(upload_to='documents/%Y/%m/%d')
|
docfile = models.ForeignKey(FilesEvent, on_delete=models.PROTECT, related_name='get_files_events', verbose_name='Прикрепеленные файлы')
|
||||||
place = models.CharField(max_length=500, verbose_name='Место проведения события')
|
place = models.CharField(max_length=500, verbose_name='Место проведения события')
|
||||||
calendarname = models.ForeignKey(CalendarEventsName, on_delete=models.PROTECT, related_name='get_calendar_events_name', verbose_name='Название для календаря')
|
calendarname = models.ForeignKey(CalendarEventsName, on_delete=models.PROTECT, related_name='get_calendar_events_name', verbose_name='Название для календаря')
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
from rest_framework import serializers
|
||||||
|
from .models import *
|
||||||
|
from userauth.serializers import *
|
||||||
@@ -4,5 +4,5 @@ from rest_framework.routers import DefaultRouter
|
|||||||
from .views import *
|
from .views import *
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
path('calendarEvents/', CalendarEventsAPIView.as_view(), name='calendarEvents'),
|
||||||
]
|
]
|
||||||
@@ -1,3 +1,15 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
from .serializers import *
|
||||||
|
from .models import *
|
||||||
|
from rest_framework.views import APIView
|
||||||
|
from rest_framework.response import Response
|
||||||
|
|
||||||
|
class CalendarEventsAPIView(APIView):
|
||||||
|
|
||||||
|
def get(self, request):
|
||||||
|
return Response('ku')
|
||||||
|
|
||||||
|
def post(self, request):
|
||||||
|
print(request.data['calendar'], '---------------------------')
|
||||||
|
return Response('ru')
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<v-menu
|
<v-menu
|
||||||
v-model="menu"
|
v-model="menu"
|
||||||
:close-on-content-click="false"
|
:close-on-content-click="false"
|
||||||
:nudge-width="500"
|
:max-width="800"
|
||||||
offset-x
|
offset-x
|
||||||
>
|
>
|
||||||
<template v-slot:activator="{ on, attrs }">
|
<template v-slot:activator="{ on, attrs }">
|
||||||
|
|||||||
@@ -1,32 +1,84 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<pre>
|
<!-- <my-helper :pretext="kl" /> -->
|
||||||
{{events}}
|
<v-btn @click="useICalReader"> ical</v-btn>
|
||||||
</pre>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {useICalReader} from '@/utils/universal_functions'
|
// import {useICalReader} from '@/utils/universal_functions'
|
||||||
import { baseURL, axiosApiInstance } from '@/utils/axios-api'
|
import { baseURL, axiosApiInstance } from '@/utils/axios-api'
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
import ical from "ical.js";
|
||||||
|
import { formatDash } from '@/utils/universal_functions'
|
||||||
|
|
||||||
const burl = baseURL.slice(0,-1)
|
const burl = baseURL.slice(0,-1)
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
const { events } = useICalReader(`${burl}/media/ical/calendar.ics`)
|
const participant = ref('')
|
||||||
|
const calendar = ref('')
|
||||||
|
const useICalReader = async () => {
|
||||||
|
const response = await fetch(`${burl}/media/ical/calendar.ics`);
|
||||||
|
const data = await response.text();
|
||||||
|
const jcalData = ical.parse(data);
|
||||||
|
const icalComponent = new ical.Component(jcalData);
|
||||||
|
const name = icalComponent.getFirstPropertyValue("x-wr-calname");
|
||||||
|
|
||||||
|
const events = icalComponent
|
||||||
|
.getAllSubcomponents("vevent")
|
||||||
|
.map((vevent) => new ical.Event(vevent));
|
||||||
|
|
||||||
|
const calendarEvents = events.map((event) => {
|
||||||
|
return {
|
||||||
|
summary: event.summary,
|
||||||
|
description: event.description,
|
||||||
|
organizer: event.organizer,
|
||||||
|
start: formatDash(event.startDate.toJSDate()),
|
||||||
|
end: formatDash(event.endDate.toJSDate()),
|
||||||
|
location: event.location,
|
||||||
|
event: event
|
||||||
|
}
|
||||||
|
})
|
||||||
|
participant.value = name
|
||||||
|
calendar.value = calendarEvents
|
||||||
|
console.log(name, 'name')
|
||||||
|
console.log(calendarEvents, 'calendarEventse')
|
||||||
|
f_feedbackdata()
|
||||||
|
// return {
|
||||||
|
// type: "calendar",
|
||||||
|
// title: name,
|
||||||
|
// calendar: calendarEvents,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// const s= useICalReader(`${burl}/media/ical/calendar.ics`)
|
||||||
|
// console.log(s.value, 'ddddddddd')
|
||||||
|
function f_feedbackdata() {
|
||||||
|
axiosApiInstance.post(`api/calendar_of_events/calendarEvents/`, {
|
||||||
|
participants: participant.value,
|
||||||
|
calendar: calendar.value
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
console.log(data,'datas')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
events
|
useICalReader
|
||||||
}
|
}
|
||||||
// const { icsContent, fetchICalFile } = useICalReader(`${burl}/media/ical/calendar.ics`)
|
|
||||||
|
|
||||||
// return {
|
|
||||||
// icsContent, fetchICalFile
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,147 +1,161 @@
|
|||||||
const str = 'hello';
|
const str = "hello";
|
||||||
import {useAccountStore} from '@/store/AccountStore'
|
import { useAccountStore } from "@/store/AccountStore";
|
||||||
import {useAppStore} from '@/store/app'
|
import { useAppStore } from "@/store/app";
|
||||||
import { baseURL } from '@/utils/axios-api'
|
import { baseURL } from "@/utils/axios-api";
|
||||||
import { axiosApiInstance, clearAxios } from '@/utils/axios-api'
|
import { axiosApiInstance, clearAxios } from "@/utils/axios-api";
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from "vue-router";
|
||||||
import moment from 'moment'
|
import moment from "moment";
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from "vue";
|
||||||
|
|
||||||
import ical from 'ical.js'
|
|
||||||
|
|
||||||
|
|
||||||
export function formatComa(date) {
|
export function formatComa(date) {
|
||||||
return moment(date).format('DD.MM.YYYY')
|
return moment(date).format("DD.MM.YYYY");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatDash(date) {
|
export function formatDash(date) {
|
||||||
return moment(date).format('YYYY-MM-DD')
|
return moment(date).format("YYYY-MM-DD");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formaComaTime(date) {
|
export function formaComaTime(date) {
|
||||||
return moment(date).format('DD.MM.YYYY H:mm')
|
return moment(date).format("DD.MM.YYYY H:mm");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function checking_for_entry (where, what) {
|
export function checking_for_entry(where, what) {
|
||||||
if (!where.includes(what))
|
if (!where.includes(what)) {
|
||||||
{
|
where.push(what);
|
||||||
where.push(what)
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getfromserver(path, reactive){
|
export function getfromserver(path, reactive) {
|
||||||
try{
|
try {
|
||||||
|
axiosApiInstance.get(path).then((result) => {
|
||||||
axiosApiInstance.get(path).then(result => {
|
reactive.value = result.data;
|
||||||
reactive.value = result.data})}
|
});
|
||||||
catch(e){
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function getfromserverfree(path, reactive){
|
export function getfromserverfree(path, reactive) {
|
||||||
try{
|
try {
|
||||||
clearAxios.get(path).then(result => {
|
clearAxios.get(path).then((result) => {
|
||||||
reactive.value = result.data})}
|
reactive.value = result.data;
|
||||||
catch(e){
|
});
|
||||||
console.log(e);
|
} catch (e) {
|
||||||
}
|
console.log(e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function checkremote(filecheck) {
|
||||||
|
return process.env.NODE_ENV == "development"
|
||||||
|
? "https://pixelbox.ru/wp-content/uploads/2021/11/avatar-whatsapp-pixelbox.ru-36.jpg"
|
||||||
|
: filecheck;
|
||||||
export function checkremote(filecheck){
|
}
|
||||||
|
|
||||||
return process.env.NODE_ENV == 'development'? "https://pixelbox.ru/wp-content/uploads/2021/11/avatar-whatsapp-pixelbox.ru-36.jpg":filecheck
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default str;
|
export default str;
|
||||||
|
|
||||||
export function splitname (name) {
|
export function splitname(name) {
|
||||||
return name.familyname + ' ' + name.name[0] + '.' + name.parentname[0]+ '.'
|
return name.familyname + " " + name.name[0] + "." + name.parentname[0] + ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function pagecounter(){
|
export function pagecounter() {
|
||||||
|
const router = useRouter();
|
||||||
const router = useRouter()
|
const accountStore = useAccountStore();
|
||||||
const accountStore = useAccountStore()
|
const appStore = useAppStore();
|
||||||
const appStore = useAppStore()
|
|
||||||
|
|
||||||
let postdata = {
|
let postdata = {
|
||||||
user__id: "user" in accountStore &&"id" in accountStore.user? accountStore.user.id: null,
|
user__id:
|
||||||
|
"user" in accountStore && "id" in accountStore.user
|
||||||
|
? accountStore.user.id
|
||||||
|
: null,
|
||||||
page: router.currentRoute.value.meta.title,
|
page: router.currentRoute.value.meta.title,
|
||||||
fullPath: router.currentRoute.value.fullPath,
|
fullPath: router.currentRoute.value.fullPath,
|
||||||
ico: router.currentRoute.value.meta.ico
|
ico: router.currentRoute.value.meta.ico,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
clearAxios.post(`${baseURL}api/watcher/counter/`, postdata).then((result) => {
|
||||||
|
appStore.countvisitor = result.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
clearAxios.post(`${baseURL}api/watcher/counter/`, postdata)
|
export function getDevelopment() {
|
||||||
.then(result => {
|
return process.env.NODE_ENV == "development" ? true : false;
|
||||||
appStore.countvisitor = result.data
|
}
|
||||||
})
|
|
||||||
|
|
||||||
|
export function useICalReader(url) {
|
||||||
|
///
|
||||||
|
const events = ref([]);
|
||||||
|
|
||||||
}
|
const loadICalFile = async () => {
|
||||||
|
try {
|
||||||
|
const response = await fetch(url);
|
||||||
|
const data = await response.text();
|
||||||
|
const jcalData = ical.parse(data);
|
||||||
|
const icalComponent = new ical.Component(jcalData);
|
||||||
|
const name = icalComponent.getFirstPropertyValue("x-wr-calname");
|
||||||
|
|
||||||
export function getDevelopment() {
|
const events = icalComponent
|
||||||
return process.env.NODE_ENV == 'development'?true:false
|
.getAllSubcomponents("vevent")
|
||||||
}
|
.map((vevent) => new ical.Event(vevent));
|
||||||
|
|
||||||
export function useICalReader(url) {
|
const calendarEvents = events.map((event) => {
|
||||||
///
|
return {
|
||||||
const events = ref([])
|
summary: event.summary,
|
||||||
|
description: event.description,
|
||||||
|
organizer: event.organizer,
|
||||||
|
attendee_count: event.attendees.length,
|
||||||
|
duration_seconds: event.duration.toSeconds(),
|
||||||
|
start: event.startDate.toJSDate().getTime() / 1000,
|
||||||
|
end: event.endDate.toJSDate().getTime() / 1000,
|
||||||
|
location: event.location,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const loadICalFile = async () => {
|
return {
|
||||||
try {
|
type: "calendar",
|
||||||
const response = await fetch(url)
|
title: name,
|
||||||
const data = await response.text()
|
calendar: calendarEvents,
|
||||||
const jcalData = ical.parse(data)
|
|
||||||
const comp = new ical.Component(jcalData)
|
|
||||||
const vevents = comp.getAllSubcomponents('vevent')
|
|
||||||
const eventsData = vevents.map(vevent => ({
|
|
||||||
vevent: vevent
|
|
||||||
// summary: vevent.getFirstPropertyValue('summary'),
|
|
||||||
// start: vevent.getFirstPropertyValue('dtstart'),
|
|
||||||
// end: vevent.getFirstPropertyValue('dtend')
|
|
||||||
}))
|
|
||||||
events.value = eventsData
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// const vevents = comp.getAllSubcomponents('vevent')
|
||||||
|
// const eventsData = vevents.map(vevent => ({
|
||||||
|
// vevent: vevent,
|
||||||
|
|
||||||
|
// summary: vevent.getFirstPropertyValue('summary'),
|
||||||
|
// start: vevent.getFirstPropertyValue('dtstart'),
|
||||||
|
// end: vevent.getFirstPropertyValue('dtend')
|
||||||
|
// }))
|
||||||
|
// events.value = eventsData
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadICalFile()
|
loadICalFile();
|
||||||
})
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
events
|
events,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// export function useICalReader(filePath) {
|
||||||
|
// const icsContent = ref('')
|
||||||
|
|
||||||
// export function useICalReader(filePath) {
|
// const fetchICalFile = async () => {
|
||||||
// const icsContent = ref('')
|
// try {
|
||||||
|
// const response = await fetch(filePath)
|
||||||
|
// if (!response.ok) {
|
||||||
|
// throw new Error('Ошибка при загрузке файла')
|
||||||
|
// }
|
||||||
|
// const data = await response.text()
|
||||||
|
// icsContent.value = data
|
||||||
|
// } catch (error) {
|
||||||
|
// console.error('Ошибка при чтении файла:', error)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// const fetchICalFile = async () => {
|
// return { icsContent, fetchICalFile }
|
||||||
// try {
|
// }
|
||||||
// const response = await fetch(filePath)
|
|
||||||
// if (!response.ok) {
|
|
||||||
// throw new Error('Ошибка при загрузке файла')
|
|
||||||
// }
|
|
||||||
// const data = await response.text()
|
|
||||||
// icsContent.value = data
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error('Ошибка при чтении файла:', error)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return { icsContent, fetchICalFile }
|
|
||||||
// }
|
|
||||||
Reference in new issue
Block a user