Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_jenicaesports
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
Christianneil Emmanuel Ocampo
midterm_jenicaesports
Commits
385eee3d
Commit
385eee3d
authored
May 10, 2023
by
Ciella
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created views and updated URLs
parent
98014e12
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
14 deletions
+27
-14
urls.py
widget_jenicaesports/assignments/urls.py
+5
-2
views.py
widget_jenicaesports/assignments/views.py
+22
-12
No files found.
widget_jenicaesports/assignments/urls.py
View file @
385eee3d
from
django.urls
import
path
from
.views
import
index
from
.views
import
assignments_view
,
AssignmentDetailView
,
AssignmentCreateView
,
AssignmentUpdateView
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
'assignments/'
,
assignments_view
,
name
=
'assignments_view'
),
path
(
'assignments/<int:pk>/details/'
,
AssignmentDetailView
.
as_view
(),
name
=
'assignment-details'
),
path
(
'assignments/add/'
,
AssignmentCreateView
.
as_view
(),
name
=
'assignment-add'
),
path
(
'assignments/<int:pk>/edit/'
,
AssignmentUpdateView
.
as_view
(),
name
=
'assignment-edit'
),
]
app_name
=
'assignments'
\ No newline at end of file
widget_jenicaesports/assignments/views.py
View file @
385eee3d
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
Assignment
# Create your views here.
def
index
(
request
):
return_string
=
'<p>Widget
\'
s Assignments Page<br>'
for
work
in
Assignment
.
objects
.
all
(
):
work_string
=
'<br>Assignment Name: {}<br>Description: {}<br>Perfect Score: {}<br>Passing Score: {}<br>Course/Section: {} {}-{}<br>'
.
format
(
work
.
name
,
work
.
description
,
work
.
perfect_score
,
work
.
passing_score
,
work
.
course
.
code
,
work
.
course
.
title
,
work
.
course
.
section
)
return_string
+=
work_string
def
assignments_view
(
request
):
tasks
=
Assignment
.
objects
.
all
()
context
=
{
'tasks'
:
tasks
}
return
render
(
request
,
'assignments/assignments.html'
)
return_string
+=
'</p>'
html_string
=
'<html><body>{}</body></html>'
.
format
(
return_string
)
return
HttpResponse
(
html_string
)
\ No newline at end of file
class
AssignmentDetailView
(
DetailView
):
model
=
Assignment
template_name
=
'assignments/assignment-details.html'
class
AssignmentCreateView
(
CreateView
):
model
=
Assignment
fields
=
'__all__'
template_name
=
'assignments/assignment-add.html'
class
AssignmentUpdateView
(
UpdateView
):
model
=
Assignment
fields
=
'__all__'
template_name
=
'assignments/assignment-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