diff --git a/backend/RateMyCourse/urls.py b/backend/RateMyCourse/urls.py index 9cbc84d..dae6471 100644 --- a/backend/RateMyCourse/urls.py +++ b/backend/RateMyCourse/urls.py @@ -18,10 +18,17 @@ from django.urls import re_path,path,include from django.conf.urls import url from django.contrib.staticfiles.views import serve from django.views.generic import RedirectView +from postings import views urlpatterns = [ # / 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 / # (assuming Django uses /static/ and /media/ for static/media urls) diff --git a/backend/db.sqlite3 b/backend/db.sqlite3 index 359edf3..e236f72 100644 Binary files a/backend/db.sqlite3 and b/backend/db.sqlite3 differ diff --git a/backend/postings/templates/postings/collections/collection.html b/backend/postings/templates/postings/collections/collection.html new file mode 100644 index 0000000..37d3f2d --- /dev/null +++ b/backend/postings/templates/postings/collections/collection.html @@ -0,0 +1,16 @@ +{% extends "postings/generic_page.html" %} + +{# Represents a generic collection of entities. #} + +{% block content %} + + + +{% endblock %} \ No newline at end of file diff --git a/backend/postings/templates/postings/collections/courses.html b/backend/postings/templates/postings/collections/courses.html new file mode 100644 index 0000000..4805231 --- /dev/null +++ b/backend/postings/templates/postings/collections/courses.html @@ -0,0 +1,12 @@ +{% extends "postings/collections/collection.html" %} + +{# Represents a list of university entities. #} + +{% block entity %} + {{ entity.name }}, University: {{ entity.taught_at_university.name}}
+ +{% endblock %} \ No newline at end of file diff --git a/backend/postings/templates/postings/collections/universities.html b/backend/postings/templates/postings/collections/universities.html new file mode 100644 index 0000000..6f392e1 --- /dev/null +++ b/backend/postings/templates/postings/collections/universities.html @@ -0,0 +1,7 @@ +{% extends "postings/collections/collection.html" %} + +{# Represents a list of university entities. #} + +{% block entity %} + {{ entity.name }} +{% endblock %} \ No newline at end of file diff --git a/backend/postings/templates/postings/generic_page.html b/backend/postings/templates/postings/generic_page.html new file mode 100644 index 0000000..9f8d23a --- /dev/null +++ b/backend/postings/templates/postings/generic_page.html @@ -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. #} + + + + + + {% block title %}RateMyCourse{% endblock %} + + + + +
+

RateMyCourse

+
+ + {# All of a page's content to display should be placed in here. #} +
+ {% block content %} + {% endblock %} +
+ + \ No newline at end of file diff --git a/backend/postings/templates/postings/index.html b/backend/postings/templates/postings/index.html new file mode 100644 index 0000000..d26bf17 --- /dev/null +++ b/backend/postings/templates/postings/index.html @@ -0,0 +1,17 @@ +{% extends "postings/generic_page.html" %} + +{# The homepage for the website. #} + +{% block content %} +

+ Click one of the links below to view a list of all those entities. +

+ +{% endblock %} \ No newline at end of file diff --git a/backend/postings/views.py b/backend/postings/views.py index 91ea44a..19b0baa 100644 --- a/backend/postings/views.py +++ b/backend/postings/views.py @@ -1,3 +1,19 @@ from django.shortcuts import render +from django.http import HttpResponse +from postings.models import * # 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) \ No newline at end of file