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
1dfeae68
Commit
1dfeae68
authored
Mar 04, 2023
by
Gabriel Limbaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented models, admin, and views for assignments
parent
fd90c34d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
5 deletions
+56
-5
admin.py
widget_casanatics/assignments/admin.py
+12
-1
models.py
widget_casanatics/assignments/models.py
+22
-0
views.py
widget_casanatics/assignments/views.py
+19
-2
__init__.cpython-310.pyc
...cs/widget_casanatics/__pycache__/__init__.cpython-310.pyc
+0
-0
settings.cpython-310.pyc
...cs/widget_casanatics/__pycache__/settings.cpython-310.pyc
+0
-0
urls.py
widget_casanatics/widget_casanatics/urls.py
+3
-2
No files found.
widget_casanatics/assignments/admin.py
View file @
1dfeae68
from
django.contrib
import
admin
from
.models
import
Assignment
,
Course
# Register your models here.
class
AssignmentAdmin
(
admin
.
ModelAdmin
):
model
=
Assignment
list_display
=
(
"name"
,
"description"
,
"course"
,
"perfect_score"
,
"passing_score"
)
class
CourseAdmin
(
admin
.
ModelAdmin
):
model
=
Course
list_display
=
(
"code"
,
"title"
,
"section"
)
admin
.
site
.
register
(
Assignment
,
AssignmentAdmin
)
admin
.
site
.
register
(
Course
,
CourseAdmin
)
\ No newline at end of file
widget_casanatics/assignments/models.py
View file @
1dfeae68
from
django.db
import
models
# Create your models here.
class
Course
(
models
.
Model
):
code
=
models
.
CharField
(
max_length
=
10
)
title
=
models
.
CharField
(
max_length
=
50
)
section
=
models
.
CharField
(
max_length
=
3
)
def
__str__
(
self
):
return
self
.
code
class
Assignment
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
100
)
description
=
models
.
TextField
(
blank
=
True
)
course
=
models
.
ForeignKey
(
Course
,
on_delete
=
models
.
CASCADE
)
perfect_score
=
models
.
IntegerField
(
default
=
0
)
@
property
def
passing_score
(
self
):
if
(
self
.
perfect_score
!=
None
):
return
self
.
perfect_score
*
0.60
def
__str__
(
self
):
return
self
.
name
\ No newline at end of file
widget_casanatics/assignments/views.py
View file @
1dfeae68
from
django.shortcuts
import
render
from
django.shortcuts
import
HttpResponse
from
.models
import
Assignment
,
Course
# Create your views here.
def
assign
(
request
):
assignments
=
Assignment
.
objects
.
all
()
response
=
"Widget's Assignments Page <br><br>"
for
assignment
in
assignments
:
AName
=
"Asssignment Name: "
+
assignment
.
name
+
"<br>"
ADesc
=
"Description: "
+
assignment
.
description
+
"<br>"
APeScore
=
"Perfect Score: "
+
str
(
assignment
.
perfect_score
)
+
"<br>"
APaScore
=
"Passing Score: "
+
str
(
assignment
.
passing_score
)
+
"<br>"
Coursec
=
"Course/Section: "
+
assignment
.
course
.
code
+
" "
+
assignment
.
course
.
title
+
"-"
+
assignment
.
course
.
section
response
+=
AName
+
ADesc
+
APeScore
+
APaScore
+
Coursec
+
"<br><br>"
return
HttpResponse
(
response
)
widget_casanatics/widget_casanatics/__pycache__/__init__.cpython-310.pyc
View file @
1dfeae68
No preview for this file type
widget_casanatics/widget_casanatics/__pycache__/settings.cpython-310.pyc
View file @
1dfeae68
No preview for this file type
widget_casanatics/widget_casanatics/urls.py
View file @
1dfeae68
...
...
@@ -14,8 +14,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from
django.contrib
import
admin
from
django.urls
import
path
from
django.urls
import
include
,
path
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'assignments/'
,
include
(
"assignments.urls"
)),
path
(
'admin/'
,
admin
.
site
.
urls
)
]
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