Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_gitgud
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
Neal Luigi D. Rodriguez
midterm_gitgud
Commits
f44227cf
Commit
f44227cf
authored
May 13, 2023
by
Christian Louis Olivares
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified models, urls, and views to prepare for html pages
parent
15477754
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
12 deletions
+38
-12
settings.py
widget_gitgud/widget_gitgud/settings.py
+1
-1
models.py
widget_gitgud/widgetcalendar/models.py
+4
-2
urls.py
widget_gitgud/widgetcalendar/urls.py
+4
-2
views.py
widget_gitgud/widgetcalendar/views.py
+29
-7
No files found.
widget_gitgud/widget_gitgud/settings.py
View file @
f44227cf
...
...
@@ -62,7 +62,7 @@ ROOT_URLCONF = 'widget_gitgud.urls'
TEMPLATES
=
[
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
[
],
'DIRS'
:
[
os
.
path
.
join
(
BASE_DIR
,
'templates'
)
],
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'context_processors'
:
[
...
...
widget_gitgud/widgetcalendar/models.py
View file @
f44227cf
...
...
@@ -20,8 +20,8 @@ class Location(models.Model):
class
Event
(
models
.
Model
):
target_datetime
=
models
.
DateTimeField
()
activity
=
models
.
TextField
(
max_length
=
1000
,
default
=
''
)
target_datetime
=
models
.
DateTimeField
()
estimated_hours
=
models
.
FloatField
()
location
=
models
.
ForeignKey
(
Location
,
...
...
@@ -38,5 +38,7 @@ class Event(models.Model):
return
'{}'
.
format
(
self
.
activity
)
def
get_absolute_url
(
self
):
return
reverse
(
'
event_detail'
,
args
=
[
str
(
self
.
activity
)]
)
return
reverse
(
'
widgetcalendar:event-detail'
,
kwargs
=
{
'pk'
:
self
.
pk
}
)
def
get_edit_url
(
self
):
return
reverse
(
'widgetcalendar:event-edit'
,
kwargs
=
{
'pk'
:
self
.
pk
}
)
\ No newline at end of file
widget_gitgud/widgetcalendar/urls.py
View file @
f44227cf
from
django.urls
import
path
from
.views
import
index
from
.views
import
index
,
EventDetailView
,
EditEventView
,
AddEventView
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
''
,
index
,
name
=
'Calendar'
),
path
(
'events/<int:pk>/details/'
,
EventDetailView
.
as_view
(),
name
=
"event-detail"
),
path
(
'events/add/'
,
AddEventView
.
as_view
(),
name
=
"event-add"
),
]
app_name
=
"widgetcalendar"
\ No newline at end of file
widget_gitgud/widgetcalendar/views.py
View file @
f44227cf
from
django.http
import
HttpResponse
from
.models
import
Event
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
django.shortcuts
import
render
#Date format source: https://ourcodeworld.com/articles/read/555/how-to-format-datetime-objects-in-the-view-and-template-in-django
# def index(request):
# return_string = ''
# for events in Event.objects.all():
# return_string += 'Date and Time: {}<br>Activity: {}<br>Estimated Hours: {}<br>Course/Section: {} {}-{}<br>Mode: {}<br>Venue: {}<br></br>'.format(
# events.target_datetime.strftime("%x, %I:%M %p"), events.activity, events.estimated_hours, events.course.code, events.course.title, events.course.section, events.location.mode, events.location.venue
# )
# html_string = '<html><head>Widget\'s Calendar of Activities<br></br></head><body>{}</body><html>'.format(return_string)
# return HttpResponse(html_string)
def
index
(
request
):
return_string
=
''
for
events
in
Event
.
objects
.
all
():
return_string
+=
'Date and Time: {}<br>Activity: {}<br>Estimated Hours: {}<br>Course/Section: {} {}-{}<br>Mode: {}<br>Venue: {}<br></br>'
.
format
(
events
.
target_datetime
.
strftime
(
"
%
x,
%
I:
%
M
%
p"
),
events
.
activity
,
events
.
estimated_hours
,
events
.
course
.
code
,
events
.
course
.
title
,
events
.
course
.
section
,
events
.
location
.
mode
,
events
.
location
.
venue
)
html_string
=
'<html><head>Widget
\'
s Calendar of Activities<br></br></head><body>{}</body><html>'
.
format
(
return_string
)
return
HttpResponse
(
html_string
)
\ No newline at end of file
events
=
Event
.
objects
.
all
()
context
=
{
'events'
:
events
}
return
render
(
request
,
'widgetcalendar/calendar.html'
,
context
)
class
EventDetailView
(
DetailView
):
model
=
Event
template_name
=
'widgetcalendar/event-details.html'
class
EditEventView
(
UpdateView
):
model
=
Event
fields
=
'__all__'
template_name
=
'widgetcalendar/event-edit.html'
class
AddEventView
(
CreateView
):
model
=
Event
fields
=
'__all__'
template_name
=
'widgetcalendar/event-add.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