From 6403bbb2f0bdf8b47f98b96ef3bc993cf499a7ed Mon Sep 17 00:00:00 2001 From: Daniel W Bond Date: Tue, 4 Oct 2016 19:11:17 -0400 Subject: [PATCH] multiple majors are now shown on the homepage... done with displaying majors, now need to work on the two forms --- roomlist/settings/views.py | 7 ++++++- roomlist/templates/landing.html | 14 +++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/roomlist/settings/views.py b/roomlist/settings/views.py index 9fdfe2a..d10e317 100644 --- a/roomlist/settings/views.py +++ b/roomlist/settings/views.py @@ -29,7 +29,12 @@ class LandingPage(LoginRequiredMixin, TemplateView): # Create Dictionaries to store Students that meet criteria context["roomies"] = Student.objects.filter(room=me.room).exclude(user__username=me) context["floories"] = Student.objects.filter(room__floor=me.get_floor()).exclude(user__username=me).exclude(room=me.room).order_by('room') - context["majormates"] = Student.objects.filter(major=me.major).exclude(user__username=me).order_by('?')[:8] + + my_majors = tuple(me.major.all()) + students_by_major = {} + for major in my_majors: + students_by_major[major] = Student.objects.filter(major__in=[major]).exclude(user__username=me).order_by('?')[:8] + context["majormates"] = students_by_major return context diff --git a/roomlist/templates/landing.html b/roomlist/templates/landing.html index 710a9fd..030a9c8 100644 --- a/roomlist/templates/landing.html +++ b/roomlist/templates/landing.html @@ -19,7 +19,7 @@ Back {% if me.on_campus %} -{% if not me.room %} +{% if not me.room and me.on_campus %}

Select your room, and we'll show you the other students on your floor.

{% else %} @@ -79,14 +79,14 @@ Back {% cache 120 landing_majors request.user.username %} -{% if not me.major %} +{% if not me.major.all %}

Set your major, and we'll show you some of the other students in your program.

{% else %} - -

Other Students in {{ me.major.name }}

- + {% for major, students in majormates.items %} +

Other Students in {{ major.name }}

+
- {% for student in majormates %} + {% for student in students %}
{{ student.get_first_name_or_uname }} profile picture

{{ student.get_full_name_or_uname }}

@@ -102,7 +102,7 @@ Back
{% endfor %}
- + {% endfor %} {% endif %} {% endcache %} -- GitLab