Commit 9599c99a authored by Ramon Angelo Enriquez's avatar Ramon Angelo Enriquez

Added changes to Homepage app, in particular: (1) Added picture field to...

Added changes to Homepage app, in particular: (1) Added picture field to homepage model, (2) Added homepage/details page, (3) Added CSS to both homepage and homepage/details.
parents bba2fb18 869f6349
widget_tee_jays_angelos/homepage/__pycache__/
widget_tee_jays_angelos/homepage/migrations/__pycache__/
widget_tee_jays_angelos/announcements/__pycache__/
widget_tee_jays_angelos/announcements/migrations/__pycache__/
widget_tee_jays_angelos/forum/__pycache__/
widget_tee_jays_angelos/forum/migrations/__pycache__/
widget_tee_jays_angelos/assignments/__pycache__/
widget_tee_jays_angelos/assignments/migrations/__pycache__/
*/__pycache__/*
\ No newline at end of file
h1 {
color: blue;
font-weight: bold;
}
ul li {
text-decoration: underline;
}
li {
padding-bottom: 20px;
}
.bold{
font-weight: bold;
color: red;
font-size: 20px;
}
.small{
font-weight: normal
color: black;
font-size: 17px;
}
{% extends 'base.html' %}
{% block head %}
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'assignments/style.css' %}">
{% endblock %}
{% block content %}
<h1> {{course}} {{course.course_title}}</h1>
<li class = "bold"> Name: {{assignment.name}} </li>
<li> Description: {{assignment.description}} </li>
<li> Perfect Score: {{assignment.max_points}} </li>
<li> Passing Score: {{assignment.passing_score}} </li>
<img src= "/static/assignments/{{assignment.name}}.jpg">
{% endblock %}
{% extends 'base.html' %}
{% block head %}
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'assignments/style.css' %}">
{% endblock %}
{% block content %}
<h1> Assignments Per Course </h1>
{% if course_list %}
{% for course in course_list %}
<li class = "bold"> {{course}} {{course.course_title}} {{course.section}}
{% for assignment in assignment_list %}
{% if assignment.course_code == course %}
<ul class = "small">
<li> <a href="/assignments/{{assignment.name}}/">{{assignment.name}}</a></li>
</ul>
{% endif %}
{% endfor %}
</li>
{% endfor %}
{% else %}
<p>No assignments are available </p>
{% endif %}
{% endblock %}
...@@ -3,5 +3,6 @@ from django.urls import path ...@@ -3,5 +3,6 @@ from django.urls import path
from . import views from . import views
urlpatterns = [ urlpatterns = [
path('', views.index, name="assignments") path('', views.index, name="assignments"),
path("<str:name>/", views.detail, name = "details"),
] ]
from django.http import HttpResponse from django.http import HttpResponse, Http404
from assignments.models import Assignment, Course from assignments.models import Assignment, Course
from django.shortcuts import render
from django.template import loader
# Create your views here. # Create your views here.
def index(request): def index(request):
assignmentOutput = "Assignments: <br/><br/>" course_list = Course.objects.order_by("course_code")
for n in Assignment.objects.all(): assignment_list = Assignment.objects.all()
assignmentOutput += ("Assignment Name: " + str(n.name) + "<br/>") template = loader.get_template("assignments/index.html")
assignmentOutput += ("Description: " + n.description + "<br/>") context = {
assignmentOutput += ("Perfect Score: " + str(n.max_points) + "<br/>") "course_list": course_list,
assignmentOutput += ("Passing Score: " + str(n.passing_score) + "<br/>") "assignment_list": assignment_list
assignmentOutput += ("Course/Section: " + Course.objects.get(course_code = n.course_code).course_code + " ") }
assignmentOutput += (Course.objects.get(course_code = n.course_code).course_title + " ") return HttpResponse(template.render(context, request))
assignmentOutput += (Course.objects.get(course_code = n.course_code).section + "<br/><br/>")
return HttpResponse(assignmentOutput) def detail(request, name):
try:
assignment = Assignment.objects.get(name = name)
course = Course.objects.get(course_code = assignment.course_code)
except Assignment.DoesNotExist:
raise Http404("Assignment does not exist!")
template = loader.get_template("assignments/detail.html")
context = {
"assignment": assignment,
"course": course
}
return HttpResponse (template.render(context, request))
{% 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, inital-scale=1.0">
{% block head %}
{% endblock %}
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
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