Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_vincentdjango
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
1
Merge Requests
1
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
Almira Redoble
midterm_vincentdjango
Commits
ff746f11
Commit
ff746f11
authored
May 11, 2023
by
Andrew Justin C. Idquival
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created calendar.html in templates
parent
77a89ab8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
34 deletions
+39
-34
models.py
widget_vincentdjango/widget_calendar/models.py
+6
-2
widget_calendar.html
...t_calendar/templates/widget_calendar/widget_calendar.html
+27
-0
urls.py
widget_vincentdjango/widget_calendar/urls.py
+2
-0
views.py
widget_vincentdjango/widget_calendar/views.py
+4
-32
No files found.
widget_vincentdjango/widget_calendar/models.py
View file @
ff746f11
from
django.db
import
models
from
django.urls
import
reverse
from
datetime
import
datetime
from
assignments.models
import
Course
...
...
@@ -12,6 +12,7 @@ class Location(models.Model):
return
'{} {}'
.
format
(
self
.
mode
,
self
.
venue
)
class
Event
(
models
.
Model
):
target_datetime
=
models
.
DateTimeField
(
default
=
datetime
.
now
())
activity
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
...
...
@@ -23,8 +24,11 @@ class Event(models.Model):
location
=
models
.
ForeignKey
(
Location
,
on_delete
=
models
.
CASCADE
,
related_name
=
'
Venue
'
related_name
=
'
venues
'
)
def
__str__
(
self
):
return
"{} {} {} {}"
.
format
(
self
.
target_datetime
,
self
.
activity
,
self
.
estimated_hours
,
self
.
location
)
def
get_absolute_url
(
self
):
return
reverse
(
'calendar:calender-details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
widget_vincentdjango/widget_calendar/templates/widget_calendar/widget_calendar.html
0 → 100644
View file @
ff746f11
+{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Calendar of Activities{% endblock %}
{% block heading %}Widget's Calendar of Activities{% endblock %}
{% block content %}
<ul>
{% for event in events %}
<li>
<a
href=
"#"
>
{{ event }}
</a>
</li>
{% endfor %}
</ul>
<button
onclick=
"window.location.href='#';"
>
New Activity
</button>
<div
id=
"footer"
>
<a
href=
"{% url 'dashboard:index' %}"
>
Dashboard
</a>
<a
href=
"{% url 'announcementBoard:index' %}"
>
Announcement Board
</a>
<a
href=
"{% url 'forum:index' %}"
>
Forum
</a>
<a
href=
"{% url 'assignments:homePage' %}"
>
Assignments
</a>
</div>
{% endblock %}
\ No newline at end of file
widget_vincentdjango/widget_calendar/urls.py
View file @
ff746f11
from
django.urls
import
path
from
.views
import
index
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
'calendar/'
,
index
,
name
=
'index'
)
]
app_name
=
"widget_calendar"
widget_vincentdjango/widget_calendar/views.py
View file @
ff746f11
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.views.generic.detail
import
DetailView
from
.models
import
Event
,
Location
def
index
(
request
):
head
=
"<h1 style='border-bottom:4px solid lightgray;
\
padding-bottom:30px;
\
font-size:500
%
;'>
\
Widget’s Calendar of Activities
\
</h1>"
body
=
""
for
event
in
Event
.
objects
.
all
():
location
=
event
.
location
datetime
=
str
(
event
.
target_datetime
)
estimated_hours
=
str
(
event
.
estimated_hours
)
body
+=
"<p style='border: 2px solid gray;
\
border-radius:5px;
\
padding:20px 30px;'>
\
Date and Time: "
+
datetime
+
" <br>
\
Activity: "
+
event
.
activity
+
" <br>
\
Estimated Hours: "
+
estimated_hours
+
" <br>
\
Course/Section: "
+
event
.
course
.
course_title
+
" <br>
\
Mode: "
+
location
.
mode
+
" <br>
\
Venue: "
+
location
.
venue
+
" <br>
\
</p>"
return_string
=
"<html>
\
<body style = 'font-family:helvetica;
\
padding:30px;'>
\
{}{}
\
</body></html>"
.
format
(
head
,
body
)
return
HttpResponse
(
return_string
)
events
=
Event
.
objects
.
all
()
return
render
(
request
,
'calendar/calendar.html'
,
{
'events'
:
events
,
})
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