Commit f6fd0c33 authored by Chester Tan's avatar Chester Tan

converted FBVs to CBVs

edited AssignmentListView template format
created AssignmentDetailView class
added base.html to templates
created static folder for static files
parent 2e2e6333
<ul>
<ul>
<li>
{{object.course.course_code}} {{object.course.course_title}} {{object.course.section}}
</li>
</ul>
<li>{{object.name}}</li>
<li>{{object.description}}</li>
<li>{{object.max_points}}</li>
<li>{{object.passing_score}}</li>
{% load static %}
<li><img src="{% static 'assignments/chesterC.png' %}" alt="image"></li>
</ul>
<h1>ASSIGNMENTS: </h1>
{% for assignment in assignments %}
<p>Assignment Name: {{assignment.name}}</p>
<p>Description: {{assignment.description}}</p>
<p>Perfect Score: {{assignment.max_points}}</p>
<p>Passing Score: {{assignment.passing_score}}</p>
<p>Course/Section: {{assignment.course.course_code}} {{assignment.course.course_title}} {{assignment.course.section}}</p><br>
{% endfor %}
\ No newline at end of file
{% extends 'base.html' %}
{% block content %}
<h1>Assignmets Per Course </h1>
<label>List of Courses:</label>
<ul>
{% for course in object_list %}
<li>{{course.course_code}} {{course.course_title}} {{course.section}}</li>
<ul>
{% for assignment in course.assignment.all %}
<li>
<a href="{% url 'assignment-detail' assignment.id %}">{{assignment}}</a>
</li>
{% endfor %}
</ul>
{% endfor %}
</ul>
{% endblock content %}
\ No newline at end of file
from django.urls import path
from .views import assignments
from .views import assignments, AssignmentDetailView, AssignmentListView
urlpatterns = [
path('', assignments, name='assignments')
path('', AssignmentListView.as_view(), name='assignments'),
path('<int:pk>/details/', AssignmentDetailView.as_view(), name='assignment-detail'),
]
\ No newline at end of file
from django.shortcuts import render
from .models import Assignment
from .models import Assignment, Course
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
def assignments(request):
assignments_context = Assignment.objects.all()
context = {'assignments':assignments_context
courses = Course.objects.order_by('course_code')
context = {
'assignments':assignments_context,
'courses':courses,
}
return render(request, 'assignments/assignments.html', context)
class AssignmentListView(ListView):
model = Course
class AssignmentDetailView(DetailView):
model = Assignment
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Francoconuts Widget</title>
</head>
<body>
<h1>WIDGET</h1>
<hr></hr>
{% block content %}
{% endblock content %}
</body>
</html>
\ No newline at end of file
......@@ -125,7 +125,11 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = 'static/'
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
......
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