Commit 793f6929 authored by Jeremy Factor's avatar Jeremy Factor

Add migration files for model updates

parent 45d99d3f
# Generated by Django 3.2.12 on 2022-05-26 11:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0002_auto_20220408_0659'),
]
operations = [
migrations.AddField(
model_name='assignment',
name='image',
field=models.FileField(blank=True, null=True, upload_to='static/assignments/'),
),
]
...@@ -5,8 +5,8 @@ class Assignment(models.Model): ...@@ -5,8 +5,8 @@ class Assignment(models.Model):
name = models.CharField(max_length = 50) name = models.CharField(max_length = 50)
description = models.CharField(max_length = 500) description = models.CharField(max_length = 500)
max_points = models.IntegerField(default = 0) max_points = models.IntegerField(default = 0)
passing_score = models.IntegerField(default = 0) passing_score = models.IntegerField(default = 0)
image = models.FileField(upload_to='static/assignments/', blank=True, null=True)
def __str__(self): def __str__(self):
return self.name return self.name
......
* {
font-family:Courier New;
}
h1 {
color: #73436D;
font-weight: bold;
}
h3{
color:#B67C9A
}
img {
float: left;
width: 500px;
height: 500px;
object-fit: cover;
border-radius: 10px;
}
p{
color: #2a384d;
}
body {
background-color: #E5E6E9;
padding: 1% 0 0 2%;
}
a {
color:black;
text-decoration: none;
}
a:visited {
color:hotpink;
}
a:hover {
color: #73436D;
}
\ No newline at end of file
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href ={% static 'assignments/style.css' %}>
<title>Project Jupert</title>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
\ No newline at end of file
{% extends "assignments/base.html" %}
{% block content %}
{% for course in course_list2 %}
{% if course.assignment.name == assignments.name %}
<p>{{ course.course_code }} {{ course.course_title }} {{ course.section }}</p>
<p> Assignment name: {{ assignments.name }}</p>
<p> Description: {{ assignments.description }}</p>
<p> Perfect score: {{ assignments.max_points }}</p>
<p> Passing score: {{ assignments.passing_score }}</p>
{% endif %}
{% endfor %}
<img src = {{assignments.image.url}}>
{% endblock %}
\ No newline at end of file
{% extends "assignments/base.html" %}
{% block content %}
<h1>Assignments Per Course</h1>
<h3>List of courses:</h3>
{% if assignment_list %}
<ul>
{% for course in course_list1 %}
<li> <b> {{ course.course_code }} {{ course.course_title }} {{ course.section }} </b> </li>
<ul>
{% for assignment in assignment_list %}
{% if course.assignment.name == assignment.name %}
<li><a href = "{% url 'assignments:details' assignment.id %}"> {{ assignment.name }} </a></li>
{% endif %}
{% endfor %}
</ul>
{% endfor %}
{% else %}
<p>No assignments are available.</p>
{% endif %}
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from django.conf.urls.static import static
from django.conf import settings
from . import views from . import views
app_name = "assignments"
urlpatterns = [ urlpatterns = [
path('', views.index, name='index') path('', views.index, name='index'),
]
\ No newline at end of file #assignments/1/details/
path("<int:assignment_id>/details/", views.details, name="details"),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
from django.http import HttpResponse from urllib import response
from django.http import HttpResponse, Http404
from django.shortcuts import render
from assignments.models import Assignment from assignments.models import Assignment
from assignments.models import Course from assignments.models import Course
# Create your views here. # Create your views here.
def index(request): def index(request):
assignment_objects = Assignment.objects.all()
assignment_list = Assignment.objects.order_by("name")
course_list1 = Course.objects.order_by("course_code")
context = {
"assignment_list": assignment_list,
"course_list1": course_list1
}
return render(request, "assignments/index.html", context)
def details(request, assignment_id):
course_list2 = Course.objects.order_by("course_code")
#error handling
try:
assignments = Assignment.objects.get(pk=assignment_id)
except Assignment.DoesNotExist:
raise Http404("Assignment does not exist.")
return render(request, "assignments/details.html", {"assignments":assignments, 'course_list2':course_list2})
"""assignment_objects = Assignment.objects.all()
course_objects = Course.objects.all() course_objects = Course.objects.all()
response = "ASSIGNMENTS:<br>" response = "ASSIGNMENTS:<br>"
...@@ -21,4 +46,4 @@ def index(request): ...@@ -21,4 +46,4 @@ def index(request):
response = (response + "Course/Section: " + response = (response + "Course/Section: " +
f"{course.course_code} {course.course_title} {course.section} <br>") f"{course.course_code} {course.course_title} {course.section} <br>")
return HttpResponse(response) return HttpResponse(response)"""
\ No newline at end of file \ 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