Commit bac6df9e authored by Nate Brevin A. Que's avatar Nate Brevin A. Que

Merge branch 'assignmentsv2' into 'master'

Assignmentsv2

See merge request !10
parents 4d36ecb3 1fa802ca
SECRET_KEY = 'django-insecure-0ne3r+4_-4wxim9e1!jkyw8%fnii1af4pc$irxf%nvrs3wp*1f'
\ No newline at end of file
from django.db import models
from django.urls import reverse
class Course(models.Model):
......@@ -24,6 +25,9 @@ class Assignment(models.Model):
Course/Section: {}<br>""".format(self.name, self.description, self.perfect_score,
self.passing_score, self.course)
def get_absolute_url(self):
return reverse('assignments:assignment-details', kwargs={'pk':self.pk})
@property
def passing_score(self):
return round(self.perfect_score*6/10)
\ No newline at end of file
{% 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
{% extends 'base.html' %}
{% block title %}{{ assignment.name }}{% endblock %}
{% block content %}
<h1>{{ assignment.name }}</h1>
<h3>{{ assignment.course}}<br>
Description: {{ assignment.description }}<br>
Perfect Score: {{ assignment.perfect_score }}<br>
Passing Score: {{ assignment.passing_score }}<br>
</h3>
{% endblock %}
{% block scripts %}
<a href="/assignments/{{ assignment.pk }}/edit"><input type="submit" value="Edit Assignment"></a>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}Edit Book{% endblock %}
{% block content %}
<form action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save Changes to Assignment">
</form>
{% endblock %}
{% block scripts %}
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}Widget's Assignments{% endblock %}
{% block content %}
<h1>Welcome to Widget's Assignments!</h1>
<h3>
{% for assignment in assignments %}
<a href="{{ assignment.get_absolute_url }}">{{ assignment.name }}</a><br>
{% endfor %}
</h3>
{% endblock %}
{% block scripts %}
<a href="/assignments/add"><input type="submit" value="New Assignment"></a><br><br>
<a href="/dashboard">Dashboard</a><br>
<a href="/announcement">Announcements</a><br>
<a href="/forum">Forum</a><br>
<a href="/calendar">Calendar</a>
{% endblock %}
\ No newline at end of file
from django.contrib import admin
from django.urls import path
from .views import index
from .views import index, AssignmentDetailView, AssignmentCreateView, AssignmentUpdateView
urlpatterns = [
path('', index, name='index'),
path('<int:pk>/details', AssignmentDetailView.as_view(), name='assignment-details'),
path('add/', AssignmentCreateView.as_view(), name='add-assignment'),
path('<int:pk>/edit', AssignmentUpdateView.as_view(), name='edit-assignment'),
]
app_name = "assignments"
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Assignment
def index(request):
page_content = "<H1>Widget's Assignments Page</H1><ul>"
for assignment in Assignment.objects.all():
page_content += "<li>{}<br>".format(assignment)
return HttpResponse(page_content)
\ No newline at end of file
return render(request, 'assignments/assignments.html', {'assignments': Assignment.objects.all()})
class AssignmentDetailView(DetailView):
model = Assignment
def get(self, request, pk):
return render(request, 'assignments/assignment-details.html', {'assignment': self.model.objects.get(pk=pk)})
class AssignmentCreateView(CreateView):
model = Assignment
fields = '__all__'
template_name = 'assignments/assignment-add.html'
class AssignmentUpdateView(UpdateView):
model = Assignment
fields = '__all__'
template_name = 'assignments/assignment-edit.html'
\ No newline at end of file
No preview for this file type
<html lang="en">
<head>
<title>{% block title %}{% endblock %}</title>
</head>
<body>
<div id="content">
{% block content %}{% endblock %}
</div>
{% block scripts %}{% endblock %}
</body>
</html>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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