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
fdc7e519
Commit
fdc7e519
authored
May 24, 2022
by
Katrina Bernice Tan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added POST functionality to Assignments
parent
4f7f5afc
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
90 additions
and
2 deletions
+90
-2
forms.py
WidgetFEKK/Assignments/forms.py
+8
-0
index.css
WidgetFEKK/Assignments/static/css/index.css
+5
-0
assignment_detail.html
.../Assignments/templates/Assignments/assignment_detail.html
+3
-0
assignment_post.html
WidgetFEKK/Assignments/templates/assignment_post.html
+32
-0
assignments.html
WidgetFEKK/Assignments/templates/assignments.html
+4
-0
views.py
WidgetFEKK/Assignments/views.py
+36
-1
urls.py
WidgetFEKK/WidgetFEKK/urls.py
+2
-1
No files found.
WidgetFEKK/Assignments/forms.py
0 → 100644
View file @
fdc7e519
from
django
import
forms
from
.models
import
Assignment
class
AssignmentForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Assignment
fields
=
'__all__'
WidgetFEKK/Assignments/static/css/index.css
View file @
fdc7e519
...
...
@@ -77,3 +77,8 @@ a:hover{
font-size
:
20px
;
font-weight
:
500
;
}
#button
a
{
font-weight
:
900px
;
padding
:
5em
;
}
\ No newline at end of file
WidgetFEKK/Assignments/templates/Assignments/assignment_detail.html
View file @
fdc7e519
...
...
@@ -10,7 +10,10 @@
</div>
<div
id =
"details"
>
<a
href =
"/assignments"
>
> Back to home
</a>
<br>
<img
src=
"{%static 'images/jokebear.png'%}"
>
<h5>
Assignment Name:
</h5>
<h3>
{{object.name}}
</h3>
<h4>
<b>
Assignment Description:
</b>
{{object.description}}
</h4>
...
...
WidgetFEKK/Assignments/templates/assignment_post.html
0 → 100644
View file @
fdc7e519
{% extends 'base.html' %}
{% load static %}
{% block styles %}
<link
rel =
"stylesheet"
href=
"{% static 'css/index.css' %}"
>
<link
rel=
"preconnect"
href=
"https://fonts.googleapis.com"
>
<link
rel=
"preconnect"
href=
"https://fonts.gstatic.com"
crossorigin
>
<link
href=
"https://fonts.googleapis.com/css2?family=Inter:wght@200;500;900&display=swap"
rel=
"stylesheet"
>
{% endblock styles %}
{% block title %} Assignments {% endblock title%}
{% block content %}
<div
id =
"header"
>
<h1>
Create a new assignment
</h1>
</div>
<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;"
>
{% csrf_token %}
{{form}}
<input
type =
"submit"
value =
"Create New Subject"
>
</form>
</div>
{%endblock content%}
\ No newline at end of file
WidgetFEKK/Assignments/templates/assignments.html
View file @
fdc7e519
...
...
@@ -17,5 +17,9 @@
<h1>
List of courses:
</h1>
</div>
{% include "Assignments/assignment_list.html" with assignments=assignment course=course %}
<div
id =
"button"
>
<a
href =
"/assignments/add"
id =
"assignment-button"
style =
"font-weight: 900px"
>
> New Assignment
</a>
</div>
{%endblock content%}
\ No newline at end of file
WidgetFEKK/Assignments/views.py
View file @
fdc7e519
from
django.shortcuts
import
render
from
ast
import
Assign
from
django.shortcuts
import
render
,
redirect
from
django.http
import
HttpResponse
from
django.views
import
View
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
.models
import
Assignment
,
Course
from
.forms
import
AssignmentForm
class
MainView
(
View
):
def
get
(
self
,
request
):
...
...
@@ -13,10 +15,43 @@ class MainView(View):
return
render
(
request
,
'assignments.html'
,{
'course'
:
course
,
'assignment'
:
assignment
,
'form'
:
AssignmentForm
(),
})
class
AssignmentListView
(
ListView
):
model
=
Assignment
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
'form'
]
=
AssignmentForm
()
return
context
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
form
=
AssignmentForm
(
request
.
POST
)
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
()
return
redirect
(
'/assignments'
)
return
self
.
get
(
request
,
*
args
,
**
kwargs
)
class
AssignmentDetailView
(
DetailView
):
model
=
Assignment
class
AssignmentPostView
(
View
):
def
get
(
self
,
request
):
return
render
(
request
,
'assignment_post.html'
,{
'form'
:
AssignmentForm
(),
})
WidgetFEKK/WidgetFEKK/urls.py
View file @
fdc7e519
...
...
@@ -19,7 +19,7 @@ from django.contrib import admin
from
django.urls
import
path
,
include
import
Announcements.views
as
Announcements_views
import
Forum.views
as
Forum_views
from
Assignments.views
import
AssignmentDetailView
from
Assignments.views
import
AssignmentDetailView
,
AssignmentPostView
from
Homepage.views
import
UserPageView
urlpatterns
=
[
...
...
@@ -33,6 +33,7 @@ urlpatterns = [
path
(
'announcements/<int:announcement_id>/details'
,
Announcements_views
.
details
,
name
=
'announcement_details'
),
path
(
'assignments/'
,
include
(
'Assignments.urls'
,
namespace
=
"Assignments"
)),
path
(
'assignment/<int:pk>/details'
,
AssignmentDetailView
.
as_view
(),
name
=
'assignment-detail'
),
path
(
'assignments/add/'
,
AssignmentPostView
.
as_view
(),
name
=
'assignement-post'
),
]
...
...
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