Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_group 25
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Andre Matthew Dumandan
widget_group 25
Commits
da63b246
Commit
da63b246
authored
May 25, 2022
by
Rau Layug
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed commented code
parent
9f4d9bb7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
23 deletions
+19
-23
forms.py
widget_group_25/calendarapp/forms.py
+0
-13
models.py
widget_group_25/calendarapp/models.py
+4
-1
views.py
widget_group_25/calendarapp/views.py
+15
-9
No files found.
widget_group_25/calendarapp/forms.py
View file @
da63b246
...
@@ -5,19 +5,6 @@ import datetime
...
@@ -5,19 +5,6 @@ import datetime
from
.models
import
Location
,
Event
from
.models
import
Location
,
Event
from
assignments.models
import
Course
from
assignments.models
import
Course
'''
class LocationForm(forms.ModelForm):
model = Location
fields = ['mode', 'venue', 'image']
class EventForm(forms.ModelForm):
class Meta:
model = Event
fields = ['target_date', 'activity', 'estimated_hours', 'course',
'location']
'''
class
EventForm
(
forms
.
Form
):
class
EventForm
(
forms
.
Form
):
target_date
=
forms
.
DateField
(
initial
=
datetime
.
date
.
today
)
target_date
=
forms
.
DateField
(
initial
=
datetime
.
date
.
today
)
...
...
widget_group_25/calendarapp/models.py
View file @
da63b246
...
@@ -12,7 +12,10 @@ class Location(models.Model):
...
@@ -12,7 +12,10 @@ class Location(models.Model):
]
]
mode
=
models
.
CharField
(
max_length
=
3
,
choices
=
MODE_CHOICES
)
mode
=
models
.
CharField
(
max_length
=
3
,
choices
=
MODE_CHOICES
)
venue
=
models
.
CharField
(
max_length
=
150
)
venue
=
models
.
CharField
(
max_length
=
150
)
image
=
models
.
ImageField
(
upload_to
=
'calendarapp/location_images'
,
height_field
=
None
,
width_field
=
None
,
max_length
=
100
)
image
=
models
.
ImageField
(
upload_to
=
'calendarapp/location_images'
,
height_field
=
None
,
width_field
=
None
,
max_length
=
100
)
def
__str__
(
self
):
def
__str__
(
self
):
...
...
widget_group_25/calendarapp/views.py
View file @
da63b246
...
@@ -10,27 +10,33 @@ from assignments.models import Course
...
@@ -10,27 +10,33 @@ from assignments.models import Course
# Create your views here.
# Create your views here.
class
CalendarView
(
View
):
class
CalendarView
(
View
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
return
render
(
request
,
'calendarapp/calendar.html'
,
{
'Courses'
:
Course
.
objects
.
all
()
.
order_by
(
'course_code'
),
'Events'
:
Event
.
objects
.
all
()
.
order_by
(
'target_date'
)})
return
render
(
request
,
'calendarapp/calendar.html'
,
{
'Courses'
:
Course
.
objects
.
all
()
.
order_by
(
'course_code'
),
'Events'
:
Event
.
objects
.
all
()
.
order_by
(
'target_date'
)})
def
add_event
(
request
):
def
add_event
(
request
):
if
request
.
method
==
'POST'
:
if
request
.
method
==
'POST'
:
form
=
EventForm
(
request
.
POST
,
request
.
FILES
)
form
=
EventForm
(
request
.
POST
,
request
.
FILES
)
if
form
.
is_valid
():
if
form
.
is_valid
():
new_location
=
Location
(
mode
=
form
.
cleaned_data
.
get
(
'mode'
),
venue
=
form
.
cleaned_data
.
get
(
'venue'
),
image
=
form
.
cleaned_data
.
get
(
'image'
))
new_location
=
Location
(
mode
=
form
.
cleaned_data
.
get
(
'mode'
),
venue
=
form
.
cleaned_data
.
get
(
'venue'
),
image
=
form
.
cleaned_data
.
get
(
'image'
))
new_location
.
save
()
new_location
.
save
()
new_event
=
Event
(
target_date
=
form
.
cleaned_data
.
get
(
'target_date'
),
activity
=
form
.
cleaned_data
.
get
(
'activity'
),
estimated_hours
=
form
.
cleaned_data
.
get
(
'estimated_hours'
),
course
=
form
.
cleaned_data
.
get
(
'course'
),
location
=
new_location
)
new_event
=
Event
(
target_date
=
form
.
cleaned_data
.
get
(
'target_date'
),
activity
=
form
.
cleaned_data
.
get
(
'activity'
),
estimated_hours
=
form
.
cleaned_data
.
get
(
'estimated_hours'
),
course
=
form
.
cleaned_data
.
get
(
'course'
),
location
=
new_location
)
new_event
.
save
()
new_event
.
save
()
return
render
(
request
,
'calendarapp/events.html'
,
{
'event'
:
Event
.
objects
.
get
(
id
=
new_event
.
id
)})
return
render
(
request
,
'calendarapp/events.html'
,
{
'event'
:
Event
.
objects
.
get
(
id
=
new_event
.
id
)})
return
HttpResponse
(
'invalid form'
)
return
HttpResponse
(
'invalid form'
)
else
:
else
:
form
=
EventForm
()
form
=
EventForm
()
return
render
(
request
,
'calendarapp/add_event.html'
,
{
'form'
:
form
})
return
render
(
request
,
'calendarapp/add_event.html'
,
{
'form'
:
form
})
# def calendar(request):
# return render(request, 'calendarapp/calendar.html', {'Courses': Course.objects.all().order_by('course_code'), 'Events': Event.objects.all().order_by('target_date')})
def
events
(
request
,
id
):
def
events
(
request
,
id
):
return
render
(
request
,
'calendarapp/events.html'
,
{
'event'
:
Event
.
objects
.
get
(
id
=
id
)})
return
render
(
request
,
'calendarapp/events.html'
,
{
'event'
:
Event
.
objects
.
get
(
id
=
id
)})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment