-
Notifications
You must be signed in to change notification settings - Fork 0
/
forms.py
33 lines (25 loc) · 915 Bytes
/
forms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import datetime
from django.utils.translation import gettext_lazy as _
from django import forms
from .models import Task
class TaskForm(forms.ModelForm):
class Meta:
model = Task
fields = ('name', 'category', 'description',
'task_date', 'task_deadline', 'task_important')
widgets = {
'task_date': forms.DateTimeInput(attrs={'class': 'datetime-input'}),
'task_deadline': forms.DateTimeInput(attrs={'class': 'datetime-input'})
}
def event(self):
event = {
'summary': self.cleaned_data['name'],
'description': self.cleaned_data['description'],
'start': {
'dateTime': self.cleaned_data['task_date'].isoformat(),
},
'end': {
'dateTime': self.cleaned_data['task_deadline'].isoformat(),
}
}
return event