Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
midterm_OhMyBash
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
Nheo Samson
midterm_OhMyBash
Commits
d14ca48c
Commit
d14ca48c
authored
May 14, 2023
by
nheoxoz
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'origin/calendarv2'
parents
f08eca11
2e38a414
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
118 additions
and
24 deletions
+118
-24
urls.py
widget_OhMyBash/widget_OhMyBash/urls.py
+1
-1
models.py
widget_OhMyBash/widget_calendar/models.py
+6
-1
calendar.html
...h/widget_calendar/templates/widget_calendar/calendar.html
+28
-0
event-add.html
.../widget_calendar/templates/widget_calendar/event-add.html
+15
-0
event-details.html
...get_calendar/templates/widget_calendar/event-details.html
+28
-0
event-edit.html
...widget_calendar/templates/widget_calendar/event-edit.html
+15
-0
urls.py
widget_OhMyBash/widget_calendar/urls.py
+6
-2
views.py
widget_OhMyBash/widget_calendar/views.py
+19
-20
No files found.
widget_OhMyBash/widget_OhMyBash/urls.py
View file @
d14ca48c
...
...
@@ -20,7 +20,7 @@ urlpatterns = [
path
(
''
,
include
(
'dashboard.urls'
,
namespace
=
"dashboard"
)),
path
(
'forum/'
,
include
(
'forum.urls'
,
namespace
=
"forum"
)),
path
(
'announcements/'
,
include
(
'announcements.urls'
,
namespace
=
"announcements"
)),
path
(
'
widget_
calendar/'
,
include
(
'widget_calendar.urls'
,
namespace
=
"calendar"
)),
path
(
'calendar/'
,
include
(
'widget_calendar.urls'
,
namespace
=
"calendar"
)),
path
(
'assignments/'
,
include
(
'assignments.urls'
,
namespace
=
"assignments"
)),
path
(
'admin/'
,
admin
.
site
.
urls
),
]
widget_OhMyBash/widget_calendar/models.py
View file @
d14ca48c
from
django.db
import
models
from
django.urls
import
reverse
class
Location
(
models
.
Model
):
onsite
=
'onsite'
...
...
@@ -17,6 +17,8 @@ class Location(models.Model):
def
__str__
(
self
):
return
'{}, {}'
.
format
(
self
.
mode
,
self
.
venue
)
class
Event
(
models
.
Model
):
...
...
@@ -32,3 +34,6 @@ class Event(models.Model):
def
__str__
(
self
):
return
'{}, {}'
.
format
(
self
.
activity
,
self
.
target_datetime
)
def
get_absolute_url
(
self
):
return
reverse
(
'widget_calendar:event-details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
\ No newline at end of file
widget_OhMyBash/widget_calendar/templates/widget_calendar/calendar.html
0 → 100644
View file @
d14ca48c
<!-- calendar -->
{% extends 'base.html' %}
{% load static %}
{% block title %}Calendar v2{% endblock %}
{% block heading %}Widget's Calendar of Activities{% endblock %}
{% block content %}
<p>
{% for event in activities %}
<a
href=
"{{ event.get_absolute_url }}"
>
{{ event.activity }}
</a><br>
{% endfor %}
</p>
{% endblock %}
{% block footing %}
<a
href=
"{% url 'widget_calendar:event-add' %}"
>
<button
class=
"btn add"
>
New Activity
</button><br>
</a>
<a
href=
"/dashboard/"
>
Dashboard
</a><br>
<a
href=
"/announcements/"
>
Announcements
</a><br>
<a
href=
"/forum/"
>
Forum
</a><br>
<a
href=
"/assignments/"
>
Assignments
</a>
{% endblock %}
widget_OhMyBash/widget_calendar/templates/widget_calendar/event-add.html
0 → 100644
View file @
d14ca48c
<!-- event-add -->
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Widget User{% endblock %}
{% block heading %}
<h1>
Add a new activity:
</h1>
{% endblock %}
{% block content %}
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save New Activity"
>
</form>
{% endblock %}
widget_OhMyBash/widget_calendar/templates/widget_calendar/event-details.html
0 → 100644
View file @
d14ca48c
<!-- event-details -->
{% extends 'base.html' %}
{% load static %}
{% block title %}{{ object.activity }}{% endblock %}
{% block heading %}
<h1>
{{ object.activity }}
</h1>
{% endblock %}
{% block content %}
<p>
Date and Time: {{ object.target_datetime|date:"m/d/Y" }}, {{ object.target_datetime|time:"g:iA" }}
<br>
Estimated Hours: {{ object.estimated_hours }}
<br>
{{ object.course.code}} {{ object.course.title}}-{{ object.course.section}}
<br>
Mode: {{ object.location.mode }}
<br>
Venue: {{ object.location.venue }}
<br>
</p>
{% endblock %}
{% block footing %}
<a
href=
"{% url 'widget_calendar:event-edit' object.pk %}"
>
<button
class=
"btn edit"
>
Edit Activity
</button>
</a>
{% endblock %}
widget_OhMyBash/widget_calendar/templates/widget_calendar/event-edit.html
0 → 100644
View file @
d14ca48c
<!-- event-edit -->
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Activity{% endblock %}
{% block heading %}Edit Activity:{% endblock %}
{% block content %}
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save New Activity"
>
</form>
{% endblock %}
widget_OhMyBash/widget_calendar/urls.py
View file @
d14ca48c
from
django.urls
import
path
from
.views
import
index
from
.views
import
(
calendar
,
EventDetailView
,
EventCreateView
,
EventUpdateView
)
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
''
,
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'
),
]
# This might be needed, depending on your Django version
app_name
=
"widget_calendar"
\ No newline at end of file
widget_OhMyBash/widget_calendar/views.py
View file @
d14ca48c
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
,
redirect
from
django.views
import
View
from
.models
import
Event
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
,
UpdateView
def
index
(
request
):
return_string
=
"<p>Widget's Calendar of Activities</p>"
def
calendar
(
request
):
activities
=
Event
.
objects
.
all
()
return
render
(
request
,
'widget_calendar/calendar.html'
,
{
'activities'
:
activities
})
for
events
in
Event
.
objects
.
all
():
round_hours
=
(
"{:0.0f}"
.
format
(
events
.
estimated_hours
))
return_string
+=
'Date and Time: {}<br>'
.
format
(
events
.
target_datetime
.
strftime
(
'
%
m/
%
d/
%
Y,
%
H:
%
M
%
p'
)
)
return_string
+=
'Activity: {}<br>'
.
format
(
events
.
activity
)
return_string
+=
'Estimated Hours: {}<br>'
.
format
(
round_hours
)
return_string
+=
'Course/Section: {} {}-{}<br>'
.
format
(
events
.
course
.
code
,
events
.
course
.
title
,
events
.
course
.
section
,
)
return_string
+=
'Mode: {}<br>'
.
format
(
events
.
location
.
mode
)
return_string
+=
'Venue: {}<br>'
.
format
(
events
.
location
.
venue
)
return_string
+=
'<br>'
class
EventDetailView
(
DetailView
):
model
=
Event
template_name
=
"widget_calendar/event-details.html"
html_string
=
'<html><body>{}</body></html>'
.
format
(
return_string
)
class
EventCreateView
(
CreateView
):
model
=
Event
fields
=
'__all__'
template_name
=
"widget_calendar/event-add.html"
return
HttpResponse
(
html_string
)
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