Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_group 6
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
Patricia Isabella Nava
widget_group 6
Commits
8da1ff9f
Commit
8da1ff9f
authored
May 26, 2022
by
Patricia Isabella Nava
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'nava/assignments'
parents
69e51314
b3b95eda
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
77 additions
and
11 deletions
+77
-11
forms.py
widget_group_6/assignments/forms.py
+8
-0
0003_assignment_image.py
...t_group_6/assignments/migrations/0003_assignment_image.py
+18
-0
models.py
widget_group_6/assignments/models.py
+6
-1
yoga.jpg
...et_group_6/assignments/static/assignments/images/yoga.jpg
+0
-0
add.html
widget_group_6/assignments/templates/assignments/add.html
+14
-0
detail.html
widget_group_6/assignments/templates/assignments/detail.html
+2
-6
index.html
widget_group_6/assignments/templates/assignments/index.html
+1
-2
urls.py
widget_group_6/assignments/urls.py
+2
-0
views.py
widget_group_6/assignments/views.py
+15
-1
History.png
widget_group_6/media/images/History.png
+0
-0
History_yLi7bgC.png
widget_group_6/media/images/History_yLi7bgC.png
+0
-0
history.jpg
widget_group_6/media/images/history.jpg
+0
-0
koreanlang.png
widget_group_6/media/images/koreanlang.png
+0
-0
yoga.jpg
widget_group_6/media/images/yoga.jpg
+0
-0
settings.py
widget_group_6/widget_group_6/settings.py
+7
-0
urls.py
widget_group_6/widget_group_6/urls.py
+4
-1
No files found.
widget_group_6/assignments/forms.py
0 → 100644
View file @
8da1ff9f
from
statistics
import
mode
from
django.forms
import
ModelForm
from
.models
import
Assignment
class
AssignmentForm
(
ModelForm
):
class
Meta
:
model
=
Assignment
fields
=
[
"name"
,
"description"
,
"max_points"
,
"course"
,
"image"
]
\ No newline at end of file
widget_group_6/assignments/migrations/0003_assignment_image.py
0 → 100644
View file @
8da1ff9f
# Generated by Django 3.2.12 on 2022-05-26 11:19
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'assignments'
,
'0002_auto_20220330_2257'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'assignment'
,
name
=
'image'
,
field
=
models
.
ImageField
(
blank
=
True
,
null
=
True
,
upload_to
=
'images/'
),
),
]
widget_group_6/assignments/models.py
View file @
8da1ff9f
...
@@ -14,7 +14,7 @@ class Course(models.Model):
...
@@ -14,7 +14,7 @@ class Course(models.Model):
)
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
course_code
+
" - "
+
self
.
course_title
return
self
.
course_code
+
" - "
+
self
.
course_title
+
" | "
+
self
.
section
class
Assignment
(
models
.
Model
):
class
Assignment
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
name
=
models
.
CharField
(
max_length
=
50
)
...
@@ -26,6 +26,11 @@ class Assignment(models.Model):
...
@@ -26,6 +26,11 @@ class Assignment(models.Model):
default
=
None
,
default
=
None
,
null
=
True
null
=
True
)
)
image
=
models
.
ImageField
(
null
=
True
,
blank
=
True
,
upload_to
=
"images/"
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
name
return
self
.
name
...
...
widget_group_6/assignments/static/assignments/images/yoga.jpg
deleted
100644 → 0
View file @
69e51314
38 KB
widget_group_6/assignments/templates/assignments/add.html
0 → 100644
View file @
8da1ff9f
{% extends "assignments/base.html" %}
{% block content %}
<h1>
Add Assignment
</h1>
<form
method=
"POST"
enctype=
"multipart/form-data"
action=
"{% url 'assignments:add' %}"
>
{% csrf_token %}
{{assignment_form.media}}
{{ assignment_form.as_p }}
<button
class=
"button"
type=
"submit"
>
Save Assignment
</button>
</form>
<br>
<button
type=
"button"
>
<a
href=
"{% url 'assignments:index' %}"
id =
"back"
>
Back to Main Assignments Page
</a>
</button>
{% endblock %}
\ No newline at end of file
widget_group_6/assignments/templates/assignments/detail.html
View file @
8da1ff9f
...
@@ -9,12 +9,8 @@
...
@@ -9,12 +9,8 @@
{{assignment.max_points}}
<br>
{{assignment.max_points}}
<br>
{{assignment.passing_score}}
<br>
{{assignment.passing_score}}
<br>
{% if assignment.id == 1 %}
{% if assignment.image %}
<img
src =
"{% static 'assignments/images/history.jpg' %}"
alt =
"history"
>
<img
src=
"{{ assignment.image.url }}"
>
{% elif assignment.id == 2 %}
<img
src =
"{% static 'assignments/images/koreanlang.png' %}"
alt =
"korean speaking"
>
{% else %}
<img
src =
"{% static 'assignments/images/yoga.jpg' %}"
alt =
"yoga"
>
{% endif %}
{% endif %}
...
...
widget_group_6/assignments/templates/assignments/index.html
View file @
8da1ff9f
...
@@ -19,8 +19,7 @@
...
@@ -19,8 +19,7 @@
{% endfor %}
{% endfor %}
</p>
</p>
<button
type=
"button"
>
<a
href=
"{% url 'assignments:add' %}"
id=
"new"
>
New Assignment
</a>
</button>
{% endblock %}
{% endblock %}
...
...
widget_group_6/assignments/urls.py
View file @
8da1ff9f
...
@@ -6,6 +6,8 @@ urlpatterns = [
...
@@ -6,6 +6,8 @@ urlpatterns = [
path
(
''
,
views
.
index
,
name
=
'index'
),
path
(
''
,
views
.
index
,
name
=
'index'
),
#assignments/1/details
#assignments/1/details
path
(
"<int:assignment_id>/details/"
,
views
.
detail
,
name
=
'detail'
),
path
(
"<int:assignment_id>/details/"
,
views
.
detail
,
name
=
'detail'
),
#assignments/add
path
(
"add/"
,
views
.
add
,
name
=
'add'
),
]
]
app_name
=
"assignments"
app_name
=
"assignments"
\ No newline at end of file
widget_group_6/assignments/views.py
View file @
8da1ff9f
...
@@ -2,6 +2,8 @@ from unicodedata import name
...
@@ -2,6 +2,8 @@ from unicodedata import name
from
django.http
import
Http404
,
HttpResponse
from
django.http
import
Http404
,
HttpResponse
from
django.shortcuts
import
render
,
redirect
from
django.shortcuts
import
render
,
redirect
from
.models
import
Course
,
Assignment
from
.models
import
Course
,
Assignment
from
.forms
import
AssignmentForm
# Create your views here.
# Create your views here.
...
@@ -17,4 +19,16 @@ def detail(request, assignment_id):
...
@@ -17,4 +19,16 @@ def detail(request, assignment_id):
assignment
=
Assignment
.
objects
.
get
(
pk
=
assignment_id
)
assignment
=
Assignment
.
objects
.
get
(
pk
=
assignment_id
)
except
Assignment
.
DoesNotExist
:
except
Assignment
.
DoesNotExist
:
raise
Http404
(
"Assignment does not exist!"
)
raise
Http404
(
"Assignment does not exist!"
)
return
render
(
request
,
"assignments/detail.html"
,
{
"assignment"
:
assignment
})
return
render
(
request
,
"assignments/detail.html"
,
{
"assignment"
:
assignment
})
\ No newline at end of file
def
add
(
request
):
if
request
.
method
==
"POST"
:
assignment_form
=
AssignmentForm
(
request
.
POST
,
request
.
FILES
)
if
assignment_form
.
is_valid
():
new_assignment
=
assignment_form
.
save
()
return
redirect
(
"assignments:add"
)
else
:
assignment_form
=
AssignmentForm
()
context
=
{
"assignment_form"
:
assignment_form
}
return
render
(
request
,
"assignments/add.html"
,
context
)
\ No newline at end of file
widget_group_6/media/images/History.png
0 → 100644
View file @
8da1ff9f
77.7 KB
widget_group_6/media/images/History_yLi7bgC.png
0 → 100644
View file @
8da1ff9f
77.7 KB
widget_group_6/
assignments/static/assignments
/images/history.jpg
→
widget_group_6/
media
/images/history.jpg
View file @
8da1ff9f
File moved
widget_group_6/
assignments/static/assignments
/images/koreanlang.png
→
widget_group_6/
media
/images/koreanlang.png
View file @
8da1ff9f
File moved
widget_group_6/media/images/yoga.jpg
0 → 100644
View file @
8da1ff9f
6.95 KB
widget_group_6/widget_group_6/settings.py
View file @
8da1ff9f
...
@@ -132,3 +132,10 @@ STATIC_URL = '/static/'
...
@@ -132,3 +132,10 @@ STATIC_URL = '/static/'
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD
=
'django.db.models.BigAutoField'
DEFAULT_AUTO_FIELD
=
'django.db.models.BigAutoField'
MEDIA_URL
=
'/media/'
MEDIA_ROOT
=
os
.
path
.
join
(
BASE_DIR
,
'media'
)
STATICFILES_DIRS
=
(
os
.
path
.
join
(
BASE_DIR
,
'static'
),
)
\ No newline at end of file
widget_group_6/widget_group_6/urls.py
View file @
8da1ff9f
...
@@ -15,6 +15,8 @@ Including another URLconf
...
@@ -15,6 +15,8 @@ Including another URLconf
"""
"""
from
django.contrib
import
admin
from
django.contrib
import
admin
from
django.urls
import
include
,
path
from
django.urls
import
include
,
path
from
django.conf
import
settings
from
django.conf.urls.static
import
static
urlpatterns
=
[
urlpatterns
=
[
path
(
'assignments/'
,
include
(
'assignments.urls'
,
namespace
=
"assignments"
)),
path
(
'assignments/'
,
include
(
'assignments.urls'
,
namespace
=
"assignments"
)),
...
@@ -22,4 +24,5 @@ urlpatterns = [
...
@@ -22,4 +24,5 @@ urlpatterns = [
path
(
"homepage/"
,
include
(
'homepage.urls'
,
namespace
=
"homepage"
)),
path
(
"homepage/"
,
include
(
'homepage.urls'
,
namespace
=
"homepage"
)),
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'announcements/'
,
include
(
'announcements.urls'
,
namespace
=
"announcements"
)),
path
(
'announcements/'
,
include
(
'announcements.urls'
,
namespace
=
"announcements"
)),
]
]
+
static
(
settings
.
MEDIA_URL
,
document_root
=
settings
.
MEDIA_ROOT
)
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