Commit 7b4fc362 authored by Albert Gagalac's avatar Albert Gagalac

implemented assignment-add.html features

parent 6c4e976c
from django.db import models
from django.urls import reverse
from django.core.validators import RegexValidator
# Create your models here.
......@@ -24,6 +25,9 @@ class Assignment(models.Model):
course = models.ForeignKey(Course, on_delete=models.CASCADE)
perfect_score = models.PositiveIntegerField(default=0)
def get_absolute_url(self):
return reverse('assignments:assignment-details', kwargs={'pk' : self.pk})
def __str__(self):
return self.name
......
{% extends 'base.html' %}
{% load static %}
{% block title %} Add Assignment {% endblock %}
{% block content %}
<h2>Add a new Assignment:</h2>
<p>
<form action='' method="POST">
{% csrf_token %}
Name: {{form.name}}<br><br>
Description: <br> {{form.description}}<br><br>
Course: {{form.course}}<br><br>
Perfect Score: {{form.perfect_score}}<br><br>
<input type="submit" value="Add Assignment">
</form>
</p>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} Widget's Assignments {% endblock %}
{% block content %}
<h2>{{assignment.name}}</h2>
<h3>{{assignment.course}}</h3>
<h2> Welcome to Widget's Assignments! </h2>
{% for data in assignment %}
<p>
Description: {{data.description}}<br>
Perfect Score: {{data.perfect_score}}<br>
Passing Score: {{data.passing_score}}<br>
</p>
<p> <a href="{{ data.get_absolute_url }}">{{ data }}</a></p>
{% endfor %}
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import pageview, AssignmentDetailView
from .views import pageview, AssignmentDetailView, AssignmentCreateView
urlpatterns = [
path('', pageview, name='pageview'),
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='assignment-add'),
]
app_name = "assignments"
\ No newline at end of file
......@@ -15,3 +15,9 @@ class AssignmentDetailView(DetailView):
course = assignment.course
return render(request, 'assignments/assignment-details.html', {'assignment': assignment, 'course': course})
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