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
2b05602d
Commit
2b05602d
authored
May 15, 2023
by
Neal Luigi D. Rodriguez
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'widgetcalendarv2'
parents
351a03b7
d5e56536
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
102 additions
and
11 deletions
+102
-11
models.py
widget_gitgud/widgetcalendar/models.py
+4
-2
calendar.html
...gud/widgetcalendar/templates/widgetcalendar/calendar.html
+23
-0
event-add.html
...ud/widgetcalendar/templates/widgetcalendar/event-add.html
+11
-0
event-details.html
...idgetcalendar/templates/widgetcalendar/event-details.html
+19
-0
event-edit.html
...d/widgetcalendar/templates/widgetcalendar/event-edit.html
+11
-0
urls.py
widget_gitgud/widgetcalendar/urls.py
+5
-2
views.py
widget_gitgud/widgetcalendar/views.py
+29
-7
No files found.
widget_gitgud/widgetcalendar/models.py
View file @
2b05602d
...
@@ -20,8 +20,8 @@ class Location(models.Model):
...
@@ -20,8 +20,8 @@ class Location(models.Model):
class
Event
(
models
.
Model
):
class
Event
(
models
.
Model
):
target_datetime
=
models
.
DateTimeField
()
activity
=
models
.
TextField
(
max_length
=
1000
,
default
=
''
)
activity
=
models
.
TextField
(
max_length
=
1000
,
default
=
''
)
target_datetime
=
models
.
DateTimeField
()
estimated_hours
=
models
.
FloatField
()
estimated_hours
=
models
.
FloatField
()
location
=
models
.
ForeignKey
(
location
=
models
.
ForeignKey
(
Location
,
Location
,
...
@@ -38,5 +38,7 @@ class Event(models.Model):
...
@@ -38,5 +38,7 @@ class Event(models.Model):
return
'{}'
.
format
(
self
.
activity
)
return
'{}'
.
format
(
self
.
activity
)
def
get_absolute_url
(
self
):
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/templates/widgetcalendar/calendar.html
0 → 100644
View file @
2b05602d
{% extends 'base.html' %}
{% load static %}
{% block title %} Widget's Calendar of Activities {% endblock %}
{% block content %}
<h1>
Widget's Calendar of Activities
</h1>
<ul>
{% for object in events %}
<li>
<a
href=
"{{ object.get_absolute_url }}"
>
{{ object.activity }}
</a>
</li>
{% endfor %}
</ul>
<button
onclick=
"window.location.href='../../Calendar/events/add/';"
>
New Activity
</button>
<p>
<a
href=
"/Dashboard"
>
Dashboard
</a><br>
<a
href=
"/Announcement"
>
Announcements
</a><br>
<a
href=
"/Forum"
>
Forum
</a><br>
<a
href=
"/Assignments"
>
Assignments
</a>
</p>
{% endblock %}
\ No newline at end of file
widget_gitgud/widgetcalendar/templates/widgetcalendar/event-add.html
0 → 100644
View file @
2b05602d
{% extends 'base.html' %}
{% load static %}
{% block title %} Add Activity {% endblock %}
{% block content %}
<h1>
Add a New Activity
</h1>
<form
action=
""
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save New Activity"
>
</form>
{% endblock %}
widget_gitgud/widgetcalendar/templates/widgetcalendar/event-details.html
0 → 100644
View file @
2b05602d
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.activity }}{% endblock %}
{% block content %}
<h1>
{{ object.activity }}
</h1>
<h2>
Date and Time: {{ object.target_datetime|date:"m/d/Y, "}}{{ object.target_datetime|time:"h:i A" }}
</h2>
<h2>
Estimated Hours: {{ object.estimated_hours }}
</h2>
<h2>
{{ object.course.code }} {{ object.course.title }} - {{ object.course.section }}
</h2>
<ul>
<li>
Mode: {{ object.location.mode }}
</li>
<li>
Venue: {{ object.location.venue }}
</li>
</ul>
<button
onclick=
"document.location='{{object.get_edit_url}}'"
>
Edit Activity
</button>
{% comment %}
<button
onclick=
"document.location='{{object.get_edit_url}}'"
>
Edit Activity
</button>
{% endcomment %}
{% endblock %}
widget_gitgud/widgetcalendar/templates/widgetcalendar/event-edit.html
0 → 100644
View file @
2b05602d
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Activity {% endblock %}
{% block content %}
<h1>
Edit Assignment
</h1>
<form
action=
""
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save Changes to Activity"
>
</form>
{% endblock %}
widget_gitgud/widgetcalendar/urls.py
View file @
2b05602d
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
index
from
.views
import
index
,
EventDetailView
,
EditEventView
,
AddEventView
urlpatterns
=
[
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"
),
path
(
'events/<int:pk>/edit/'
,
EditEventView
.
as_view
(),
name
=
"event-edit"
),
]
]
app_name
=
"widgetcalendar"
app_name
=
"widgetcalendar"
\ No newline at end of file
widget_gitgud/widgetcalendar/views.py
View file @
2b05602d
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
.models
import
Event
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
#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
):
def
index
(
request
):
return_string
=
''
events
=
Event
.
objects
.
all
()
for
events
in
Event
.
objects
.
all
():
context
=
{
'events'
:
events
}
return_string
+=
'Date and Time: {}<br>Activity: {}<br>Estimated Hours: {}<br>Course/Section: {} {}-{}<br>Mode: {}<br>Venue: {}<br></br>'
.
format
(
return
render
(
request
,
'widgetcalendar/calendar.html'
,
context
)
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
)
class
EventDetailView
(
DetailView
):
html_string
=
'<html><head>Widget
\'
s Calendar of Activities<br></br></head><body>{}</body><html>'
.
format
(
return_string
)
model
=
Event
return
HttpResponse
(
html_string
)
template_name
=
'widgetcalendar/event-details.html'
\ No newline at end of file
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