Commit 87fe8fad authored by Daniel W Bond's avatar Daniel W Bond

minor template cleaning

parent 63ca4da3
......@@ -22,6 +22,7 @@ class LandingPage(LoginRequiredMixin, TemplateView):
def get_context_data(self, **kwargs):
context = super(LandingPage, self).get_context_data(**kwargs)
me = Student.objects.get(user=self.request.user)
context['me'] = me
# Create Dictionaries to store Students that meet criteria
context["roomies"] = Student.objects.filter(room=me.room).exclude(user__username=me)
......@@ -29,13 +30,13 @@ class LandingPage(LoginRequiredMixin, TemplateView):
context["majormates"] = Student.objects.filter(major=me.major).exclude(user__username=me).order_by('?')[:8]
# Hack to Correctly Display Building plus Floor
floor = str(me.get_floor())
if floor[len(floor)-1:len(floor)] == "1":
context["home"] = "%s %s" %(me.get_building(), 'First')
elif floor[len(floor)-1:len(floor)] == "2":
context["home"] = "%s %s" %(me.get_building(), 'Second')
else:
context["home"] = "%s %s" %(me.get_building(), 'Third')
#floor = str(me.get_floor())
#if floor[len(floor)-1:len(floor)] == "1":
# context["home"] = "%s %s" %(me.get_building(), 'First')
#elif floor[len(floor)-1:len(floor)] == "2":
# context["home"] = "%s %s" %(me.get_building(), 'Second')
#else:
# context["home"] = "%s %s" %(me.get_building(), 'Third')
return context
......
......@@ -6,10 +6,10 @@
{% cache 300 roommates request.user.username %}
{% if roomies|length == 1 %}
<h3>Your Roommate in {{ request.user.student.room }}</h3>
<h3>Your Roommate in {{ me.room }}</h3>
<legend></legend>
{% else %}
<h3>Your Roommates in {{ request.user.student.room }}</h3>
<h3>Your Roommates in <a href="{{ me.room.get_absolute_url }}">{{ me.room }}</a></h3>
<legend></legend>
{% endif %}
<div class="text-center">
......@@ -17,7 +17,8 @@
{% for student in roomies %}
<div class="col-md-3">
<a href="{{ student.get_absolute_url }}"><img class="img-circle img-responsive center center-block" src="{% gravatar_url student.user.email 100 %}" alt="{{ student.user.first_name }} Gravatar picture"></img></a>
<h4>{{ student.user.first_name }} {{ student.user.last_name }}</h4>
<h4>{{ student.user.get_full_name }}</h4>
<h5><a href="{{ student.major.get_absolute_url }}"><em>{{ student.major }}</em></a></h5>
</div>
{% empty %}
<h4>There are no other students registered in your room right now.</h4>
......@@ -26,8 +27,10 @@
</div>
{% endcache %}
{% load humanize %}
{% cache 300 floormates request.user.username %}
<h3>Your Floormates from {{ home }}</h3>
<h3>Your Floormates from <a href="{{ me.room.floor.get_absolute_url }}">{{ me.room.floor.building }} {{ me.room.floor.number|ordinal }}</a></h3>
<legend></legend>
<div class="text-center">
<div class="row">
......@@ -35,7 +38,8 @@
<div class="col-md-3">
<a href="{{ student.get_absolute_url }}"><img class="img-circle img-responsive center center-block" src="{% gravatar_url student.user.email 100 %}" alt="{{ student.user.first_name }} Gravatar picture"></a>
<h4>{{ student.user.first_name }} {{ student.user.last_name }}</h4>
<a href="{{ student.room.get_absolute_url }}"><h4>{{ student.room }}</h4></a>
<h5><a href="{{ student.major.get_absolute_url }}"><em>{{ student.major }}</em></a></h5>
<h5><a href="{{ student.room.get_absolute_url }}">{{ student.room }}</h5></a>
</div>
{% empty %}
<h4>There are no other students registered on your floor right now.</h4>
......@@ -45,7 +49,7 @@
{% endcache %}
{% cache 600 majormates request.user.username %}
<h3>Other Students in <a href="{{ request.user.student.major.get_absolute_url }}">{{ request.user.student.major }}</a></h3>
<h3>Other Students in <a href="{{ me.major.get_absolute_url }}">{{ me.major.name }}</a></h3>
<legend></legend>
<div class="text-center">
<div class="row">
......
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