Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_vincentdjango
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
1
Merge Requests
1
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
Almira Redoble
midterm_vincentdjango
Commits
96ea2992
Commit
96ea2992
authored
Apr 29, 2023
by
Star Neptune R. Sy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
assignments-add is done
parent
8f7e287a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
39 deletions
+49
-39
models.py
widget_vincentdjango/assignments/models.py
+3
-3
assignment-add.html
...jango/assignments/templates/templates/assignment-add.html
+18
-0
assignment-details.html
...o/assignments/templates/templates/assignment-details.html
+1
-1
assignment-edit.html
...ango/assignments/templates/templates/assignment-edit.html
+5
-3
urls.py
widget_vincentdjango/assignments/urls.py
+4
-3
views.py
widget_vincentdjango/assignments/views.py
+18
-29
No files found.
widget_vincentdjango/assignments/models.py
View file @
96ea2992
...
@@ -12,9 +12,9 @@ class Course(models.Model):
...
@@ -12,9 +12,9 @@ class Course(models.Model):
class
Assignment
(
models
.
Model
):
class
Assignment
(
models
.
Model
):
assignment_name
=
models
.
CharField
(
unique
=
True
,
default
=
""
,
max_length
=
50
,)
assignment_name
=
models
.
CharField
(
unique
=
True
,
default
=
""
,
max_length
=
50
,)
description
=
models
.
TextField
(
default
=
""
)
description
=
models
.
TextField
(
default
=
""
)
perfect_score
=
models
.
IntegerField
(
default
=
0
)
perfect_score
=
models
.
IntegerField
(
default
=
10
0
)
passing_score
=
models
.
IntegerField
(
default
=
0
)
passing_score
=
models
.
IntegerField
(
default
=
8
0
)
section
=
models
.
CharField
(
unique
=
True
,
max_length
=
16
,)
section
=
models
.
CharField
(
max_length
=
16
,)
course
=
models
.
ForeignKey
(
course
=
models
.
ForeignKey
(
Course
,
Course
,
on_delete
=
models
.
CASCADE
,
on_delete
=
models
.
CASCADE
,
...
...
widget_vincentdjango/assignments/templates/templates/assignment-add.html
0 → 100644
View file @
96ea2992
{% extends 'base.html' %}
{% block webTitle %} Add Assignment {% endblock %}
{% block pageTitle %} Add a new assignment {% endblock %}
{% block content %}
<form
id=
"editBook"
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
id=
"submitButton"
value=
"Add assignment"
>
</form>
{% endblock %}
{% block otherButtons %}
{% endblock %}
\ No newline at end of file
widget_vincentdjango/assignments/templates/templates/assignment-details.html
View file @
96ea2992
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
{% block content %}
{% block content %}
<h2>
{{object.course}}
</h2>
<h2>
{{object.course}}
</h2>
<p>
Description: {{object.description}}
<br>
<p>
Description: {{object.description}}
<br>
Perfect Score: {{object.pefect_score}}
<br>
Perfect Score: {{object.pe
r
fect_score}}
<br>
Passing Score: {{object.passing_score}}
<br>
Passing Score: {{object.passing_score}}
<br>
</p>
</p>
{% endblock %}
{% endblock %}
...
...
widget_vincentdjango/assignments/templates/templates/assignment-edit.html
View file @
96ea2992
...
@@ -5,10 +5,12 @@
...
@@ -5,10 +5,12 @@
{% block pageTitle %} Edit Assignment {% endblock %}
{% block pageTitle %} Edit Assignment {% endblock %}
{% block content %}
{% block content %}
<form
id=
"editBook"
method=
"post"
>
{% csrf_token %}
{% csrf_token %}
{{ form.as_p }}
{{ form.as_p }}
<input
type=
"submit"
id=
"submitButton"
value=
"Submit"
>
<input
type=
"submit"
id=
"submitButton"
value=
"Edit assignment"
>
</form>
{% endblock %}
{% endblock %}
{% block otherButtons %}
{% block otherButtons %}
...
...
widget_vincentdjango/assignments/urls.py
View file @
96ea2992
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
homeAssignmentsPage
,
AssignmentsDetailView
from
.views
import
homeAssignmentsPage
,
AssignmentsDetailView
,
AssignmentsUpdateView
,
AssignmentsCreateView
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
homeAssignmentsPage
,
name
=
'homePage'
),
path
(
''
,
homeAssignmentsPage
,
name
=
'homePage'
),
path
(
'<int:pk>/details/'
,
AssignmentsDetailView
.
as_view
(),
name
=
'assignment_details'
)
path
(
'add/'
,
AssignmentsCreateView
.
as_view
(),
name
=
'assignment_add'
),
path
(
'<int:pk>/details/'
,
AssignmentsDetailView
.
as_view
(),
name
=
'assignment_details'
),
path
(
'<int:pk>/edit/'
,
AssignmentsUpdateView
.
as_view
(),
name
=
'assignment_update'
),
]
]
...
...
widget_vincentdjango/assignments/views.py
View file @
96ea2992
from
django.forms.models
import
BaseModelForm
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.views.generic.detail
import
DetailView
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.views.generic.list
import
ListView
from
django.http
import
HttpResponse
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
django.urls
import
reverse
,
reverse_lazy
from
.models
import
Assignment
from
.models
import
Assignment
def
homeAssignmentsPage
(
request
):
def
homeAssignmentsPage
(
request
):
return
render
(
request
,
'templates/assignments.html'
,
{
"assignmentsList"
:
Assignment
.
objects
.
all
()})
return
render
(
request
,
'templates/assignments.html'
,
{
"assignmentsList"
:
Assignment
.
objects
.
all
()})
#you can pass an entire list of model instances to the html
class
AssignmentsDetailView
(
DetailView
):
class
AssignmentsDetailView
(
DetailView
):
model
=
Assignment
model
=
Assignment
template_name
=
"templates/assignment-details.html"
template_name
=
"templates/assignment-details.html"
pass
def
index
(
request
):
head
=
"<h1 style='border-bottom:4px solid lightgray;
\
class
AssignmentsUpdateView
(
UpdateView
):
padding-bottom:30px;
\
model
=
Assignment
font-size:500
%
;'>
\
fields
=
"__all__"
Widget's assignment page
\
template_name
=
"templates/assignment-edit.html"
</h1>
\n
"
body
=
""
for
subject
in
Assignment
.
objects
.
all
():
success_url
=
"../details"
body
+=
"<p style='border: 2px solid gray;
\
border-radius:5px;
\
padding:20px 30px;'>
\
<b> Assignment Name: "
+
subject
.
assignment_name
+
" </b> <br>
\
Description: "
+
subject
.
description
+
" <br>
\
Perfect Score: "
+
str
(
subject
.
perfect_score
)
+
" <br>
\
Passing Score: "
+
str
(
subject
.
passing_score
)
+
" <br>
\
Course/Section: "
+
str
(
subject
.
course
)
+
" /"
+
str
(
subject
.
section
)
+
" <br>
\
</p>"
return_string
=
"<html>
\
<body>
\
{}{}
\
</body></html>"
.
format
(
head
,
body
)
return
HttpResponse
(
return_string
)
class
AssignmentsCreateView
(
CreateView
):
model
=
Assignment
fields
=
"__all__"
template_name
=
"templates/assignment-add.html"
def
som
():
def
get_success_url
(
self
):
pass
return
reverse
(
'assignments:assignment_details'
,
kwargs
=
{
#appName:pathName
'pk'
:
self
.
object
.
pk
,
})
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