Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_aguandhischipmunks
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
Adrian Lance Damalerio
midterm_aguandhischipmunks
Commits
9dc25d9d
Commit
9dc25d9d
authored
May 13, 2023
by
Deokhyun Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add page for assignments is now correctly implemented
parent
dea1426b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
74 additions
and
5 deletions
+74
-5
forms.py
widget_aguandhischipmunks/assignments/forms.py
+9
-0
assignment-add.html
...andhischipmunks/assignments/templates/assignment-add.html
+13
-0
assignment-edit.html
...ndhischipmunks/assignments/templates/assignment-edit.html
+12
-0
assignments.html
...aguandhischipmunks/assignments/templates/assignments.html
+1
-1
urls.py
widget_aguandhischipmunks/assignments/urls.py
+2
-1
views.py
widget_aguandhischipmunks/assignments/views.py
+37
-3
db.sqlite3
widget_aguandhischipmunks/db.sqlite3
+0
-0
No files found.
widget_aguandhischipmunks/assignments/forms.py
0 → 100644
View file @
9dc25d9d
from
django
import
forms
from
.models
import
Assignment
class
AddAssignmentForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Assignment
exclude
=
[
'passing_score'
]
widget_aguandhischipmunks/assignments/templates/assignment-add.html
View file @
9dc25d9d
{% extends 'base.html'%}
{% block title %}
Add Assignment
{% endblock %}
{% block content %}
<h2>
Add a new assignment:
</h2>
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<button
type=
"submit"
>
Save New Assignment
</button>
</form>
{% endblock %}
\ No newline at end of file
widget_aguandhischipmunks/assignments/templates/assignment-edit.html
0 → 100644
View file @
9dc25d9d
{% extends 'base.html'%}
{% block title %}
Edit Assignment
{% endblock %}
{% block content %}
<h2>
Edit Assignment:
</h2>
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<button
type=
"submit"
>
Save Changes to Assignment
</button>
</form>
{% endblock %}
\ No newline at end of file
widget_aguandhischipmunks/assignments/templates/assignments.html
View file @
9dc25d9d
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
<p>
No Available Assignments.
</p>
<p>
No Available Assignments.
</p>
{% endif %}
{% endif %}
<ul>
<ul>
<li><button
type=
"button"
onclick=
"window.location.href='/
book
s/add'"
>
New Assignments
</button></li>
<li><button
type=
"button"
onclick=
"window.location.href='/
assignment
s/add'"
>
New Assignments
</button></li>
<li><a
href=
"/dashboard"
>
Dashboard
</a></li>
<li><a
href=
"/dashboard"
>
Dashboard
</a></li>
<li><a
href=
"/announcements"
>
Announcements
</a></li>
<li><a
href=
"/announcements"
>
Announcements
</a></li>
<li><a
href=
"/forum"
>
Forum
</a></li>
<li><a
href=
"/forum"
>
Forum
</a></li>
...
...
widget_aguandhischipmunks/assignments/urls.py
View file @
9dc25d9d
...
@@ -4,5 +4,6 @@ from . import views
...
@@ -4,5 +4,6 @@ from . import views
# url for assignments
# url for assignments
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
views
.
assignments_view
,
name
=
'assignment'
),
path
(
''
,
views
.
assignments_view
,
name
=
'assignment'
),
path
(
'<int:pk>/details'
,
views
.
AssignmentDetailView
.
as_view
(),
name
=
'assignment_detail'
),
path
(
'<int:pk>/details'
,
views
.
AssignmentDetailView
.
as_view
(),
name
=
'assignment_details'
),
path
(
'add'
,
views
.
AssignmentAddListView
.
as_view
(),
name
=
"assignment_add"
),
]
]
\ No newline at end of file
widget_aguandhischipmunks/assignments/views.py
View file @
9dc25d9d
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
from
django.views.generic
import
DetailView
,
CreateView
,
UpdateView
from
.models
import
Assignment
from
.models
import
Assignment
from
django.views.generic
import
DetailView
from
.forms
import
AddAssignmentForm
# assignment view for FBV implementation.
# assignment view for FBV implementation.
def
assignments_view
(
request
):
def
assignments_view
(
request
):
...
@@ -11,4 +13,36 @@ def assignments_view(request):
...
@@ -11,4 +13,36 @@ def assignments_view(request):
class
AssignmentDetailView
(
DetailView
):
class
AssignmentDetailView
(
DetailView
):
model
=
Assignment
model
=
Assignment
template_name
=
'assignment-details.html'
template_name
=
'assignment-details.html'
context_object_name
=
'assignment'
context_object_name
=
'assignment'
\ No newline at end of file
# assignment for adding CBV implementation.
class
AssignmentAddListView
(
CreateView
):
model
=
Assignment
form_class
=
AddAssignmentForm
template_name
=
"assignment-add.html"
def
post
(
self
,
request
):
form
=
AddAssignmentForm
(
request
.
POST
)
if
form
.
is_valid
():
# onSave is called, the form will have essential data and this includes pk as well.
new_assignment
=
form
.
save
()
# pass the pk and redirect.
return
redirect
(
'assignment_details'
,
pk
=
new_assignment
.
pk
)
else
:
return
render
(
request
,
'book_details.html'
,
{
'form'
:
form
})
# assignment for edditing CBV implementation.
class
BookEditView
(
UpdateView
):
model
=
Assignment
()
form_class
=
AddAssignmentForm
template_name
=
'assignment-edit.html'
def
post
(
self
,
request
,
pk
):
form
=
AddAssignmentForm
(
request
.
POST
)
if
form
.
is_valid
():
# onSave is called, the form will have essential data and this includes pk as well.
update_assignment
=
form
.
save
()
# pass the pk and redirect.
return
redirect
(
'assignment_details'
,
pk
=
update_assignment
.
pk
)
else
:
return
render
(
request
,
'book_details.html'
,
{
'form'
:
form
})
\ No newline at end of file
widget_aguandhischipmunks/db.sqlite3
View file @
9dc25d9d
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