Add option for user to add new assignment

parent 408687f5
{% extends 'base.html' %}
{% load static %}
{% block styles %}
<link rel="stylesheet" type="text/css" href="{% static 'assignments/style.css' %}">
{% endblock %}
{% block title %}New Assignment{% endblock %}
{% block content %}
<h1>New Assignment</h1>
<div>
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
Assignment name: {{ form.name }}<br>
Description: <br>{{ form.description }}<br>
Max points: {{ form.max_points }}<br>
Course Code/Course Title/Section: {{ form.course }}<br>
Image: {{ form.assignment_image}}<br>
<input type="submit" value="Save Assignment">
</form>
</div>
{% endblock %}
\ No newline at end of file
......@@ -21,11 +21,14 @@
</ul>
{% endif %}
{% endfor %}
<br><br>
<br>
{% endfor %}
</ul>
{% else %}
<p>There are no assignments under any course.</p>
{% endif %}
<a href="{% url 'assignments:addAssignment' %}">
<button>New Assignment</button>
</a>
</div>
{% endblock %}
\ No newline at end of file
from django.urls import path
from . import views
app_name="assignments"
urlpatterns = [
path('', views.index, name="indexAssignments"),
path('<int:assignment_id>/details', views.details, name="details")
path('<int:assignment_id>/details', views.details, name="details"),
path('add', views.addAssignment.as_view(), name="addAssignment"),
]
\ No newline at end of file
from ast import Assign
from django.http import HttpResponse, Http404
from django.http import Http404
from django.shortcuts import render
from .models import Assignment, Course
from django.views.generic import CreateView
# Create your views here.
def index(request):
......@@ -21,4 +20,9 @@ def details(request, assignment_id):
except Assignment.DoesNotExist:
raise Http404("Assignment does not exist!")
return render(request, "assignments/detail.html", {"assignment": assignment})
\ No newline at end of file
return render(request, "assignments/detail.html", {"assignment": assignment})
class addAssignment(CreateView):
model = Assignment
template_name = "assignments/add.html"
fields = ['name', 'description', 'max_points', 'course', 'assignment_image']
\ No newline at end of file
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