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
b1718512
Commit
b1718512
authored
May 17, 2022
by
Juan Gabriel M. Lacanienta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change Assignments app according to requirements ofFinal Project
parent
4aef3fdf
Changes
7
Hide 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 @
b1718512
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 @
b1718512
...
@@ -7,6 +7,9 @@ class Course(models.Model):
...
@@ -7,6 +7,9 @@ class Course(models.Model):
course_title
=
models
.
CharField
(
max_length
=
50
)
course_title
=
models
.
CharField
(
max_length
=
50
)
section
=
models
.
CharField
(
max_length
=
3
)
section
=
models
.
CharField
(
max_length
=
3
)
def
__str__
(
self
):
return
'{}/{}/{}'
.
format
(
self
.
course_code
,
self
.
course_title
,
self
.
section
)
class
Assignment
(
models
.
Model
):
class
Assignment
(
models
.
Model
):
course
=
models
.
ForeignKey
(
Course
,
on_delete
=
models
.
CASCADE
,
default
=
1
)
course
=
models
.
ForeignKey
(
Course
,
on_delete
=
models
.
CASCADE
,
default
=
1
)
name
=
models
.
CharField
(
max_length
=
10
)
name
=
models
.
CharField
(
max_length
=
10
)
...
@@ -15,5 +18,9 @@ class Assignment(models.Model):
...
@@ -15,5 +18,9 @@ class Assignment(models.Model):
passing_score
=
models
.
IntegerField
(
default
=
0
)
passing_score
=
models
.
IntegerField
(
default
=
0
)
def
save
(
self
,
*
args
,
**
kwargs
):
def
save
(
self
,
*
args
,
**
kwargs
):
super
(
Assignment
,
self
)
.
save
(
*
args
,
**
kwargs
)
self
.
passing_score
=
F
(
'max_points'
)
*
0.6
self
.
passing_score
=
F
(
'max_points'
)
*
0.6
super
(
Assignment
,
self
)
.
save
(
*
args
,
**
kwargs
)
super
(
Assignment
,
self
)
.
save
(
*
args
,
**
kwargs
)
def
__str__
(
self
):
return
'{}'
.
format
(
self
.
name
)
widget_group22/assignments/static/assignments/style.css
View file @
b1718512
...
@@ -11,11 +11,12 @@ h3 {
...
@@ -11,11 +11,12 @@ h3 {
p
{
p
{
color
:
red
;
color
:
red
;
font-weight
:
lighter
;
font-weight
:
bold
;
font-family
:
"Gill Sans"
,
sans-serif
;
font-family
:
"Gill Sans"
,
sans-serif
;
}
}
body
{
body
{
padding
:
20px
;
color
:
black
;
color
:
black
;
background-color
:
orange
;
background-color
:
orange
;
font-family
:
"Gill Sans"
,
sans-serif
;
font-family
:
"Gill Sans"
,
sans-serif
;
...
...
widget_group22/assignments/templates/assignments/addassignments.html
0 → 100644
View file @
b1718512
{% 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 @
b1718512
...
@@ -11,5 +11,7 @@
...
@@ -11,5 +11,7 @@
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
<center>
<button
class=
"button"
><a
href=
"{% url 'assignments:add' %}"
>
New Assignment
</a></button>
</center>
{% endblock %}
{% endblock %}
widget_group22/assignments/urls.py
View file @
b1718512
...
@@ -2,8 +2,9 @@ from django.urls import path
...
@@ -2,8 +2,9 @@ from django.urls import path
from
.
import
views
from
.
import
views
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
views
.
assignments
,
name
=
'assignments'
),
path
(
''
,
views
.
displayAssignments
.
as_view
(),
name
=
'assignments'
),
path
(
"<int:assignment_id>/details/"
,
views
.
details
,
name
=
'details'
)
path
(
"<int:assignment_id>/details/"
,
views
.
details
,
name
=
'details'
),
path
(
"add/"
,
views
.
add
,
name
=
'add'
)
]
]
app_name
=
'assignments'
app_name
=
'assignments'
widget_group22/assignments/views.py
View file @
b1718512
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
from
.
import
models
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
import
Template
,
Context
from
django.template.loader
import
get_template
from
django.template.loader
import
get_template
from
django.views
import
View
# Create your views here.
# Create your views here.
def
index
(
request
):
def
index
(
request
):
return
HttpResponse
(
"This is the Assignments page!"
)
return
HttpResponse
(
"This is the Assignments page!"
)
def
assignments
(
request
):
class
displayAssignments
(
View
):
all_assignments
=
models
.
Assignment
.
objects
.
order_by
(
"name"
)
template
=
"assignments/assignments.html"
all_courses
=
models
.
Course
.
objects
.
order_by
(
"course_code"
)
def
get
(
self
,
request
):
context
=
{
all_assignments
=
models
.
Assignment
.
objects
.
order_by
(
"name"
)
"all_assignments"
:
all_assignments
,
all_courses
=
models
.
Course
.
objects
.
order_by
(
"course_code"
)
"all_courses"
:
all_courses
context
=
{
}
"all_assignments"
:
all_assignments
,
"all_courses"
:
all_courses
}
return
render
(
request
,
"assignments/assignments.html"
,
context
)
return
render
(
request
,
self
.
template
,
context
)
def
details
(
request
,
assignment_id
):
def
details
(
request
,
assignment_id
):
assignment
=
models
.
Assignment
.
objects
.
get
(
pk
=
assignment_id
)
assignment
=
models
.
Assignment
.
objects
.
get
(
pk
=
assignment_id
)
...
@@ -25,3 +29,13 @@ def details(request, assignment_id):
...
@@ -25,3 +29,13 @@ def details(request, assignment_id):
"img"
:
"images/"
+
str
(
assignment_id
)
+
".jpg"
"img"
:
"images/"
+
str
(
assignment_id
)
+
".jpg"
}
}
return
render
(
request
,
"assignments/details.html"
,
context
)
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