Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_group22
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 Tamano
widget_group22
Commits
542b31ef
Commit
542b31ef
authored
May 18, 2022
by
N1o9r4b7e9r6to
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://gitlab.discs.ateneo.edu/JohnTamano/widget_group22
parents
b6962c2d
b1718512
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
14 deletions
+56
-14
forms.py
widget_group22/assignments/forms.py
+7
-0
models.py
widget_group22/assignments/models.py
+7
-0
style.css
widget_group22/assignments/static/assignments/style.css
+2
-1
addassignments.html
...p22/assignments/templates/assignments/addassignments.html
+10
-0
assignments.html
...roup22/assignments/templates/assignments/assignments.html
+3
-1
urls.py
widget_group22/assignments/urls.py
+3
-2
views.py
widget_group22/assignments/views.py
+24
-10
No files found.
widget_group22/assignments/forms.py
0 → 100644
View file @
542b31ef
from
django.forms
import
ModelForm
from
.models
import
Assignment
,
Course
class
AssignmentForm
(
ModelForm
):
class
Meta
:
model
=
Assignment
fields
=
[
"name"
,
"description"
,
"max_points"
,
"course"
]
widget_group22/assignments/models.py
View file @
542b31ef
...
...
@@ -7,6 +7,9 @@ class Course(models.Model):
course_title
=
models
.
CharField
(
max_length
=
50
)
section
=
models
.
CharField
(
max_length
=
3
)
def
__str__
(
self
):
return
'{}/{}/{}'
.
format
(
self
.
course_code
,
self
.
course_title
,
self
.
section
)
class
Assignment
(
models
.
Model
):
course
=
models
.
ForeignKey
(
Course
,
on_delete
=
models
.
CASCADE
,
default
=
1
)
name
=
models
.
CharField
(
max_length
=
10
)
...
...
@@ -15,5 +18,9 @@ class Assignment(models.Model):
passing_score
=
models
.
IntegerField
(
default
=
0
)
def
save
(
self
,
*
args
,
**
kwargs
):
super
(
Assignment
,
self
)
.
save
(
*
args
,
**
kwargs
)
self
.
passing_score
=
F
(
'max_points'
)
*
0.6
super
(
Assignment
,
self
)
.
save
(
*
args
,
**
kwargs
)
def
__str__
(
self
):
return
'{}'
.
format
(
self
.
name
)
widget_group22/assignments/static/assignments/style.css
View file @
542b31ef
...
...
@@ -11,11 +11,12 @@ h3 {
p
{
color
:
red
;
font-weight
:
lighter
;
font-weight
:
bold
;
font-family
:
"Gill Sans"
,
sans-serif
;
}
body
{
padding
:
20px
;
color
:
black
;
background-color
:
orange
;
font-family
:
"Gill Sans"
,
sans-serif
;
...
...
widget_group22/assignments/templates/assignments/addassignments.html
0 → 100644
View file @
542b31ef
{% extends "assignments/base.html" %}
{% block content %}
<form
method=
"POST"
action=
"{% url 'assignments:add' %}"
>
{% csrf_token %}
{{assignment_form.as_p}}
<button
class=
"button"
type=
"submit"
>
Save Assignment
</button>
<button
class=
"button"
><a
href=
"/assignments/"
"
>
Back
</a></button>
</form>
{% endblock %}
widget_group22/assignments/templates/assignments/assignments.html
View file @
542b31ef
...
...
@@ -11,5 +11,7 @@
{% endif %}
{% endfor %}
{% endfor %}
<center>
<button
class=
"button"
><a
href=
"{% url 'assignments:add' %}"
>
New Assignment
</a></button>
</center>
{% endblock %}
widget_group22/assignments/urls.py
View file @
542b31ef
...
...
@@ -2,8 +2,9 @@ from django.urls import path
from
.
import
views
urlpatterns
=
[
path
(
''
,
views
.
assignments
,
name
=
'assignments'
),
path
(
"<int:assignment_id>/details/"
,
views
.
details
,
name
=
'details'
)
path
(
''
,
views
.
displayAssignments
.
as_view
(),
name
=
'assignments'
),
path
(
"<int:assignment_id>/details/"
,
views
.
details
,
name
=
'details'
),
path
(
"add/"
,
views
.
add
,
name
=
'add'
)
]
app_name
=
'assignments'
widget_group22/assignments/views.py
View file @
542b31ef
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
from
.
import
models
from
django.http
import
HttpResponse
from
.forms
import
AssignmentForm
from
django.http
import
HttpResponse
,
Http404
from
django.template
import
Template
,
Context
from
django.template.loader
import
get_template
from
django.views
import
View
# Create your views here.
def
index
(
request
):
return
HttpResponse
(
"This is the Assignments page!"
)
def
assignments
(
request
):
class
displayAssignments
(
View
):
template
=
"assignments/assignments.html"
def
get
(
self
,
request
):
all_assignments
=
models
.
Assignment
.
objects
.
order_by
(
"name"
)
all_courses
=
models
.
Course
.
objects
.
order_by
(
"course_code"
)
context
=
{
...
...
@@ -16,7 +20,7 @@ def assignments(request):
"all_courses"
:
all_courses
}
return
render
(
request
,
"assignments/assignments.html"
,
context
)
return
render
(
request
,
self
.
template
,
context
)
def
details
(
request
,
assignment_id
):
assignment
=
models
.
Assignment
.
objects
.
get
(
pk
=
assignment_id
)
...
...
@@ -25,3 +29,13 @@ def details(request, assignment_id):
"img"
:
"images/"
+
str
(
assignment_id
)
+
".jpg"
}
return
render
(
request
,
"assignments/details.html"
,
context
)
def
add
(
request
):
if
request
.
method
==
"POST"
:
assignment_form
=
AssignmentForm
(
request
.
POST
)
if
assignment_form
.
is_valid
():
new_assignment
=
assignment_form
.
save
()
return
redirect
(
"assignments:assignments"
)
else
:
assignment_form
=
AssignmentForm
()
return
render
(
request
,
"assignments/addassignments.html"
,
{
"assignment_form"
:
assignment_form
})
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