Изменить дату без времени
This commit is contained in:
1 parent
4446456b71
commit
264342cef4
8 files changed
+150
-154
No files matched your search
@@ -21,7 +21,7 @@ class CalendarEventsSerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = CalendarEvents
|
||||
fields = ['pk', 'name', 'description', 'cdate', 'enddate', 'frequency', 'author', 'files', 'place', 'participants']
|
||||
fields = ['pk', 'name', 'description', 'cdate', 'enddate', 'frequency', 'author', 'files', 'place', 'participants', 'startdate']
|
||||
|
||||
def get_user(self, obj):
|
||||
return InfoUserCardSerializer(obj.author.user).data
|
||||
|
||||
@@ -6,6 +6,20 @@ from rest_framework.response import Response
|
||||
|
||||
class CalendarEventsAPIView(APIView):
|
||||
|
||||
def updateCreate(self, ev, calendar, bigname):
|
||||
CalendarEvents.objects.update_or_create(**ev,
|
||||
defaults = {'name': calendar['summary'],
|
||||
'description': calendar['description'],
|
||||
'cdate':calendar['cdate'],
|
||||
'startdate':calendar['start'],
|
||||
'enddate': calendar['end'],
|
||||
'author_id': self.request.user.id,
|
||||
'place': calendar['location'],
|
||||
'calendarname_id': bigname.pk,
|
||||
'frequency': 'repeat: {weekdays: [5] }',
|
||||
'content': calendar['content']
|
||||
})
|
||||
|
||||
def get(self, request):
|
||||
cal = CalendarEventsName.objects.all()
|
||||
|
||||
@@ -17,35 +31,27 @@ 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})
|
||||
|
||||
|
||||
for cal in request.data['calendar']:
|
||||
print(request.data['calendar'], 'request.data[]')
|
||||
|
||||
print(request.data['calendar'], '----------------------request.data[]')
|
||||
if 'pk' in request.data['calendar']:
|
||||
event = {"calendarname_id":namecalendar.pk,
|
||||
"name": cal['summary'],
|
||||
"author_id": self.request.user.id}
|
||||
"pk": request.data['calendar']['pk'],}
|
||||
self.updateCreate(event, request.data['calendar'], namecalendar)
|
||||
|
||||
|
||||
|
||||
|
||||
CalendarEvents.objects.update_or_create(**event,
|
||||
defaults = {'name': cal['summary'],
|
||||
'description': cal['description'],
|
||||
'cdate':cal['cdate'],
|
||||
'startdate':cal['start'],
|
||||
'enddate': cal['end'],
|
||||
'author_id': self.request.user.id,
|
||||
'place': cal['location'],
|
||||
'calendarname_id': namecalendar.pk,
|
||||
'frequency': 'repeat: {weekdays: [5] }'
|
||||
})
|
||||
# if len(cal['attendees']) > 0 :
|
||||
# for player in cal['attendees']:
|
||||
# print(player, '5555555555555')
|
||||
# ParticipantsEvent.objects.update_or_create(participant=player,
|
||||
# event=envent.pk,
|
||||
# defaults= {'participant':player,
|
||||
# 'event':envent.pk
|
||||
|
||||
else:
|
||||
for cal in request.data['calendar']:
|
||||
event = {"calendarname_id":namecalendar.pk,
|
||||
"name": cal['summary'],
|
||||
"author_id": self.request.user.id}
|
||||
self.updateCreate(event, cal, namecalendar)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# })
|
||||
|
||||
|
||||
return Response('ru')
|
||||
@@ -146,7 +146,7 @@ class roundExcel():
|
||||
|
||||
self.wb.save(file_path)
|
||||
return file_path
|
||||
|
||||
|
||||
def convert_width(self, width):
|
||||
"""
|
||||
Конвертируем ширину столбца Excel в ширину столбца openpyxl
|
||||
|
||||
@@ -2,31 +2,24 @@
|
||||
<v-row>
|
||||
<v-col class="flex-column pr-0">
|
||||
<v-card class="h-100">
|
||||
<my-helper :pretext="selectedEvent" />
|
||||
<!-- <my-helper :pretext="selectedEvent" /> -->
|
||||
|
||||
<vue-cal
|
||||
locale="ru"
|
||||
xsmall
|
||||
:selected-date="new Date()"
|
||||
:time-from="8 * 60"
|
||||
:time-to="23 * 60"
|
||||
hide-view-selector
|
||||
events-count-on-year-view
|
||||
editable-events
|
||||
show-all-day-events
|
||||
todayButton
|
||||
:events="events"
|
||||
:on-event-click="onEventClick"
|
||||
active-view="month"
|
||||
:disable-views="['years', 'year', 'week', 'day']"
|
||||
@cell-focus="selectedDate = $event"
|
||||
@event-drag-create="showEventCreationDialog = true"
|
||||
>
|
||||
<template #arrow-prev>
|
||||
<v-icon icon="mdi-menu-left"></v-icon>
|
||||
<v-icon icon="mdi-menu-left"/>
|
||||
</template>
|
||||
<template #arrow-next>
|
||||
<v-icon icon="mdi-menu-right"></v-icon>
|
||||
<v-icon icon="mdi-menu-right"/>
|
||||
</template>
|
||||
<template #today-button>
|
||||
<v-tooltip text="Сегодня" location="bottom">
|
||||
@@ -36,7 +29,7 @@
|
||||
v-bind="props"
|
||||
icon="mdi-crosshairs-gps"
|
||||
size="x-small"
|
||||
class="pt-1 pr-3"
|
||||
class="pr-3"
|
||||
color="more_details_btn"
|
||||
/>
|
||||
</template>
|
||||
@@ -60,23 +53,26 @@
|
||||
<vue-cal
|
||||
locale="ru"
|
||||
hideTitleBar
|
||||
split
|
||||
header-format="DD"
|
||||
active-view="day"
|
||||
:disable-views="['years', 'year', 'month', 'week']"
|
||||
:selected-date="selectedDate"
|
||||
small
|
||||
:time-from="8 * 60"
|
||||
:time-to="20 * 60"
|
||||
xsmall
|
||||
hide-view-selector
|
||||
hide-title-bar
|
||||
hide-weekends
|
||||
editable-events
|
||||
:time="false"
|
||||
:events="events"
|
||||
:on-event-create="onEventCreate"
|
||||
:on-event-dblclick="onEventClick"
|
||||
@event-drag-create="showEventCreationDialog = true"
|
||||
|
||||
>
|
||||
<template #cell-content="{ view, events }">
|
||||
<v-img
|
||||
v-if="['week', 'day'].includes(view.id) && !events.length"
|
||||
class="align-end text-white cursor-default"
|
||||
height="200"
|
||||
:src="`${burl}/media/newsimage/calendar_stub.jpg`"
|
||||
cover
|
||||
/>
|
||||
<!-- <span class="vuecal__no-event" v-if="['week', 'day'].includes(view.id) && !events.length">Событий нет 👌</span> -->
|
||||
</template>
|
||||
</vue-cal>
|
||||
</v-card>
|
||||
</v-col>
|
||||
@@ -87,6 +83,7 @@
|
||||
import VueCal from "vue-cal";
|
||||
import "vue-cal/dist/vuecal.css";
|
||||
import { ref } from "vue";
|
||||
import { baseURL } from "@/utils/axios-api";
|
||||
import { axiosApiInstance } from "@/utils/axios-api";
|
||||
import { formaDashTime } from "@/utils/universal_functions";
|
||||
import EventDialog from "@/components/calendar_of_events/event-dialog.vue";
|
||||
@@ -97,31 +94,8 @@ export default {
|
||||
const selectedEvent = ref({});
|
||||
const eventsCssClasses = ["bg-red", "bg-blue", "bg-green"];
|
||||
const showDialog = ref(false);
|
||||
const showEventCreationDialog = ref(false);
|
||||
const events = ref([
|
||||
// {
|
||||
// start: '2024-04-15 14:00',
|
||||
// end: '2024-04-25 18:00',
|
||||
// title: 'Need to go shopping',
|
||||
// icon: 'shopping_cart', // Custom attribute.
|
||||
// content: 'Click to see my shopping list',
|
||||
// contentFull: 'My shopping list is rather long:<br><ul><li>Avocados</li><li>Tomatoes</li><li>Potatoes</li><li>Mangoes</li></ul>', // Custom attribute.
|
||||
// class: 'leisure',
|
||||
// repeat: {
|
||||
// every: 'week', // You can repeat on multiple days of the week.
|
||||
// until: '2024-05-30' // Don't need a time here as it will take the same as original event date.
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// start: '2024-04-15 10:00',
|
||||
// end: '2024-04-25 15:00',
|
||||
// title: 'Golf with John',
|
||||
// icon: 'golf_course', // Custom attribute.
|
||||
// content: 'Do I need to tell how many holes?',
|
||||
// contentFull: 'Okay.<br>It will be a 18 hole golf course.', // Custom attribute.
|
||||
// class: 'sport'
|
||||
// }
|
||||
]);
|
||||
const burl = baseURL.slice(0, -1);
|
||||
const events = ref([]);
|
||||
|
||||
const onEventClick = (event, e) => {
|
||||
selectedEvent.value = event;
|
||||
@@ -129,23 +103,8 @@ export default {
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
const onEventCreate = (event, deleteEventFunction) => {
|
||||
console.log(event, deleteEventFunction, "event, deleteEventFunction");
|
||||
selectedEvent.value = event;
|
||||
showEventCreationDialog.value = true;
|
||||
deleteEventFunction.value = deleteEventFunction;
|
||||
|
||||
return event;
|
||||
};
|
||||
|
||||
const cancelEventCreation = () => {
|
||||
closeCreationDialog();
|
||||
deleteEventFunction();
|
||||
};
|
||||
const closeCreationDialog = () => {
|
||||
showEventCreationDialog.value = false;
|
||||
selectedEvent.value = {};
|
||||
};
|
||||
|
||||
function f_generalvacation() {
|
||||
axiosApiInstance
|
||||
@@ -154,13 +113,17 @@ export default {
|
||||
for (let key in data.data) {
|
||||
for (let x in data.data[key].event) {
|
||||
events.value.push({
|
||||
bigname: data.data[key].name,
|
||||
pk: data.data[key].event[x].pk,
|
||||
start: formaDashTime(data.data[key].event[x].cdate),
|
||||
end: formaDashTime(data.data[key].event[x].enddate),
|
||||
start: formaDashTime(data.data[key].event[x].startdate),
|
||||
end: formaDashTime(data.data[key].event[x].startdate),
|
||||
title: data.data[key].event[x].name,
|
||||
contentFull: data.data[key].event[x].description,
|
||||
icon: "mdi-book-open",
|
||||
class: "bg-indigo-lighten-5 border-sm",
|
||||
place: data.data[key].event[x].place,
|
||||
cdate: data.data[key].event[x].cdate,
|
||||
enddate: formaDashTime(data.data[key].event[x].enddate),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -189,11 +152,8 @@ export default {
|
||||
dayformat,
|
||||
showDialog,
|
||||
onEventClick,
|
||||
showEventCreationDialog,
|
||||
eventsCssClasses,
|
||||
onEventCreate,
|
||||
closeCreationDialog,
|
||||
cancelEventCreation,
|
||||
burl,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -320,4 +280,8 @@ export default {
|
||||
.vuecal__event-content {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.vuecal__cell-content {
|
||||
cursor: default;
|
||||
}
|
||||
</style>
|
||||
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
<v-textarea v-model="event.bigname" placeholder="Название календаря" />
|
||||
<v-text-field v-model="event.title" placeholder="Заголовок" />
|
||||
</v-card-title>
|
||||
<v-card-subtitle>
|
||||
@@ -40,12 +41,15 @@
|
||||
show-adjacent-months
|
||||
hide-header
|
||||
border
|
||||
no-time
|
||||
@update:modelValue = "updateDate"
|
||||
/>
|
||||
</v-locale-provider>
|
||||
</v-menu>
|
||||
</v-card-subtitle>
|
||||
<v-card-text class="pt-2">
|
||||
<v-textarea v-model="event.content" placeholder="Описание события" />
|
||||
|
||||
<v-textarea
|
||||
v-model="event.contentFull"
|
||||
placeholder="Полное описание события"
|
||||
@@ -132,16 +136,21 @@ export default {
|
||||
).padStart(2, "0")}`
|
||||
);
|
||||
const selectedDateTime = ref(new Date());
|
||||
const selectedTime = ref(new Date());
|
||||
|
||||
|
||||
const updateDateTime = (time, period) => {
|
||||
if (time) {
|
||||
const timeParts = time.split(":");
|
||||
|
||||
props.event[period].setHours(parseInt(timeParts[0], 10));
|
||||
props.event[period].setMinutes(parseInt(timeParts[1], 10));
|
||||
}
|
||||
};
|
||||
|
||||
const updateDate = () => {
|
||||
console.log('sssssssssssssssssssssssss');
|
||||
}
|
||||
|
||||
return {
|
||||
menudate,
|
||||
formatComa,
|
||||
@@ -150,6 +159,7 @@ export default {
|
||||
endTime,
|
||||
selectedDateTime,
|
||||
updateDateTime,
|
||||
updateDate
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,57 +1,57 @@
|
||||
<template>
|
||||
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
|
||||
<v-icon color="indigo-darken-3" class="pb-1">{{ event.icon }}</v-icon>
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
<v-icon color="indigo-darken-3" class="pb-1">{{ event.icon }}</v-icon>
|
||||
|
||||
<span class="pl-3"> {{ event.title }}</span>
|
||||
</v-card-title>
|
||||
<v-card-subtitle>
|
||||
<strong>{{ event.start && event.start.format("DD.MM.YYYY") }}</strong>
|
||||
</v-card-subtitle>
|
||||
<v-card-text class="pt-2">
|
||||
<p class="pb-3" v-html=formatText(event.contentFull) />
|
||||
<strong>Время:</strong>
|
||||
|
||||
<ul class="pl-5">
|
||||
<li>
|
||||
Начало:
|
||||
{{ event.start && event.start.formatTime() }}
|
||||
</li>
|
||||
<li>
|
||||
Окончание:
|
||||
{{ event.end && event.end.formatTime() }}
|
||||
</li>
|
||||
</ul>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { baseURL } from '@/utils/axios-api'
|
||||
export default {
|
||||
props: {
|
||||
|
||||
event: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
<span class="pl-3"> {{ event.title }}</span>
|
||||
</v-card-title>
|
||||
<v-card-subtitle>
|
||||
<strong>{{ event.start && event.start.format("DD.MM.YYYY") }}</strong>
|
||||
</v-card-subtitle>
|
||||
<v-card-text class="pt-2">
|
||||
<p class="pb-3" v-html="formatText(event.contentFull)" />
|
||||
<strong>Время:</strong>
|
||||
|
||||
<ul class="pl-5">
|
||||
<li>
|
||||
Начало:
|
||||
{{ event.start && event.start.formatTime() }}
|
||||
</li>
|
||||
<li>
|
||||
Окончание:
|
||||
{{ event.end && event.end.formatTime() }}
|
||||
</li>
|
||||
</ul>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { baseURL } from "@/utils/axios-api";
|
||||
export default {
|
||||
props: {
|
||||
event: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
|
||||
setup() {
|
||||
const formatText= (text) => {
|
||||
setup() {
|
||||
const formatText = (text) => {
|
||||
if (text !== null) {
|
||||
return text.replaceAll(
|
||||
'src="/media/uploads',
|
||||
`src="${baseURL}media/uploads`
|
||||
);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
return {
|
||||
formatText,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
return text.replaceAll('src="/media/uploads', `src="${baseURL}media/uploads`)
|
||||
|
||||
}
|
||||
return {
|
||||
formatText
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
<style></style>
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<v-dialog v-model="mydialog" max-width="700">
|
||||
<v-card>
|
||||
<my-helper :pretext="event" />
|
||||
<!-- <my-helper :pretext="event" /> -->
|
||||
<v-card-title>
|
||||
<v-icon
|
||||
:icon="editEvent ? 'mdi-check' : 'mdi-pencil'"
|
||||
@@ -21,6 +21,7 @@
|
||||
import { computed, ref } from "vue";
|
||||
import eventDialogEdit from "@/components/calendar_of_events/event-dialog-edit.vue";
|
||||
import eventDialogInfo from "@/components/calendar_of_events/event-dialog-info.vue";
|
||||
import { axiosApiInstance } from "@/utils/axios-api";
|
||||
|
||||
export default {
|
||||
components: { eventDialogEdit, eventDialogInfo },
|
||||
@@ -50,15 +51,29 @@ export default {
|
||||
const chekEvent = () => {
|
||||
if (editEvent.value) {
|
||||
editEvent.value = false;
|
||||
const editEvent ={
|
||||
name: props.event.title,
|
||||
const calendar ={
|
||||
cdate: props.event.cdate,
|
||||
summary: props.event.title,
|
||||
description: props.event.contentFull,
|
||||
content: props.event.content,
|
||||
startdate: props.event.start,
|
||||
enddate: props.event.end
|
||||
start: props.event.start,
|
||||
end: props.event.end,
|
||||
location: props.event.place,
|
||||
pk: props.event.pk
|
||||
|
||||
}
|
||||
console.log(props.event.end)
|
||||
const participants = props.event.bigname
|
||||
|
||||
axiosApiInstance
|
||||
.post(`api/calendar_of_events/calendarEvents/`, {
|
||||
participants: participants,
|
||||
calendar: calendar,
|
||||
})
|
||||
.then((data) => {
|
||||
console.log(data, "datas");
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
editEvent.value = true;
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@ export default {
|
||||
location: event.location,
|
||||
attendees: attendees,
|
||||
cdate: new Date(event.component.jCal[1][6][3]),
|
||||
content: ''
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user