Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
midterm_OhMyBash
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
Nheo Samson
midterm_OhMyBash
Commits
32bda5ca
Commit
32bda5ca
authored
May 13, 2023
by
Jose Gabriel L. Salas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated paths in urls.py and created edit, update, and create classes in views.py
parent
d1349b22
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
22 deletions
+25
-22
urls.py
widget_OhMyBash/widget_calendar/urls.py
+6
-2
views.py
widget_OhMyBash/widget_calendar/views.py
+19
-20
No files found.
widget_OhMyBash/widget_calendar/urls.py
View file @
32bda5ca
from
django.urls
import
path
from
.views
import
index
from
.views
import
(
calendar
,
EventDetailView
,
EventCreateView
,
EventUpdateView
)
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
'calendar/'
,
calendar
,
name
=
'calendar'
),
path
(
'calendar/events/<int:pk>/details/'
,
EventDetailView
,
name
=
'event-details'
),
path
(
'calendar/events/add/'
,
EventCreateView
,
name
=
'event-add'
),
path
(
'calendar/events/<int:pk>/edit/'
,
EventUpdateView
,
name
=
'event-edit'
),
]
# This might be needed, depending on your Django version
app_name
=
"widget_calendar"
\ No newline at end of file
widget_OhMyBash/widget_calendar/views.py
View file @
32bda5ca
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
,
redirect
from
django.views
import
View
from
.models
import
Event
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
,
UpdateView
def
index
(
request
):
return_string
=
"<p>Widget's Calendar of Activities</p>"
def
index
(
request
):
activities
=
Event
.
objects
.
all
()
return
render
(
request
,
'calendar/calendar.html'
,
{
'activities'
:
activities
})
for
events
in
Event
.
objects
.
all
():
round_hours
=
(
"{:0.0f}"
.
format
(
events
.
estimated_hours
))
return_string
+=
'Date and Time: {}<br>'
.
format
(
events
.
target_datetime
.
strftime
(
'
%
m/
%
d/
%
Y,
%
H:
%
M
%
p'
)
)
return_string
+=
'Activity: {}<br>'
.
format
(
events
.
activity
)
return_string
+=
'Estimated Hours: {}<br>'
.
format
(
round_hours
)
return_string
+=
'Course/Section: {} {}-{}<br>'
.
format
(
events
.
course
.
code
,
events
.
course
.
title
,
events
.
course
.
section
,
)
return_string
+=
'Mode: {}<br>'
.
format
(
events
.
location
.
mode
)
return_string
+=
'Venue: {}<br>'
.
format
(
events
.
location
.
venue
)
return_string
+=
'<br>'
class
EventDetailView
(
DetailView
):
model
=
Event
template_name
=
"calendar/event-details.html"
html_string
=
'<html><body>{}</body></html>'
.
format
(
return_string
)
class
EventCreateView
(
CreateView
):
model
=
Event
fields
=
'__all__'
template_name
=
"calendar/event-add.html"
return
HttpResponse
(
html_string
)
class
EventUpdateView
(
UpdateView
):
model
=
Event
fields
=
'__all__'
template_name
=
'calendar/event-edit.html'
\ No newline at end of file
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