Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_bigdjangoenergy
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
Alec Dayupay
midterm_bigdjangoenergy
Commits
db44e158
Commit
db44e158
authored
May 05, 2023
by
Kirsten Daena Chidrome
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged calendarsv2
parent
1b22d175
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
96 additions
and
16 deletions
+96
-16
forms.py
widget_bigdjangoenergy/calendars/forms.py
+7
-0
models.py
widget_bigdjangoenergy/calendars/models.py
+5
-1
calendar.html
...gdjangoenergy/calendars/templates/calendars/calendar.html
+20
-0
event-add.html
...djangoenergy/calendars/templates/calendars/event-add.html
+13
-0
event-details.html
...goenergy/calendars/templates/calendars/event-details.html
+16
-0
event-edit.html
...jangoenergy/calendars/templates/calendars/event-edit.html
+13
-0
urls.py
widget_bigdjangoenergy/calendars/urls.py
+5
-1
views.py
widget_bigdjangoenergy/calendars/views.py
+17
-14
No files found.
widget_bigdjangoenergy/calendars/forms.py
0 → 100644
View file @
db44e158
from
django.forms
import
ModelForm
from
.models
import
Event
class
EventForm
(
ModelForm
):
class
Meta
:
model
=
Event
fields
=
"__all__"
\ No newline at end of file
widget_bigdjangoenergy/calendars/models.py
View file @
db44e158
from
django.db
import
models
from
django.db
import
models
from
django.urls
import
reverse
class
Location
(
models
.
Model
):
class
Location
(
models
.
Model
):
Onsite
=
'Onsite'
Onsite
=
'Onsite'
...
@@ -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_bigdjangoenergy/calendars/templates/calendars/calendar.html
0 → 100644
View file @
db44e158
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Calendar of Activities{% endblock %}
{% block heading %}Widget's Calendar of Activities{% endblock %}
{% block content %}
{% for event in event %}
<p><a
href=
"{% url 'event-details' event.pk %}"
>
{{ event.activity }}
</a></p>
{% endfor %}
<input
type=
"button"
value=
"New Activity"
onclick=
"location.href='{% url 'event-add' %}'"
/>
{% endblock %}
{% block links %}
<p><a
href=
"http://localhost:8000/dashboard/"
>
Dashboard
</a></p>
<p><a
href=
"http://localhost:8000/announcements/"
>
Announcement
</a></p>
<p><a
href=
"http://localhost:8000/assignments/"
>
Assignment
</a></p>
<p><a
href=
"http://localhost:8000/calendar/"
>
Calendar
</a></p>
{% endblock %}
widget_bigdjangoenergy/calendars/templates/calendars/event-add.html
0 → 100644
View file @
db44e158
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Activity{% endblock %}
{% block content %}
<p>
Add a new activity:
</p>
<form
method=
"POST"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"Submit"
value=
"Save New Activity"
>
</form>
{% endblock %}
widget_bigdjangoenergy/calendars/templates/calendars/event-details.html
0 → 100644
View file @
db44e158
{% extends 'base.html' %}
{% load static %}
{% block title %}{{ object.activity }}{% endblock %}
{% block heading %}{{ object.activty }}{% endblock %}
{% block content %}
<p>
Date and Time: {{ object.target_datetime }}
</p>
<p>
Estimated Hours: {{ object.estimated_hours }}
</p>
<p>
{{ object.course }}
</p>
<p>
Mode: {{ object.locations.modes }}
</p>
<p>
Venue: {{ object.locations.venue }}
</p>
<input
type=
"button"
value=
"Edit Post"
onclick=
"location.href='{% url 'event-edit' object.pk %}'"
/>
{% endblock %}
widget_bigdjangoenergy/calendars/templates/calendars/event-edit.html
0 → 100644
View file @
db44e158
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Activity{% endblock %}
{% block content %}
<p>
Edit Activity:
</p>
<form
method=
"POST"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"Submit"
value=
"Save New Activity"
>
</form>
{% endblock %}
widget_bigdjangoenergy/calendars/urls.py
View file @
db44e158
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
=
"index"
)
path
(
''
,
views
.
calendar
,
name
=
"calendar"
),
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_bigdjangoenergy/calendars/views.py
View file @
db44e158
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
Event
from
.models
import
Event
def
index
(
request
):
def
calendar
(
request
):
events
=
Event
.
objects
.
all
(
)
return
render
(
request
,
'calendars/calendar.html'
,
{
'event'
:
Event
.
objects
.
all
()}
)
response
=
"Widgets's Calendar of Activities<br><br>Date and Time: "
class
EventDetailView
(
DetailView
):
for
event
in
events
:
model
=
Event
response
+=
"{}<br>Activity: {}<br>Estimated Hours: {}<br>Course/Section: {}<br>Mode: {}<br>Venue: {}<br>"
.
format
(
template_name
=
'calendars/event-details.html'
event
.
target_datetime
.
strftime
(
"
%
m/
%
d/
%
Y,
%
I:
%
M
%
p"
),
event
.
activity
,
str
(
event
.
estimated_hours
),
event
.
course
,
event
.
locations
.
modes
,
event
.
locations
.
venue
)
return
HttpResponse
(
response
)
class
EventCreateView
(
CreateView
):
\ No newline at end of file
model
=
Event
fields
=
'__all__'
template_name
=
'calendars/event-add.html'
class
EventUpdateView
(
UpdateView
):
model
=
Event
fields
=
'__all__'
template_name
=
'calendars/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