Added template system.
This commit is contained in:
parent
552a1a526f
commit
e22ae60e92
|
@ -18,10 +18,17 @@ from django.urls import re_path,path,include
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from django.contrib.staticfiles.views import serve
|
from django.contrib.staticfiles.views import serve
|
||||||
from django.views.generic import RedirectView
|
from django.views.generic import RedirectView
|
||||||
|
from postings import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# / routes to index.html
|
# / routes to index.html
|
||||||
url(r'^$', serve, kwargs={'path': 'index.html'}),
|
path('', views.index, name='homepage'),
|
||||||
|
|
||||||
|
# /universities routes to a list of universities.
|
||||||
|
path('universities', views.universities, name='universities_list'),
|
||||||
|
|
||||||
|
# /courses routes to a list of courses.
|
||||||
|
path('courses', views.courses, name='courses_list'),
|
||||||
|
|
||||||
# static files (*.css, *.js, *.jpg etc.) served on /
|
# static files (*.css, *.js, *.jpg etc.) served on /
|
||||||
# (assuming Django uses /static/ and /media/ for static/media urls)
|
# (assuming Django uses /static/ and /media/ for static/media urls)
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,16 @@
|
||||||
|
{% extends "postings/generic_page.html" %}
|
||||||
|
|
||||||
|
{# Represents a generic collection of entities. #}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{% for entity in entities %}
|
||||||
|
<li>
|
||||||
|
{% block entity %}
|
||||||
|
{% endblock %}
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,12 @@
|
||||||
|
{% extends "postings/collections/collection.html" %}
|
||||||
|
|
||||||
|
{# Represents a list of university entities. #}
|
||||||
|
|
||||||
|
{% block entity %}
|
||||||
|
<b>{{ entity.name }}</b>, University:<i> {{ entity.taught_at_university.name}}</i><br>
|
||||||
|
<ul>
|
||||||
|
{% for professor in entity.professors.all %}
|
||||||
|
<li>{{ professor.name }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{% extends "postings/collections/collection.html" %}
|
||||||
|
|
||||||
|
{# Represents a list of university entities. #}
|
||||||
|
|
||||||
|
{% block entity %}
|
||||||
|
<b>{{ entity.name }}</b>
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,23 @@
|
||||||
|
{# This page represents the base template that all others will extend from. #}
|
||||||
|
{# It will contain a universal navigation bar, script tags, footers, and other things needed on every page. #}
|
||||||
|
|
||||||
|
<!doctype HTML>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>
|
||||||
|
{% block title %}RateMyCourse{% endblock %}</title>
|
||||||
|
</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div style="width: 100%; text-align: center; background-color: gray;">
|
||||||
|
<h1>RateMyCourse</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{# All of a page's content to display should be placed in here. #}
|
||||||
|
<div id="content">
|
||||||
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,17 @@
|
||||||
|
{% extends "postings/generic_page.html" %}
|
||||||
|
|
||||||
|
{# The homepage for the website. #}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<p>
|
||||||
|
Click one of the links below to view a list of all those entities.
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="/universities">Universities</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="/courses">Courses</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
|
@ -1,3 +1,19 @@
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from postings.models import *
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
|
# The view for the homepage, or index.html
|
||||||
|
def index(request):
|
||||||
|
return render(request, 'postings/index.html')
|
||||||
|
|
||||||
|
def universities(request):
|
||||||
|
universities_list = University.objects.all()
|
||||||
|
context = {'entities': universities_list}
|
||||||
|
return render(request, 'postings/collections/universities.html', context)
|
||||||
|
|
||||||
|
def courses(request):
|
||||||
|
courses_list = Course.objects.all()
|
||||||
|
context = {'entities': courses_list}
|
||||||
|
return render(request, 'postings/collections/courses.html', context)
|
Loading…
Reference in New Issue