Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_group 6
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
Patricia Isabella Nava
widget_group 6
Commits
b93bb5c4
Commit
b93bb5c4
authored
Apr 01, 2022
by
Patricia Isabella Nava
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'nava/assignments'
parents
124a5053
9c21583b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
87 additions
and
4 deletions
+87
-4
admin.py
widget_group_6/assignments/admin.py
+6
-2
0002_auto_20220330_2257.py
...group_6/assignments/migrations/0002_auto_20220330_2257.py
+29
-0
models.py
widget_group_6/assignments/models.py
+23
-1
index.html
widget_group_6/assignments/templates/assignments/index.html
+19
-0
views.py
widget_group_6/assignments/views.py
+10
-1
db.sqlite3
widget_group_6/db.sqlite3
+0
-0
No files found.
widget_group_6/assignments/admin.py
View file @
b93bb5c4
from
django.contrib
import
admin
from
django.contrib
import
admin
# Register your models here.
# Register your models here.
from
.models
import
Assignment
from
.models
import
Assignment
,
Course
class
AssignmentAdmin
(
admin
.
ModelAdmin
):
class
AssignmentAdmin
(
admin
.
ModelAdmin
):
model
=
Assignment
model
=
Assignment
admin
.
site
.
register
(
Assignment
,
AssignmentAdmin
)
class
CourseAdmin
(
admin
.
ModelAdmin
):
\ No newline at end of file
model
=
Course
admin
.
site
.
register
(
Assignment
,
AssignmentAdmin
)
admin
.
site
.
register
(
Course
,
CourseAdmin
)
\ No newline at end of file
widget_group_6/assignments/migrations/0002_auto_20220330_2257.py
0 → 100644
View file @
b93bb5c4
# Generated by Django 3.2.12 on 2022-03-30 14:57
import
django.core.validators
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'assignments'
,
'0001_initial'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Course'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'course_code'
,
models
.
CharField
(
max_length
=
10
)),
(
'course_title'
,
models
.
CharField
(
max_length
=
100
)),
(
'section'
,
models
.
SlugField
(
max_length
=
3
,
validators
=
[
django
.
core
.
validators
.
RegexValidator
(
'^[a-zA-Z]*$'
)])),
],
),
migrations
.
AddField
(
model_name
=
'assignment'
,
name
=
'course'
,
field
=
models
.
ForeignKey
(
default
=
None
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'assignments.course'
),
),
]
widget_group_6/assignments/models.py
View file @
b93bb5c4
from
pyexpat
import
model
from
django.db
import
models
from
django.db
import
models
from
django.core.validators
import
RegexValidator
# Create your models here.
# Create your models here.
class
Course
(
models
.
Model
):
course_code
=
models
.
CharField
(
max_length
=
10
)
course_title
=
models
.
CharField
(
max_length
=
100
)
section
=
models
.
SlugField
(
max_length
=
3
,
validators
=
[
RegexValidator
(
r'^[a-zA-Z]*$'
)]
)
def
__str__
(
self
):
return
self
.
course_code
+
" - "
+
self
.
course_title
class
Assignment
(
models
.
Model
):
class
Assignment
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
name
=
models
.
CharField
(
max_length
=
50
)
description
=
models
.
CharField
(
max_length
=
200
)
description
=
models
.
CharField
(
max_length
=
200
)
max_points
=
models
.
IntegerField
()
max_points
=
models
.
IntegerField
()
course
=
models
.
ForeignKey
(
'Course'
,
on_delete
=
models
.
CASCADE
,
default
=
None
,
null
=
True
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
name
return
self
.
name
@
property
def
passing_score
(
self
):
return
int
(
self
.
max_points
*
0.6
)
widget_group_6/assignments/templates/assignments/index.html
0 → 100644
View file @
b93bb5c4
<!DOCTYPE html>
<html>
<head></head>
<body>
<h1>
ASSIGNMENTS:
</h1>
{% for assignment in assignment_entries %}
<p>
Assignment Name: {{assignment.name}}
<br>
Description: {{assignment.description}}
<br>
Perfect Score: {{assignment.max_points}}
<br>
Passing Score: {{assignment.passing_score}}
<br>
Course/Section: {{assignment.course.course_code}} {{assignment.course.course_title}} | {{assignment.course.section}}
</p>
{% endfor %}
</body>
</html>
widget_group_6/assignments/views.py
View file @
b93bb5c4
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
django.template
import
loader
from
.models
import
Course
,
Assignment
# Create your views here.
# Create your views here.
def
index
(
request
):
def
index
(
request
):
return
HttpResponse
(
"This is the Assignments page!"
)
assignments
=
Assignment
.
objects
.
all
()
\ No newline at end of file
template
=
loader
.
get_template
(
'assignments/index.html'
)
context
=
{
'assignment_entries'
:
assignments
}
return
HttpResponse
(
template
.
render
(
context
,
request
))
widget_group_6/db.sqlite3
View file @
b93bb5c4
No preview for this file type
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