Переименовка модели
This commit is contained in:
1 parent
264342cef4
commit
0e9e0f0934
5 files changed
+112
-110
No files matched your search
@@ -21,7 +21,7 @@ class CalendarEventsSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = CalendarEvents
|
model = CalendarEvents
|
||||||
fields = ['pk', 'name', 'description', 'cdate', 'enddate', 'frequency', 'author', 'files', 'place', 'participants', 'startdate']
|
fields = ['pk', 'name', 'description', 'cdate', 'enddate', 'frequency', 'author', 'files', 'place', 'participants', 'startdate', 'content']
|
||||||
|
|
||||||
def get_user(self, obj):
|
def get_user(self, obj):
|
||||||
return InfoUserCardSerializer(obj.author.user).data
|
return InfoUserCardSerializer(obj.author.user).data
|
||||||
|
|||||||
@@ -30,8 +30,9 @@ 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'], 'author_id': self.request.user.id})
|
defaults = {'name':request.data['participants'],
|
||||||
print(request.data['calendar'], '----------------------request.data[]')
|
'author_id': self.request.user.id})
|
||||||
|
|
||||||
if 'pk' in request.data['calendar']:
|
if 'pk' in request.data['calendar']:
|
||||||
event = {"calendarname_id":namecalendar.pk,
|
event = {"calendarname_id":namecalendar.pk,
|
||||||
"pk": request.data['calendar']['pk'],}
|
"pk": request.data['calendar']['pk'],}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<v-row>
|
<v-row>
|
||||||
<v-col class="flex-column pr-0">
|
<v-col class="flex-column pr-0">
|
||||||
<v-card class="h-100">
|
<v-card class="h-100">
|
||||||
<!-- <my-helper :pretext="selectedEvent" /> -->
|
<my-helper :pretext="selectedEvent" />
|
||||||
|
|
||||||
<vue-cal
|
<vue-cal
|
||||||
locale="ru"
|
locale="ru"
|
||||||
@@ -16,10 +16,10 @@
|
|||||||
@cell-focus="selectedDate = $event"
|
@cell-focus="selectedDate = $event"
|
||||||
>
|
>
|
||||||
<template #arrow-prev>
|
<template #arrow-prev>
|
||||||
<v-icon icon="mdi-menu-left"/>
|
<v-icon icon="mdi-menu-left" />
|
||||||
</template>
|
</template>
|
||||||
<template #arrow-next>
|
<template #arrow-next>
|
||||||
<v-icon icon="mdi-menu-right"/>
|
<v-icon icon="mdi-menu-right" />
|
||||||
</template>
|
</template>
|
||||||
<template #today-button>
|
<template #today-button>
|
||||||
<v-tooltip text="Сегодня" location="bottom">
|
<v-tooltip text="Сегодня" location="bottom">
|
||||||
@@ -40,6 +40,7 @@
|
|||||||
<event-dialog
|
<event-dialog
|
||||||
:event="selectedEvent"
|
:event="selectedEvent"
|
||||||
:opendialog="showDialog"
|
:opendialog="showDialog"
|
||||||
|
@returnUpdateData="returnUpdateData"
|
||||||
@update:opendialog="showDialog = $event"
|
@update:opendialog="showDialog = $event"
|
||||||
/>
|
/>
|
||||||
</v-card>
|
</v-card>
|
||||||
@@ -61,7 +62,6 @@
|
|||||||
:time="false"
|
:time="false"
|
||||||
:events="events"
|
:events="events"
|
||||||
:on-event-dblclick="onEventClick"
|
:on-event-dblclick="onEventClick"
|
||||||
|
|
||||||
>
|
>
|
||||||
<template #cell-content="{ view, events }">
|
<template #cell-content="{ view, events }">
|
||||||
<v-img
|
<v-img
|
||||||
@@ -71,7 +71,9 @@
|
|||||||
:src="`${burl}/media/newsimage/calendar_stub.jpg`"
|
:src="`${burl}/media/newsimage/calendar_stub.jpg`"
|
||||||
cover
|
cover
|
||||||
/>
|
/>
|
||||||
<!-- <span class="vuecal__no-event" v-if="['week', 'day'].includes(view.id) && !events.length">Событий нет 👌</span> -->
|
<v-card v-else>
|
||||||
|
{{events}}
|
||||||
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
</vue-cal>
|
</vue-cal>
|
||||||
</v-card>
|
</v-card>
|
||||||
@@ -103,10 +105,8 @@ export default {
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function f_generalvacation() {
|
function f_generalvacation() {
|
||||||
|
events.value = [];
|
||||||
axiosApiInstance
|
axiosApiInstance
|
||||||
.get("api/calendar_of_events/calendarEvents/")
|
.get("api/calendar_of_events/calendarEvents/")
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
@@ -119,6 +119,7 @@ export default {
|
|||||||
end: formaDashTime(data.data[key].event[x].startdate),
|
end: formaDashTime(data.data[key].event[x].startdate),
|
||||||
title: data.data[key].event[x].name,
|
title: data.data[key].event[x].name,
|
||||||
contentFull: data.data[key].event[x].description,
|
contentFull: data.data[key].event[x].description,
|
||||||
|
content: data.data[key].event[x].content,
|
||||||
icon: "mdi-book-open",
|
icon: "mdi-book-open",
|
||||||
class: "bg-indigo-lighten-5 border-sm",
|
class: "bg-indigo-lighten-5 border-sm",
|
||||||
place: data.data[key].event[x].place,
|
place: data.data[key].event[x].place,
|
||||||
@@ -130,6 +131,10 @@ export default {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const returnUpdateData = () => {
|
||||||
|
f_generalvacation();
|
||||||
|
};
|
||||||
|
|
||||||
f_generalvacation();
|
f_generalvacation();
|
||||||
|
|
||||||
const selectedDate = ref(null);
|
const selectedDate = ref(null);
|
||||||
@@ -154,6 +159,7 @@ export default {
|
|||||||
onEventClick,
|
onEventClick,
|
||||||
eventsCssClasses,
|
eventsCssClasses,
|
||||||
burl,
|
burl,
|
||||||
|
returnUpdateData,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-card>
|
<v-card>
|
||||||
|
{{dataToEdit}}
|
||||||
<v-card-title>
|
<v-card-title>
|
||||||
<v-textarea v-model="event.bigname" placeholder="Название календаря" />
|
<v-textarea
|
||||||
<v-text-field v-model="event.title" placeholder="Заголовок" />
|
v-model="dataToEdit.bigname"
|
||||||
|
placeholder="Название календаря"
|
||||||
|
/>
|
||||||
|
<v-text-field v-model="dataToEdit.title" placeholder="Заголовок" />
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-subtitle>
|
<v-card-subtitle>
|
||||||
<v-menu
|
<v-menu
|
||||||
@@ -14,8 +18,8 @@
|
|||||||
>
|
>
|
||||||
<template v-slot:activator="{ props }">
|
<template v-slot:activator="{ props }">
|
||||||
<v-textarea
|
<v-textarea
|
||||||
v-model="event.start"
|
v-model="dataToEdit.start"
|
||||||
:value="formatComa(event.start)"
|
:value="formatComa(dataToEdit.start)"
|
||||||
no-resize
|
no-resize
|
||||||
class="my-textarea"
|
class="my-textarea"
|
||||||
rows="1"
|
rows="1"
|
||||||
@@ -37,54 +41,31 @@
|
|||||||
</template>
|
</template>
|
||||||
<v-locale-provider locale="ru">
|
<v-locale-provider locale="ru">
|
||||||
<v-date-picker
|
<v-date-picker
|
||||||
v-model="event.start"
|
v-model="dataToEdit.start"
|
||||||
show-adjacent-months
|
show-adjacent-months
|
||||||
hide-header
|
hide-header
|
||||||
border
|
border
|
||||||
no-time
|
no-time
|
||||||
@update:modelValue = "updateDate"
|
@update:modelValue="updateDateTime"
|
||||||
/>
|
/>
|
||||||
</v-locale-provider>
|
</v-locale-provider>
|
||||||
</v-menu>
|
</v-menu>
|
||||||
</v-card-subtitle>
|
</v-card-subtitle>
|
||||||
<v-card-text class="pt-2">
|
<v-card-text class="pt-2">
|
||||||
<v-textarea v-model="event.content" placeholder="Описание события" />
|
<v-textarea v-model="dataToEdit.content" placeholder="Описание события" />
|
||||||
|
|
||||||
<v-textarea
|
<v-textarea
|
||||||
v-model="event.contentFull"
|
v-model="dataToEdit.contentFull"
|
||||||
placeholder="Полное описание события"
|
placeholder="Полное описание события"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<v-textarea
|
||||||
|
v-model="dataToEdit.place"
|
||||||
|
placeholder="Местопроведение события"
|
||||||
|
/>
|
||||||
<strong>Время:</strong>
|
<strong>Время:</strong>
|
||||||
|
|
||||||
<ul class="pl-5">
|
<ul class="pl-5">
|
||||||
<!-- <v-text-field
|
|
||||||
v-model="selectedDateTime"
|
|
||||||
:active="menu2"
|
|
||||||
:focus="menu2"
|
|
||||||
label="Picker in menu"
|
|
||||||
prepend-icon="mdi-clock-time-four-outline"
|
|
||||||
readonly
|
|
||||||
>
|
|
||||||
<v-menu
|
|
||||||
v-model="menu2"
|
|
||||||
:close-on-content-click="false"
|
|
||||||
activator="parent"
|
|
||||||
transition="scale-transition"
|
|
||||||
@input="updateDateTime"
|
|
||||||
>
|
|
||||||
<v-time-picker
|
|
||||||
v-if="menu2"
|
|
||||||
v-model="selectedDateTime"
|
|
||||||
full-width
|
|
||||||
|
|
||||||
></v-time-picker>
|
|
||||||
</v-menu>
|
|
||||||
</v-text-field> -->
|
|
||||||
|
|
||||||
<!-- <div>
|
|
||||||
<v-time-picker v-model="time" @click="updateDateTime"></v-time-picker>
|
|
||||||
</div> -->
|
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
@@ -92,27 +73,28 @@
|
|||||||
v-model="startTime"
|
v-model="startTime"
|
||||||
suffix="PST"
|
suffix="PST"
|
||||||
type="time"
|
type="time"
|
||||||
@input="updateDateTime(startTime, 'start')"
|
@update:modelValue="updateDateTime"
|
||||||
></v-text-field>
|
|
||||||
</v-col>
|
|
||||||
<v-col>
|
|
||||||
<v-text-field
|
|
||||||
label="Начало события"
|
|
||||||
v-model="endTime"
|
|
||||||
suffix="PST"
|
|
||||||
type="time"
|
|
||||||
@input="updateDateTime(endTime, 'end')"
|
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</ul>
|
</ul>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
<v-card-actions>
|
||||||
|
<v-icon
|
||||||
|
icon="mdi-check"
|
||||||
|
color="green"
|
||||||
|
class="pb-1"
|
||||||
|
@click="confirmation"
|
||||||
|
/>
|
||||||
|
</v-card-actions>
|
||||||
|
|
||||||
</v-card>
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { formatComa } from "@/utils/universal_functions";
|
import { formatComa } from "@/utils/universal_functions";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
import { axiosApiInstance } from "@/utils/axios-api";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -120,46 +102,64 @@ export default {
|
|||||||
type: Object,
|
type: Object,
|
||||||
default: () => {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setup(props, { event }) {
|
setup(props, { emit }) {
|
||||||
const menudate = ref(false);
|
const menudate = ref(false);
|
||||||
const menu2 = ref(false);
|
const dataToEdit = ref({...props.event})
|
||||||
|
|
||||||
const startTime = ref(
|
const startTime = ref(
|
||||||
`${props.event.start.getHours()}:${String(
|
`${dataToEdit.value.start.getHours()}:${String(
|
||||||
props.event.start.getMinutes()
|
dataToEdit.value.start.getMinutes()
|
||||||
).padStart(2, "0")}`
|
).padStart(2, "0")}`
|
||||||
);
|
);
|
||||||
const endTime = ref(
|
|
||||||
`${props.event.end.getHours()}:${String(
|
|
||||||
props.event.end.getMinutes()
|
|
||||||
).padStart(2, "0")}`
|
|
||||||
);
|
|
||||||
const selectedDateTime = ref(new Date());
|
|
||||||
|
|
||||||
|
const updateDateTime = () => {
|
||||||
const updateDateTime = (time, period) => {
|
if (startTime.value) {
|
||||||
if (time) {
|
const timeParts = startTime.value.split(":");
|
||||||
const timeParts = time.split(":");
|
dataToEdit.value.start.setHours(parseInt(timeParts[0], 10));
|
||||||
|
dataToEdit.value.start.setMinutes(parseInt(timeParts[1], 10));
|
||||||
props.event[period].setHours(parseInt(timeParts[0], 10));
|
|
||||||
props.event[period].setMinutes(parseInt(timeParts[1], 10));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateDate = () => {
|
|
||||||
console.log('sssssssssssssssssssssssss');
|
|
||||||
|
const confirmation = () => {
|
||||||
|
console.log('11111111111111')
|
||||||
|
// const calendar ={
|
||||||
|
// cdate: dataToEdit.value.cdate,
|
||||||
|
// summary: dataToEdit.value.title,
|
||||||
|
// description: dataToEdit.value.contentFull,
|
||||||
|
// content: dataToEdit.value.content,
|
||||||
|
// start: dataToEdit.value.start,
|
||||||
|
// end: dataToEdit.value.start,
|
||||||
|
// location: dataToEdit.value.place,
|
||||||
|
// pk: dataToEdit.value.pk
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
const participants = dataToEdit.value.bigname
|
||||||
|
|
||||||
|
axiosApiInstance
|
||||||
|
.post(`api/calendar_of_events/calendarEvents/`, {
|
||||||
|
participants: participants,
|
||||||
|
calendar: dataToEdit.value,
|
||||||
|
})
|
||||||
|
.then((data) => {
|
||||||
|
emit('returnUpdateData')
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
menudate,
|
menudate,
|
||||||
formatComa,
|
formatComa,
|
||||||
menu2,
|
|
||||||
startTime,
|
startTime,
|
||||||
endTime,
|
|
||||||
selectedDateTime,
|
|
||||||
updateDateTime,
|
updateDateTime,
|
||||||
updateDate
|
dataToEdit,
|
||||||
|
confirmation
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,15 +4,20 @@
|
|||||||
<!-- <my-helper :pretext="event" /> -->
|
<!-- <my-helper :pretext="event" /> -->
|
||||||
<v-card-title>
|
<v-card-title>
|
||||||
<v-icon
|
<v-icon
|
||||||
:icon="editEvent ? 'mdi-check' : 'mdi-pencil'"
|
:icon="editEvent ? 'mdi-book-open-variant' : 'mdi-pencil'"
|
||||||
color="indigo-darken-3"
|
color="indigo-darken-3"
|
||||||
class="pb-1"
|
class="pb-1"
|
||||||
@click="chekEvent"
|
@click="modeEvent"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
</v-card>
|
</v-card>
|
||||||
<!-- @returndate="returnend" -->
|
<!-- mdi-check-->
|
||||||
<event-dialog-edit :event="event" v-if="editEvent" />
|
<event-dialog-edit
|
||||||
|
v-if="editEvent"
|
||||||
|
:event="event"
|
||||||
|
@returnUpdateData="returnUpdateData"
|
||||||
|
/>
|
||||||
<event-dialog-info :event="event" v-else />
|
<event-dialog-info :event="event" v-else />
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
</template>
|
</template>
|
||||||
@@ -45,44 +50,34 @@ export default {
|
|||||||
set: (value) => emit("update:opendialog", value),
|
set: (value) => emit("update:opendialog", value),
|
||||||
});
|
});
|
||||||
|
|
||||||
// const editEvent = () => {
|
|
||||||
// console.log('hello')
|
const modeEvent = () => {
|
||||||
// }
|
|
||||||
const chekEvent = () => {
|
|
||||||
if (editEvent.value) {
|
if (editEvent.value) {
|
||||||
editEvent.value = false;
|
editEvent.value = false;
|
||||||
const calendar ={
|
|
||||||
cdate: props.event.cdate,
|
|
||||||
summary: props.event.title,
|
|
||||||
description: props.event.contentFull,
|
|
||||||
content: props.event.content,
|
|
||||||
start: props.event.start,
|
|
||||||
end: props.event.end,
|
|
||||||
location: props.event.place,
|
|
||||||
pk: props.event.pk
|
|
||||||
|
|
||||||
}
|
|
||||||
const participants = props.event.bigname
|
|
||||||
|
|
||||||
axiosApiInstance
|
|
||||||
.post(`api/calendar_of_events/calendarEvents/`, {
|
|
||||||
participants: participants,
|
|
||||||
calendar: calendar,
|
|
||||||
})
|
|
||||||
.then((data) => {
|
|
||||||
console.log(data, "datas");
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
editEvent.value = true;
|
editEvent.value = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const chekEvent = () => {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
const returnUpdateData = () => {
|
||||||
|
mydialog.value= false
|
||||||
|
emit('returnUpdateData')
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mydialog,
|
mydialog,
|
||||||
editEvent,
|
editEvent,
|
||||||
chekEvent,
|
chekEvent,
|
||||||
|
modeEvent,
|
||||||
|
returnUpdateData
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user