Commit 791103a2 authored by Nate Brevin A. Que's avatar Nate Brevin A. Que

Implemented the 'Add New Assignment Page'

parent 99e2be94
{% extends 'base.html' %}
{% block title %}Add Assigment{% endblock %}
{% block content %}
<form action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save New Assigment">
</form>
{% endblock %}
{% block scripts %}
{% endblock %}
\ No newline at end of file
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</h3> </h3>
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<input type="submit" value="New Assignment"><br><br> <a href="/assignments/add"><input type="submit" value="New Assignment"></a><br><br>
<a href="/dashboard">Dashboard</a><br> <a href="/dashboard">Dashboard</a><br>
<a href="/announcement">Announcements</a><br> <a href="/announcement">Announcements</a><br>
<a href="/forum">Forum</a><br> <a href="/forum">Forum</a><br>
......
from django.contrib import admin from django.contrib import admin
from django.urls import path from django.urls import path
from .views import index, AssignmentDetailView from .views import index, AssignmentDetailView, AssignmentCreateView
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('', index, name='index'),
path('<int:pk>/details', AssignmentDetailView.as_view(), name='assignment-details'), path('<int:pk>/details', AssignmentDetailView.as_view(), name='assignment-details'),
path('add/', AssignmentCreateView.as_view(), name='add-assignment'),
] ]
app_name = "assignments" app_name = "assignments"
\ No newline at end of file
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.edit import CreateView
from .models import Assignment from .models import Assignment
...@@ -12,4 +13,10 @@ class AssignmentDetailView(DetailView): ...@@ -12,4 +13,10 @@ class AssignmentDetailView(DetailView):
model = Assignment model = Assignment
def get(self, request, pk): def get(self, request, pk):
return render(request, 'assignments/assignment-details.html', {'assignment': self.model.objects.get(pk=pk)}) return render(request, 'assignments/assignment-details.html', {'assignment': self.model.objects.get(pk=pk)})
\ No newline at end of file
class AssignmentCreateView(CreateView):
model = Assignment
fields = '__all__'
template_name = 'assignments/assignment-add.html'
\ 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