Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_casanatics
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
John Aidan Vincent M. Ng
midterm_casanatics
Commits
41e3f559
Commit
41e3f559
authored
May 13, 2023
by
justin
Browse files
Options
Browse Files
Download
Plain Diff
merged assignmentsv2
parents
96508d52
4b70feec
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
97 additions
and
19 deletions
+97
-19
models.py
widget_casanatics/assignments/models.py
+4
-1
assignment-add.html
...ics/assignments/templates/assignments/assignment-add.html
+13
-0
assignment-details.html
...assignments/templates/assignments/assignment-details.html
+16
-0
assignment-edit.html
...cs/assignments/templates/assignments/assignment-edit.html
+13
-0
assignments.html
...natics/assignments/templates/assignments/assignments.html
+27
-0
urls.py
widget_casanatics/assignments/urls.py
+6
-0
views.py
widget_casanatics/assignments/views.py
+18
-17
settings.py
widget_casanatics/widget_casanatics/settings.py
+0
-1
No files found.
widget_casanatics/assignments/models.py
View file @
41e3f559
from
django.db
import
models
from
django.urls
import
reverse
class
Course
(
models
.
Model
):
code
=
models
.
CharField
(
max_length
=
10
)
...
...
@@ -23,3 +23,6 @@ class Assignment(models.Model):
def
__str__
(
self
):
return
self
.
name
def
get_absolute_url
(
self
):
return
reverse
(
'assignments:assignment-details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
widget_casanatics/assignments/templates/assignments/assignment-add.html
0 → 100644
View file @
41e3f559
{% extends 'base.html' %}
{% load static %}
{% block title %} Add Assignment {% endblock %}
{% block content %}
<h1>
Add a new Assignment:
</h1>
<form
method=
"POST"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"Submit"
value=
"Save New Assignment"
>
</form>
{% endblock %}
widget_casanatics/assignments/templates/assignments/assignment-details.html
0 → 100644
View file @
41e3f559
{% extends 'base.html' %}
{% load static %}
{% block title %} {{object.name}} {% endblock %}
{% block content %}
<h1>
{{object.name}}
</h1>
<h2>
{{object.course.code}} {{object.course.title}} - {{ object.course.section }}
<br>
Description: {{object.description}}
<br>
Perfect Score: {{object.perfect_score}}
<br>
Passing Score: {{object.passing_score}}
<br>
</h2>
<a
href=
"/assignments/{{object.id}}/edit"
><button>
Edit Assignment
</button></a>
{% endblock %}
\ No newline at end of file
widget_casanatics/assignments/templates/assignments/assignment-edit.html
0 → 100644
View file @
41e3f559
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Assignment {% endblock %}
{% block content %}
<h1>
Edit Assignment:
</h1>
<form
method=
"POST"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"Submit"
value=
"Save Changes to Assignment"
>
</form>
{% endblock %}
widget_casanatics/assignments/templates/assignments/assignments.html
0 → 100644
View file @
41e3f559
{% extends 'base.html' %}
{% load static %}
{% block title %} Widget's Assignments{% endblock %}
{% block content%}
<h1>
Welcome to Widget's Assignments
</h1>
<ul>
{% for assignment in assignments %}
<li>
<a
href =
"{{ assignment.get_absolute_url }}"
>
{{assignment}}
</a>
</li>
{% endfor %}
</ul>
<form
action=
"./add"
>
<button
type=
"Submit"
>
New Assignment
</button>
</form>
<br>
<a
href =
"../dashboard/"
>
Dashboard
</a><br>
<a
href =
"../forum/"
>
Forum
</a><br>
<a
href =
"../assignments/"
>
Assignments
</a><br>
<a
href =
"../calendar/"
>
Calendar
</a><br>
{% endblock %}
widget_casanatics/assignments/urls.py
View file @
41e3f559
from
django.urls
import
path
from
.
import
views
from
.views
import
*
urlpatterns
=
[
path
(
""
,
views
.
assignments
,
name
=
"assignments"
),
path
(
'<int:pk>/details/'
,
AssignmentDetailView
.
as_view
(),
name
=
'assignment-details'
),
path
(
'add/'
,
AssignmentCreateView
.
as_view
(),
name
=
'assignment-add'
),
path
(
'<int:pk>/edit/'
,
AssignmentUpdateView
.
as_view
(),
name
=
'assignment-edit'
),
]
app_name
=
"assignments"
widget_casanatics/assignments/views.py
View file @
41e3f559
from
django.http
import
HttpResponse
from
.models
import
Assignment
,
Course
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
django.shortcuts
import
render
from
django.template
import
loader
def
assignments
(
request
):
assignments
=
Assignment
.
objects
.
all
()
context
=
{
'assignments'
:
assignments
,}
re
sponse
=
"Widget's Assignments Page <br><br>"
re
turn
render
(
request
,
'assignments/assignments.html'
,
context
)
for
assignment
in
assignments
:
name
=
"Asssignment Name: "
+
assignment
.
name
+
"<br>"
desc
=
"Description: "
+
assignment
.
description
+
"<br>"
perfect
=
"Perfect Score: "
+
str
(
assignment
.
perfect_score
)
+
"<br>"
passing
=
"Passing Score: "
+
str
(
assignment
.
passing_score
)
+
"<br>"
courseSection
=
(
"Course/Section: "
+
assignment
.
course
.
code
+
" "
+
assignment
.
course
.
title
+
"-"
+
assignment
.
course
.
section
)
class
AssignmentDetailView
(
DetailView
):
model
=
Assignment
template_name
=
'assignments/assignment-details.html'
response
+=
name
+
desc
+
perfect
+
passing
+
courseSection
+
"<br><br>"
class
AssignmentCreateView
(
CreateView
):
model
=
Assignment
fields
=
'__all__'
template_name
=
'assignments/assignment-add.html'
return
HttpResponse
(
response
)
class
AssignmentUpdateView
(
UpdateView
):
model
=
Assignment
fields
=
'__all__'
template_name
=
'assignments/assignment-edit.html'
widget_casanatics/widget_casanatics/settings.py
View file @
41e3f559
...
...
@@ -9,7 +9,6 @@ https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
import
os
from
pathlib
import
Path
...
...
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