Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_k3git
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
Stefan Gomez
midterm_k3git
Commits
99e2be94
Commit
99e2be94
authored
May 07, 2023
by
Nate Brevin A. Que
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented the 'Per Assignment Details Page'
parent
eddb0b03
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
5 deletions
+30
-5
.env
widget_k3git/.env
+0
-1
models.py
widget_k3git/assignments/models.py
+4
-0
assignment-details.html
...assignments/templates/assignments/assignment-details.html
+14
-0
assignments.html
..._k3git/assignments/templates/assignments/assignments.html
+1
-1
urls.py
widget_k3git/assignments/urls.py
+2
-1
views.py
widget_k3git/assignments/views.py
+9
-2
No files found.
widget_k3git/.env
deleted
100644 → 0
View file @
eddb0b03
SECRET_KEY = 'django-insecure-0ne3r+4_-4wxim9e1!jkyw8%fnii1af4pc$irxf%nvrs3wp*1f'
\ No newline at end of file
widget_k3git/assignments/models.py
View file @
99e2be94
from
django.db
import
models
from
django.db
import
models
from
django.urls
import
reverse
class
Course
(
models
.
Model
):
class
Course
(
models
.
Model
):
...
@@ -24,6 +25,9 @@ class Assignment(models.Model):
...
@@ -24,6 +25,9 @@ class Assignment(models.Model):
Course/Section: {}<br>"""
.
format
(
self
.
name
,
self
.
description
,
self
.
perfect_score
,
Course/Section: {}<br>"""
.
format
(
self
.
name
,
self
.
description
,
self
.
perfect_score
,
self
.
passing_score
,
self
.
course
)
self
.
passing_score
,
self
.
course
)
def
get_absolute_url
(
self
):
return
reverse
(
'assignments:assignment-details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
@
property
@
property
def
passing_score
(
self
):
def
passing_score
(
self
):
return
round
(
self
.
perfect_score
*
6
/
10
)
return
round
(
self
.
perfect_score
*
6
/
10
)
\ No newline at end of file
widget_k3git/assignments/templates/assignments/assignment-details.html
0 → 100644
View file @
99e2be94
{% extends 'base.html' %}
{% block title %}{{ assignment.name }}{% endblock %}
{% block content %}
<h1>
{{ assignment.name }}
</h1>
<h3>
{{ assignment.course}}
<br>
Description: {{ assignment.description }}
<br>
Perfect Score: {{ assignment.perfect_score }}
<br>
Passing Score: {{ assignment.passing_score }}
<br>
</h3>
{% endblock %}
{% block scripts %}
<input
type=
"submit"
value=
"Edit Assignment"
>
{% endblock %}
\ No newline at end of file
widget_k3git/assignments/templates/assignments/assignments.html
View file @
99e2be94
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<h1>
Welcome to Widget's Assignments!
</h1>
<h1>
Welcome to Widget's Assignments!
</h1>
<h3>
<h3>
{% for assignment in assignments %}
{% for assignment in assignments %}
{{ assignment.name }}
<br>
<a
href=
"{{ assignment.get_absolute_url }}"
>
{{ assignment.name }}
</a>
<br>
{% endfor %}
{% endfor %}
</h3>
</h3>
{% endblock %}
{% endblock %}
...
...
widget_k3git/assignments/urls.py
View file @
99e2be94
from
django.contrib
import
admin
from
django.contrib
import
admin
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
index
from
.views
import
index
,
AssignmentDetailView
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
''
,
index
,
name
=
'index'
),
path
(
'<int:pk>/details'
,
AssignmentDetailView
.
as_view
(),
name
=
'assignment-details'
),
]
]
app_name
=
"assignments"
app_name
=
"assignments"
\ No newline at end of file
widget_k3git/assignments/views.py
View file @
99e2be94
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.
http
import
HttpResponse
from
django.
views.generic.detail
import
DetailView
from
.models
import
Assignment
from
.models
import
Assignment
def
index
(
request
):
def
index
(
request
):
return
render
(
request
,
'assignments/assignments.html'
,
{
'assignments'
:
Assignment
.
objects
.
all
()})
return
render
(
request
,
'assignments/assignments.html'
,
{
'assignments'
:
Assignment
.
objects
.
all
()})
class
AssignmentDetailView
(
DetailView
):
model
=
Assignment
def
get
(
self
,
request
,
pk
):
return
render
(
request
,
'assignments/assignment-details.html'
,
{
'assignment'
:
self
.
model
.
objects
.
get
(
pk
=
pk
)})
\ 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