Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_Francoconuts
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Chester Tan
widget_Francoconuts
Commits
b99e11d4
Commit
b99e11d4
authored
Mar 31, 2022
by
Chester Tan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added Course model to admin panel
updated Assignments view to display course/section
parent
3643c1e7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
10 deletions
+51
-10
admin.py
widget_Francoconuts/assignments/admin.py
+5
-2
0001_initial.py
widget_Francoconuts/assignments/migrations/0001_initial.py
+11
-2
0003_assignment_course.py
...coconuts/assignments/migrations/0003_assignment_course.py
+20
-0
__init__.py
widget_Francoconuts/assignments/migrations/__init__.py
+0
-0
models.py
widget_Francoconuts/assignments/models.py
+13
-5
assignments.html
...conuts/assignments/templates/assignments/assignments.html
+2
-1
No files found.
widget_Francoconuts/assignments/admin.py
View file @
b99e11d4
from
django.contrib
import
admin
from
.models
import
Assignment
from
.models
import
Assignment
,
Course
class
AssignmentAdmin
(
admin
.
ModelAdmin
):
model
=
Assignment
class
CourseAdmin
(
admin
.
ModelAdmin
):
model
=
Course
admin
.
site
.
register
(
Assignment
,
AssignmentAdmin
)
\ No newline at end of file
admin
.
site
.
register
(
Assignment
,
AssignmentAdmin
)
admin
.
site
.
register
(
Course
,
CourseAdmin
)
\ No newline at end of file
widget_Francoconuts/assignments/migrations/0001_initial.py
View file @
b99e11d4
# Generated by Django 4.0.3 on 2022-03-
22 06:1
2
# Generated by Django 4.0.3 on 2022-03-
31 07:2
2
from
django.db
import
migrations
,
models
...
...
@@ -15,9 +15,18 @@ class Migration(migrations.Migration):
name
=
'Assignment'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'name'
,
models
.
CharField
(
max_length
=
1
0
)),
(
'name'
,
models
.
CharField
(
max_length
=
3
0
)),
(
'description'
,
models
.
TextField
(
max_length
=
500
)),
(
'max_points'
,
models
.
IntegerField
()),
],
),
migrations
.
CreateModel
(
name
=
'Course'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'course_code'
,
models
.
SlugField
(
max_length
=
10
)),
(
'course_title'
,
models
.
SlugField
(
max_length
=
100
)),
(
'section'
,
models
.
CharField
(
max_length
=
3
)),
],
),
]
widget_Francoconuts/assignments/migrations/0003_assignment_course.py
0 → 100644
View file @
b99e11d4
# Generated by Django 4.0.3 on 2022-03-31 07:33
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'assignments'
,
'0002_alter_assignment_name'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'assignment'
,
name
=
'course'
,
field
=
models
.
ForeignKey
(
default
=
1
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'assignment'
,
to
=
'assignments.course'
),
preserve_default
=
False
,
),
]
widget_Francoconuts/assignments/migrations/__init__.py
0 → 100644
View file @
b99e11d4
widget_Francoconuts/assignments/models.py
View file @
b99e11d4
from
django.db
import
models
class
Course
(
models
.
Model
):
course_code
=
models
.
SlugField
(
max_length
=
10
)
course_title
=
models
.
SlugField
(
max_length
=
100
)
section
=
models
.
CharField
(
max_length
=
3
)
def
__str__
(
self
):
return
self
.
course_code
class
Assignment
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
30
)
description
=
models
.
TextField
(
max_length
=
500
)
max_points
=
models
.
IntegerField
()
course
=
models
.
ForeignKey
(
Course
,
on_delete
=
models
.
CASCADE
,
related_name
=
'assignment'
)
def
__str__
(
self
):
return
self
.
name
...
...
@@ -11,8 +24,3 @@ class Assignment(models.Model):
@
property
def
passing_score
(
self
):
return
int
(
self
.
max_points
*
.6
)
class
Course
(
models
.
Model
):
course_code
=
models
.
SlugField
(
max_length
=
10
)
course_title
=
models
.
SlugField
(
max_length
=
100
)
section
=
models
.
CharField
(
max_length
=
3
)
\ No newline at end of file
widget_Francoconuts/assignments/templates/assignments/assignments.html
View file @
b99e11d4
...
...
@@ -3,5 +3,6 @@
<p>
Assignment Name: {{assignment.name}}
</p>
<p>
Description: {{assignment.description}}
</p>
<p>
Perfect Score: {{assignment.max_points}}
</p>
<p>
Passing Score: {{assignment.passing_score}}
</p><br>
<p>
Passing Score: {{assignment.passing_score}}
</p>
<p>
Course/Section: {{assignment.course.course_code}}-{{assignment.course.course_title}}-{{assignment.course.section}}
</p><br>
{% endfor %}
\ 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