Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
midterm_OhMyBash
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
Nheo Samson
midterm_OhMyBash
Commits
7eba6986
Commit
7eba6986
authored
May 14, 2023
by
nheoxoz
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'origin/assignmentsv2'
parents
d14ca48c
f382bad6
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
112 additions
and
28 deletions
+112
-28
admin.py
widget_OhMyBash/assignments/admin.py
+3
-3
models.py
widget_OhMyBash/assignments/models.py
+12
-4
.DS_Store
widget_OhMyBash/assignments/templates/.DS_Store
+0
-0
.DS_Store
widget_OhMyBash/assignments/templates/assignments/.DS_Store
+0
-0
assignment-add.html
...ash/assignments/templates/assignments/assignment-add.html
+10
-0
assignment-details.html
...assignments/templates/assignments/assignment-details.html
+14
-0
assignment-edit.html
...sh/assignments/templates/assignments/assignment-edit.html
+10
-0
assignments.html
...MyBash/assignments/templates/assignments/assignments.html
+28
-0
urls.py
widget_OhMyBash/assignments/urls.py
+6
-3
views.py
widget_OhMyBash/assignments/views.py
+29
-18
No files found.
widget_OhMyBash/assignments/admin.py
View file @
7eba6986
...
...
@@ -6,9 +6,9 @@ from .models import Assignment, Course
class
AssignmentAdmin
(
admin
.
ModelAdmin
):
model
=
Assignment
list_display
=
(
'
assignment_
name'
,
'description'
,
'course'
,
'perfect_score'
,)
search_fields
=
(
'
assignment_
name'
,
'description'
,
'course'
,
'perfect_score'
,)
list_filter
=
(
'
assignment_
name'
,
'description'
,
'course'
,
'perfect_score'
,)
list_display
=
(
'name'
,
'description'
,
'course'
,
'perfect_score'
,)
search_fields
=
(
'name'
,
'description'
,
'course'
,
'perfect_score'
,)
list_filter
=
(
'name'
,
'description'
,
'course'
,
'perfect_score'
,)
class
CourseAdmin
(
admin
.
ModelAdmin
):
...
...
widget_OhMyBash/assignments/models.py
View file @
7eba6986
from
django.db
import
models
from
django.urls
import
reverse
class
Course
(
models
.
Model
):
code
=
models
.
CharField
(
max_length
=
10
)
...
...
@@ -14,15 +16,21 @@ class Course(models.Model):
class
Assignment
(
models
.
Model
):
assignment_
name
=
models
.
CharField
(
max_length
=
50
)
name
=
models
.
CharField
(
max_length
=
50
)
description
=
models
.
TextField
()
course
=
models
.
ForeignKey
(
Course
,
on_delete
=
models
.
CASCADE
)
perfect_score
=
models
.
IntegerField
()
def
__str__
(
self
):
return
'''{}, {}, {}, {}'''
.
format
(
self
.
assignment_
name
,
return
'''{}, {}, {}, {}'''
.
format
(
self
.
name
,
self
.
description
,
self
.
course
,
self
.
perfect_score
,
)
\ No newline at end of file
)
def
passing_score
(
self
):
return
round
(
self
.
perfect_score
*
0.6
)
def
get_absolute_url
(
self
):
return
reverse
(
'assignments:assignment-details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
widget_OhMyBash/assignments/templates/.DS_Store
0 → 100644
View file @
7eba6986
File added
widget_OhMyBash/assignments/templates/assignments/.DS_Store
0 → 100644
View file @
7eba6986
File added
widget_OhMyBash/assignments/templates/assignments/assignment-add.html
0 → 100644
View file @
7eba6986
{% extends 'base.html' %}
{% block title %} Add Assignment {% endblock %}
{% block heading %} Add a new assignment: {% endblock %}
{% block content %}
<form
method=
"POST"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"SUBMIT"
value=
"Save New Assignment"
>
</form>
{% endblock %}
widget_OhMyBash/assignments/templates/assignments/assignment-details.html
0 → 100644
View file @
7eba6986
{% extends 'base.html' %}
{% block title %} {{ assignment.name }} {% endblock %}
{% block heading %} {{ assignment.name }} {% endblock %}
{% block content %}
<p>
{{ assignment.course.code }} {{ assignment.course.title }} - {{ assignment.course.section }}
<br>
Description: {{ assignment.description }}
<br>
Perfert Score: {{ assignment.perfect_score }}
<br>
Passing Score: {{ assignment.passing_score }}
</p>
<a
href=
"{% url 'assignments:assignment-edit' assignment.id %}"
>
<button>
Edit Assignment
</button>
</a><br>
{% endblock %}
widget_OhMyBash/assignments/templates/assignments/assignment-edit.html
0 → 100644
View file @
7eba6986
{% extends 'base.html' %}
{% block title %} Edit Assignment {% endblock %}
{% block heading %} Edit Assignment: {% endblock %}
{% block content %}
<form
method=
"POST"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"SUBMIT"
value=
"Save Changes to Assignment"
>
</form>
{% endblock %}
widget_OhMyBash/assignments/templates/assignments/assignments.html
0 → 100644
View file @
7eba6986
{% extends 'base.html' %}
{% load static %}
{% block title %} Widget's Assignments {% endblock %}
{% block heading %} Welcome to Widget's Assignments! {% endblock %}
{% block content %}
<div
class=
"main"
>
<div
class=
"list"
>
<ul>
{% for assignment in assignments %}
<a
href=
"{{ assignment.get_absolute_url }}"
>
<li>
{{assignment.name}}
</li>
</a>
{% endfor %}
</ul>
</div>
<a
href=
"{% url 'assignments:assignment-add' %}"
class=
"add-btn"
><i
class=
"fa fa-plus"
></i>
New Assignment
</a>
</div>
{% endblock %}
{% block footing %}
<div
class=
"links"
>
<a
href=
"/dashboard/"
class=
"btn-primary"
>
Dashboard --
</a>
<a
href=
"/announcements/"
class=
"btn-primary"
>
Announcements --
</a>
<a
href=
"/forum/"
class=
"btn-primary"
>
Forum --
</a>
<a
href=
"/widget_calendar/"
class=
"btn-primary"
>
Calendar
</a>
</div>
{% endblock %}
widget_OhMyBash/assignments/urls.py
View file @
7eba6986
from
django.urls
import
path
from
.views
import
index
from
.views
import
Assignments
,
AssignmentDetailView
,
AssignmentAddView
,
AssignmentEditView
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
''
,
Assignments
,
name
=
"assignments"
),
path
(
'<int:pk>/details/'
,
AssignmentDetailView
.
as_view
(),
name
=
'assignment-details'
),
path
(
'add/'
,
AssignmentAddView
.
as_view
(),
name
=
'assignment-add'
),
path
(
'<int:pk>/edit/'
,
AssignmentEditView
.
as_view
(),
name
=
'assignment-edit'
),
]
app_name
=
"assignments"
\ No newline at end of file
app_name
=
'assignments'
widget_OhMyBash/assignments/views.py
View file @
7eba6986
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
from
django.views.generic.edit
import
UpdateView
from
.models
import
Assignment
def
index
(
request
):
return_string
=
"<p>Widget's Assignment Page</p>"
for
a
in
Assignment
.
objects
.
all
():
return_string
+=
'''Assignment Name: {} <br>Description: {}
<br>Perfect Score: {} <br>Passing Score: {}
<br>Course/Section: {} {}-{}<br><br>'''
.
format
(
a
.
assignment_name
,
a
.
description
,
a
.
perfect_score
,
int
(
a
.
perfect_score
*
0.60
),
a
.
course
.
code
,
a
.
course
.
title
,
a
.
course
.
section
,
)
html_string
=
'<html><body>{}</body></html>'
.
format
(
return_string
)
return
HttpResponse
(
html_string
)
def
Assignments
(
request
):
assignments
=
Assignment
.
objects
.
all
()
dict_assignments
=
{
'assignments'
:
assignments
,
}
return
render
(
request
,
'assignments/assignments.html'
,
dict_assignments
)
class
AssignmentDetailView
(
DetailView
):
model
=
Assignment
template_name
=
'assignments/assignment-details.html'
class
AssignmentAddView
(
CreateView
):
model
=
Assignment
fields
=
'__all__'
template_name
=
'assignments/assignment-add.html'
class
AssignmentEditView
(
UpdateView
):
model
=
Assignment
fields
=
'__all__'
template_name
=
'assignments/assignment-edit.html'
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