Commit aeb3a963 authored by rachbit's avatar rachbit

created assignment-add and assignment-edit

parent ab553878
......@@ -8,7 +8,7 @@ class Course(models.Model):
section = models.CharField(max_length=3)
def __str__(self):
return '{}'.format(self.code)
return '{} - {}'.format(self.code, self.section)
class Assignment(models.Model):
......
{% extends 'base.html' %}
{% load static %}
{% block title %} Add Assignment {% endblock %}
{% block content %}
<h1>Add Assignment:</h1>
<form method="post">
{% csrf_token %}
{{form.as_p}}
<input type="submit" value="Save New Assignment">
</form>
<br>
{% endblock %}
......@@ -16,7 +16,7 @@
</div>
<br>
<a href="../#/">
<a href="edit">
<button type="button"><p>Edit Assignment</p></button>
</a>
{% endblock %}
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Assignment {% endblock %}
{% block content %}
<h1>Edit Assignment:</h1>
<form method="post">
{% csrf_token %}
{{form.as_p}}
<input type="submit" value="Save Changes to Assignment">
</form>
<br>
{% endblock %}
......@@ -17,7 +17,7 @@
{% endfor %}
<br><br>
<a href="#">
<a href="add">
<button type="button"><p>New Assignment</p></button>
</a>
......
......@@ -4,6 +4,8 @@ from .views import *
urlpatterns = [
path('', index, name='index'),
path('<int:pk>/details', AssignmentsDetailView.as_view(), name='assignment-details'),
path('<int:pk>/edit', AssignmentsUpdateView.as_view(), name='assignment-edit'),
path('add', AssignmentsCreateView.as_view(), name='assignment-add'),
]
# This might be needed, depending on your Django version
......
......@@ -15,3 +15,13 @@ class AssignmentsView(ListView):
class AssignmentsDetailView(DetailView):
model = Assignment
template_name = 'assignments/assignment-details.html'
class AssignmentsUpdateView(UpdateView):
model = Assignment
fields = "__all__"
template_name = 'assignments/assignment-edit.html'
class AssignmentsCreateView(CreateView):
model = Assignment
fields = "__all__"
template_name = 'assignments/assignment-add.html'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment