Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widgets_FEKK
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
Kyla Martin
widgets_FEKK
Commits
26c273cc
Commit
26c273cc
authored
May 24, 2022
by
Katrina Bernice Tan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added upload image function to Assignments
parent
fdc7e519
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
15 deletions
+24
-15
0008_assignment_image.py
WidgetFEKK/Assignments/migrations/0008_assignment_image.py
+18
-0
models.py
WidgetFEKK/Assignments/models.py
+1
-0
assignment_detail.html
.../Assignments/templates/Assignments/assignment_detail.html
+2
-1
assignment_post.html
WidgetFEKK/Assignments/templates/assignment_post.html
+1
-1
views.py
WidgetFEKK/Assignments/views.py
+2
-13
No files found.
WidgetFEKK/Assignments/migrations/0008_assignment_image.py
0 → 100644
View file @
26c273cc
# Generated by Django 4.0.4 on 2022-05-24 10:11
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'Assignments'
,
'0007_alter_assignment_course'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'assignment'
,
name
=
'image'
,
field
=
models
.
ImageField
(
blank
=
True
,
null
=
True
,
upload_to
=
''
),
),
]
WidgetFEKK/Assignments/models.py
View file @
26c273cc
...
...
@@ -18,6 +18,7 @@ class Assignment(models.Model):
on_delete
=
models
.
CASCADE
,
related_name
=
'requirements'
)
image
=
models
.
ImageField
(
null
=
True
,
blank
=
True
)
def
__str__
(
self
):
return
'Assignment name: {} :{}'
.
format
(
self
.
name
,
self
.
description
)
...
...
WidgetFEKK/Assignments/templates/Assignments/assignment_detail.html
View file @
26c273cc
...
...
@@ -12,7 +12,8 @@
<div
id =
"details"
>
<a
href =
"/assignments"
>
> Back to home
</a>
<br>
<img
src=
"{%static 'images/jokebear.png'%}"
>
<!-- <img src="{%static 'images/jokebear.png'%}">-->
<img
src =
"{{object.image.url}}"
>
<h5>
Assignment Name:
</h5>
<h3>
{{object.name}}
</h3>
...
...
WidgetFEKK/Assignments/templates/assignment_post.html
View file @
26c273cc
...
...
@@ -18,7 +18,7 @@
<div
id =
"courses"
style=
"margin: 5em;"
>
<a
href =
"/assignments"
>
> Back to home
</a>
<form
action=
"{% url 'Assignments:assignment-list' %}"
method =
"POST"
style =
"padding-top: 5em;"
>
<form
action=
"{% url 'Assignments:assignment-list' %}"
method =
"POST"
style =
"padding-top: 5em;"
enctype =
"multipart/form-data"
>
{% csrf_token %}
...
...
WidgetFEKK/Assignments/views.py
View file @
26c273cc
...
...
@@ -28,20 +28,9 @@ class AssignmentListView(ListView):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
form
=
AssignmentForm
(
request
.
POST
)
form
=
AssignmentForm
(
request
.
POST
,
request
.
FILES
)
if
form
.
is_valid
():
name
=
form
.
cleaned_data
.
get
(
'name'
)
description
=
form
.
cleaned_data
.
get
(
'description'
)
max_points
=
form
.
cleaned_data
.
get
(
'max_points'
)
course
=
form
.
cleaned_data
.
get
(
'course'
)
a
=
Assignment
(
name
=
name
,
description
=
description
,
max_points
=
max_points
,
course
=
course
,
)
a
.
save
()
form
.
save
()
return
redirect
(
'/assignments'
)
return
self
.
get
(
request
,
*
args
,
**
kwargs
)
...
...
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