Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_group17
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
Vaughn Nephi Fajardo
widget_group17
Commits
b8471c6d
Commit
b8471c6d
authored
May 24, 2022
by
Joan Denise Nocos
Browse files
Options
Browse Files
Download
Plain Diff
fix: resolving merge conflicts
parents
5fd6a621
08a18138
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
65 additions
and
12 deletions
+65
-12
forms.cpython-39.pyc
widget_group_17/assignments/__pycache__/forms.cpython-39.pyc
+0
-0
forms.py
widget_group_17/assignments/forms.py
+7
-0
models.py
widget_group_17/assignments/models.py
+4
-1
index.html
widget_group_17/assignments/templates/assignments/index.html
+1
-0
newassignment.html
...p_17/assignments/templates/assignments/newassignment.html
+13
-0
urls.py
widget_group_17/assignments/urls.py
+4
-1
views.py
widget_group_17/assignments/views.py
+36
-10
No files found.
widget_group_17/assignments/__pycache__/forms.cpython-39.pyc
0 → 100644
View file @
b8471c6d
File added
widget_group_17/assignments/forms.py
0 → 100644
View file @
b8471c6d
from
django.forms
import
ModelForm
from
.models
import
Assignment
,
Course
class
AssignmentForm
(
ModelForm
):
class
Meta
:
model
=
Assignment
fields
=
[
"name"
,
"description"
,
"max_points"
,
"course"
]
\ No newline at end of file
widget_group_17/assignments/models.py
View file @
b8471c6d
...
...
@@ -6,6 +6,9 @@ class Course(models.Model):
course_code
=
models
.
CharField
(
max_length
=
10
)
course_title
=
models
.
CharField
(
max_length
=
255
)
section
=
models
.
CharField
(
max_length
=
3
)
def
__str__
(
self
):
return
self
.
course_code
+
'/'
+
self
.
course_title
+
'/'
+
self
.
section
class
Assignment
(
models
.
Model
):
course
=
models
.
ForeignKey
(
Course
,
on_delete
=
models
.
CASCADE
,
null
=
True
)
...
...
@@ -15,7 +18,7 @@ class Assignment(models.Model):
passing_score
=
models
.
IntegerField
(
default
=
0
)
image
=
models
.
FileField
(
upload_to
=
'static/assignments/'
,
null
=
True
)
def
_
str
_
(
self
):
def
_
_str_
_
(
self
):
return
self
.
name
def
file
(
self
):
...
...
widget_group_17/assignments/templates/assignments/index.html
View file @
b8471c6d
...
...
@@ -21,4 +21,5 @@
{% else %}
<p>
No course available.
</p>
{% endif %}
<a
href=
"{% url 'assignments:newassignment' %}"
>
New Assignment
</a>
{% endblock %}
\ No newline at end of file
widget_group_17/assignments/templates/assignments/newassignment.html
0 → 100644
View file @
b8471c6d
{% extends "assignments/base.html" %}
{% block page-title %}New Assignment{% endblock %}
{% block content %}
<h1>
New Assignment
</h1>
<a
href=
"{% url 'assignments:index' %}"
>
Assignments Per Course
</a>
<form
method=
"POST"
action=
"{% url 'assignments:newassignment' %}"
>
{% csrf_token %}
{{ assignment_form.as_p }}
<button
class=
"button"
type=
"submit"
>
Save Assignment
</button>
</form>
{% endblock %}
\ No newline at end of file
widget_group_17/assignments/urls.py
View file @
b8471c6d
from
django.urls
import
path
from
.
import
views
from
.views
import
IndexView
app_name
=
"assignments"
urlpatterns
=
[
# assignments/
path
(
''
,
views
.
index
,
name
=
'index'
),
path
(
''
,
IndexView
.
as_view
()
,
name
=
'index'
),
# assignments/<assignment_id>/details/
path
(
'<int:assignment_id>/details/'
,
views
.
details
,
name
=
'details'
),
# assignments/add/
path
(
'add/'
,
views
.
newassignment
,
name
=
'newassignment'
),
]
\ No newline at end of file
widget_group_17/assignments/views.py
View file @
b8471c6d
from
django.http
import
HttpResponse
,
Http404
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
from
django.views
import
View
from
assignments.models
import
Assignment
,
Course
from
assignments.forms
import
AssignmentForm
# Create your views here.
def
index
(
request
):
course_list
=
Course
.
objects
.
order_by
(
"course_code"
)
assignment_list
=
Assignment
.
objects
.
all
()
context
=
{
"course_list"
:
course_list
,
"assignment_list"
:
assignment_list
,
}
return
render
(
request
,
"assignments/index.html"
,
context
)
class
IndexView
(
View
):
def
get
(
self
,
request
):
course_list
=
Course
.
objects
.
order_by
(
"course_code"
)
assignment_list
=
Assignment
.
objects
.
all
()
context
=
{
"course_list"
:
course_list
,
"assignment_list"
:
assignment_list
,
}
return
render
(
request
,
"assignments/index.html"
,
context
)
def
details
(
request
,
assignment_id
):
try
:
...
...
@@ -27,7 +30,30 @@ def details(request, assignment_id):
}
return
render
(
request
,
"assignments/details.html"
,
context
)
# Code from previous labs:
def
newassignment
(
request
):
if
request
.
method
==
"POST"
:
assignment_form
=
AssignmentForm
(
request
.
POST
)
if
assignment_form
.
is_valid
():
new_assignment
=
assignment_form
.
save
()
return
redirect
(
"assignments:newassignment"
)
else
:
assignment_form
=
AssignmentForm
()
return
render
(
request
,
"assignments/newassignment.html"
,
{
"assignment_form"
:
assignment_form
})
# Code from Lab 3:
#
# def index(request):
# course_list = Course.objects.order_by("course_code")
# assignment_list = Assignment.objects.all()
# context = {
# "course_list" : course_list,
# "assignment_list" : assignment_list,
# }
# return render(request, "assignments/index.html", context)
# Code from Midterm Project and earlier labs:
#
# def index(request):
# assignments_view = "ASSIGNMENTS: <br>"
...
...
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