Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_princessgabi
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
Ysabella Panghulan
midterm_princessgabi
Commits
b6424f86
Commit
b6424f86
authored
May 12, 2023
by
Ysabella Panghulan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'calendarv2'
parents
e521c58b
c7916771
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
148 additions
and
15 deletions
+148
-15
forms.py
widget_princessgabi/widget_calendar/forms.py
+14
-0
models.py
widget_princessgabi/widget_calendar/models.py
+5
-1
calendar.html
...i/widget_calendar/templates/widget_calendar/calendar.html
+26
-0
event-add.html
.../widget_calendar/templates/widget_calendar/event-add.html
+20
-0
event-details.html
...get_calendar/templates/widget_calendar/event-details.html
+22
-0
event-edit.html
...widget_calendar/templates/widget_calendar/event-edit.html
+20
-0
urls.py
widget_princessgabi/widget_calendar/urls.py
+5
-1
views.py
widget_princessgabi/widget_calendar/views.py
+36
-13
No files found.
widget_princessgabi/widget_calendar/forms.py
0 → 100644
View file @
b6424f86
from
django
import
forms
from
django.forms
import
ModelForm
from
.models
import
Location
,
Event
class
LocationForm
(
ModelForm
):
class
Meta
:
model
=
Location
fields
=
'__all__'
class
EventForm
(
ModelForm
):
class
Meta
:
model
=
Event
fields
=
'__all__'
widget_princessgabi/widget_calendar/models.py
View file @
b6424f86
from
django.db
import
models
from
django.db
import
models
from
assignments.models
import
Course
from
assignments.models
import
Course
from
django.urls
import
reverse
# Create your models here.
# Create your models here.
class
Location
(
models
.
Model
):
class
Location
(
models
.
Model
):
...
@@ -24,3 +25,6 @@ class Event(models.Model):
...
@@ -24,3 +25,6 @@ class Event(models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
activity
return
self
.
activity
def
get_absolute_url
(
self
):
return
reverse
(
'event-details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
\ No newline at end of file
widget_princessgabi/widget_calendar/templates/widget_calendar/calendar.html
0 → 100644
View file @
b6424f86
{%extends 'base.html'%}
{% block title %} Widget's Calendar of Activties {% endblock %}
{% block header %}
<h2>
Widget's Calendar of Activties
</h2>
{% endblock %}
{% block body %}
{% block content %}
<ul>
{% for event in events %}
<a
href=
"{{ event.get_absolute_url }}"
>
<li>
{{ event }}
</li>
</a>
{% endfor %}
</ul>
{% endblock %}
<div
class=
"calendar-links"
>
<a
href=
"events/add"
class=
"btn-primary"
>
New Activity
</a>
<a
href=
"../dashboard"
class=
"btn-primary"
>
Dashboard
</a>
<a
href=
"../announcements"
class=
"btn-primary"
>
Announcements
</a>
<a
href=
"../forum"
class=
"btn-primary"
>
Forum
</a>
<a
href=
"../assignments"
class=
"btn-primary"
>
Assignments
</a>
</div>
{% endblock %}
\ No newline at end of file
widget_princessgabi/widget_calendar/templates/widget_calendar/event-add.html
0 → 100644
View file @
b6424f86
{%extends 'base.html'%}
{% block title %}Add Activity{% endblock %}
{% block header %}
<h2>
Add a new activity:
</h2>
{% endblock %}
{% block body %}
{% block content %}
<div
class=
"form"
>
<form
method=
"POST"
action=
""
>
{% csrf_token %}
{{form}}
<input
type=
"Submit"
value=
"Save New Activity"
>
</form>
</div>
{% endblock %}
{% endblock %}
\ No newline at end of file
widget_princessgabi/widget_calendar/templates/widget_calendar/event-details.html
0 → 100644
View file @
b6424f86
{%extends 'base.html'%}
{% block title %}{{ object }}{% endblock %}
{% block header %}
<h2>
{{ object }}
</h2>
{% endblock %}
{% block body %}
<div
class=
"event-content"
>
{% block content %}
<h4>
Date and Time: {{ object.target_datetime|date:'m/d/Y' }} {{ object.target_datetime|date:'h:i A' }}
</h4>
<h4>
Estimated Hours: {{ object.estimated_hours }}
</h4>
<h4>
{{ object.course.code }} {{ object.course.title }} - {{ object.course.section }}
</h4>
<h4>
Mode: {{ object.location.mode }}
</h4>
<h4>
Venue: {{ object.location.venue }}
</h4>
{% endblock %}
</div>
<div
class=
"links"
>
<a
href=
"{{object.get_absolute_url}}../edit"
class=
"btn-primary"
>
Edit Activity
</a>
</div>
{% endblock %}
\ No newline at end of file
widget_princessgabi/widget_calendar/templates/widget_calendar/event-edit.html
0 → 100644
View file @
b6424f86
{%extends 'base.html'%}
{% block title %} Edit Activity {% endblock %}
{% block header %}
<h2>
Edit Activity:
</h2>
{% endblock %}
{% block body %}
{% block content %}
<div
class=
"form"
>
<form
method=
"POST"
action=
""
>
{% csrf_token %}
{{form}}
<input
type=
"Submit"
value=
"Save New Activity"
>
</form>
</div>
{% endblock %}
{% endblock %}
\ No newline at end of file
widget_princessgabi/widget_calendar/urls.py
View file @
b6424f86
from
django.urls
import
path
from
django.urls
import
path
from
.
import
views
from
.
import
views
from
.views
import
(
EventDetailView
,
EventCreateView
,
EventUpdateView
)
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
views
.
index
,
name
=
'calendar'
),
path
(
''
,
views
.
Calendar
,
name
=
''
),
path
(
'events/<int:pk>/details/'
,
EventDetailView
.
as_view
(),
name
=
'event-details'
),
path
(
'events/add'
,
EventCreateView
.
as_view
(),
name
=
'event-add'
),
path
(
'events/<int:pk>/edit'
,
EventUpdateView
.
as_view
(),
name
=
'event-edit'
),
]
]
\ No newline at end of file
widget_princessgabi/widget_calendar/views.py
View file @
b6424f86
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
.models
import
Location
,
Event
from
.models
import
Location
,
Event
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.forms
import
LocationForm
,
EventForm
# Create your views here.
# Create your views here.
def
index
(
request
):
def
Calendar
(
request
):
locations
=
Location
.
objects
.
all
()
events
=
Event
.
objects
.
all
()
events
=
Event
.
objects
.
all
()
welcomeMessage
=
'Widget
\'
s Calendar of Activities <br><br>'
context
=
{
activities
=
''
'locations'
:
locations
,
'events'
:
events
,
}
return
render
(
request
,
'widget_calendar/calendar.html'
,
context
)
for
event
in
events
:
class
EventDetailView
(
DetailView
):
activities
+=
'Date and Time: '
+
event
.
target_datetime
.
strftime
(
'
%
m/
%
d/
%
Y,
%
I:
%
M
%
p'
)
+
'<br>'
model
=
Event
activities
+=
'Activity: '
+
event
.
activity
+
'<br>'
template_name
=
'widget_calendar/event-details.html'
activities
+=
'Estimated Hours: '
+
str
(
event
.
estimated_hours
)
+
'<br>'
activities
+=
'Course/Section: '
+
event
.
course
.
code
+
' '
+
event
.
course
.
title
+
'-'
+
event
.
course
.
section
+
'<br>'
activities
+=
'Mode: '
+
event
.
location
.
mode
+
'<br>'
activities
+=
'Venue: '
+
event
.
location
.
venue
+
'<br><br>'
return
HttpResponse
(
welcomeMessage
+
activities
)
class
EventCreateView
(
CreateView
):
\ No newline at end of file
model
=
Event
template_name
=
'widget_calendar/event-add.html'
fields
=
'__all__'
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
form
=
EventForm
(
request
.
POST
)
if
form
.
is_valid
():
event
=
form
.
save
()
return
redirect
(
'event-details'
,
pk
=
event
.
pk
)
else
:
form
=
EventForm
()
context
=
{
'form'
:
form
}
return
render
(
request
,
'widget_calendar/event-add.html'
,
context
)
class
EventUpdateView
(
UpdateView
):
model
=
Event
fields
=
'__all__'
template_name
=
'widget_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