Commit 1ec662ae authored by Deokhyun Lee's avatar Deokhyun Lee

added Assignments page for FBV

parent 6902d76f
No preview for this file type
{% extends 'base.html'%}
{% block title %}
Widget's Assignments
{% endblock %}
{% block content %}
<h1>Welcome to Widget's Assignments!</h1>
{% if assignments %}
<ul>
{% for assignment in assignments %}
<a href={{assignment.id}}/details>{{ assignment.name }}</a><br>
{% endfor %}
</ul>
{% else %}
<p>No Available Assignments.</p>
{% endif %}
<li><button type="button" onclick="window.location.href='/books/add'">New Assignments</button></li>
<li><a href="/dashboard">Dashboard</a></li>
<li><a href="/announcements">Announcements</a></li>
<li><a href="/forum">Forum</a></li>
<li><a href="/calendar">Calendar</a></li>
{% endblock %}
\ No newline at end of file
......@@ -3,5 +3,5 @@ from . import views
# url for assignments
urlpatterns = [
path('', views.assignmentIndex, name='assignmentIndex'),
path('', views.assignments_view, name='assignment'),
]
\ No newline at end of file
from django.http import HttpResponse
from django.shortcuts import render
from .models import Assignment
# assignment view from .models
def assignmentIndex(request):
title = "Widget's Assignments Page" + "<br><br>"
assignments = Assignment.objects.all()
output_view = ""
for assignment in assignments:
name = "Assignment Name: " + assignment.name + "<br>"
description = "Description: " + assignment.description + "<br>"
perfect_score = "Perfect Score: " + str(assignment.perfect_score) + "<br>"
passing_score = "Passing Score: " + str(assignment.passing_score) + "<br>"
course_section = "Course/Section: " + assignment.course.code + " " + assignment.course.title + "-" + assignment.course.section + "<br><br>"
output_view = output_view + name + description + perfect_score + passing_score + course_section
return HttpResponse(title + output_view)
\ No newline at end of file
# assignment view for FBV implementation.
def assignments_view(request):
assignments = Assignment.objects.all().order_by('id')
return render(request, 'assignments.html', {'assignments': assignments})
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
{% load static %}
<link rel="stylesheet" href="{% static 'styles.css' %}">
<title>{% block title %}{% endblock %}</title>
</head>
<body>
<div class="container">
{% block content %}{% endblock %}
</div>
</body>
</html>
\ No newline at end of file
......@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/4.1/ref/settings/
"""
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
......@@ -60,15 +61,15 @@ ROOT_URLCONF = "widget_aguandhischipmunks.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
......
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