Commit a4bb4095 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

Merge branch 'frontend' into 'master'

Frontend

See merge request !2
parents d3624748 c6d42c6b
......@@ -3,6 +3,7 @@ from model_utils.models import TimeStampedModel
from django.contrib.auth.models import User
from autoslug import AutoSlugField
from django.core.urlresolvers import reverse
from housing.models import Building, Room, Class
......@@ -110,5 +111,8 @@ class Student(TimeStampedModel):
return "http://www.gravatar.com/avatar/{}?s=175".format(hashlib.md5(self.user.email).hexdigest())
def get_absolute_url(self):
return reverse('detail_student', kwargs={'slug':self.slug})
def __str__(self): # __unicode__ on Python 2
return self.user.username
......@@ -9,8 +9,10 @@
</div>
<div class="col-md-6 text-center">
<h1><strong>{{ student.user.first_name }} {{ student.user.last_name }}</strong></h1>
<p class="lead"><strong>{{ student.room }}</strong></p>
<p><em>shared with</em>: <span class="label label-default">campus</span></p>
{% if shares %}
<p class="lead"><strong><a href="{{ student.room.get_absolute_url }}">{{ student.room }}</a></strong></p>
{% endif %}
<p><em>shares room with</em>: <span class="label label-default"><strong>{{ student.privacy }}</strong></span></p>
</div>
</div>
</div>
......@@ -20,7 +22,7 @@
<table class="table table-hover text-center">
<tbody>
<tr>
<td><h4><strong>Major</strong>: {{ student.major.major_name }}</h4></td>
<td><h4><strong>Major</strong>: {{ student.major.name }}</h4></td>
</tr>
<tr>
......
......@@ -11,7 +11,7 @@ urlpatterns = patterns('',
model=Student,
context_object_name='student',
template_name='detailStudent.html'),
name='detailStudent'),
name='detail_student'),
url(r'^student/$',
DetailCurrentStudent.as_view(
......
......@@ -17,13 +17,48 @@ class CreateStudent(LoginRequiredMixin, CreateView):
# details about the student
class DetailStudent(LoginRequiredMixin, DetailView):
model = Student
login_url = '/accounts/login/'
def get_context_data(self, **kwargs):
context = super(DetailStudent, self).get_context_data(**kwargs)
# requesting_student = Student.objects.get(user=self.request.user)
requesting_student_filter = Student.objects.filter(user=self.request.user)
requesting_student = requesting_student_filter[0]
def onFloor():
floor_status = False
if requesting_student.get_floor() == self.get_object().get_floor():
floor_status = True
return floor_status
def inBuilding():
floor_status = False
if requesting_student.get_building() == self.get_object().get_building():
floor_status = True
return floor_status
def shares():
student_shares = False
# if the student's privacy is floor and the requesting user is on their floor
if(self.get_object().privacy == 'floor') and onFloor():
student_shares = True
# if the student's privacy is building and the requesting users is on their floor or in their building
elif(self.get_object().privacy == 'building') and inBuilding():
student_shares = True
# if the student's privacy is set to 'student'
elif(self.get_object().privacy == 'students'):
student_shares = True
return student_shares
context['shares'] = shares()
return context
login_url = '/'
# changeable student settings
class DetailStudentSettings(LoginRequiredMixin, DetailView):
model = Student
login_url = '/accounts/login/'
login_url = '/'
class DetailCurrentStudent(LoginRequiredMixin, DetailView):
......
......@@ -3,6 +3,7 @@ from autoslug import AutoSlugField
from model_utils.models import TimeStampedModel
#from localflavor.us.models import USStateField
from django.core.urlresolvers import reverse
class Building(TimeStampedModel):
name = models.CharField(max_length=100)
......@@ -36,10 +37,16 @@ class Building(TimeStampedModel):
slug = AutoSlugField(populate_from='name', unique=True)
def get_absolute_url(self):
return reverse('detail_building', kwargs={'slug':self.slug})
def __str__(self): # __unicode__ on Python 2
return self.name
def __unicode__(self): # __unicode__ on Python 2
return unicode(self.name)
class Meta:
ordering = ['name']
class Floor(TimeStampedModel):
building = models.ForeignKey('Building')
......@@ -47,18 +54,37 @@ class Floor(TimeStampedModel):
slug = AutoSlugField(populate_from='number')
def get_absolute_url(self):
return reverse('detail_floor', kwargs={
'slug':self.slug,
'building':self.building.slug,
})
def __str__(self): # __unicode__ on Python 2
return self.building.__str__()+" "+self.number.__str__()
class Meta:
ordering = ['number']
class Room(TimeStampedModel):
number = models.IntegerField()
floor = models.ForeignKey('Floor')
slug = AutoSlugField(populate_from='number')
def get_absolute_url(self):
return reverse('detail_room', kwargs={
'slug':self.slug,
'floor':self.floor.slug,
'building':self.floor.building.slug,
})
def __str__(self): # __unicode__ on Python 2
return self.floor.building.__str__()+" "+self.number.__str__()
class Meta:
ordering = ['number']
# buildings on campus don't have separate addresses yet
#class Address(TimeStampedModel):
......
......@@ -14,7 +14,7 @@
<div class="row">
{% for floor in floors %}
<div class="col-sm-3 text-center">
<a href="#" class="btn btn-primary btn-lg btn-block">{{ floor.number }}</a>
<a href="{{ floor.get_absolute_url }}" class="btn btn-primary btn-lg btn-block">{{ floor.number }}</a>
</div>
{% endfor %}
</div>
......
......@@ -2,19 +2,45 @@
{% block title %} SRCT RoomList &bull; {{ floor.building.name }} {{ floor.number }}{% endblock %}
{% block content %}
{% load humanize %}
<div class="page-header" id="banner">
<div class="row">
<div class="col-lg-12 text-center">
<h1><strong>GMU</strong>ROOMLIST</h1>
<p class="lead"><strong>{{ floor.building.name }}{{ floor.number }}</strong></p>
<h1><strong>SRCT</strong>ROOMLIST</h1>
<p class="lead"><strong>{{ floor.building.name }} {{ floor.number|ordinal }}</strong></p>
</div>
</div>
</div>
{% load gravatar %}
<div class="row">
{% for student in students %}
{{ student }}
<div class="col-sm-3 text-center">
<img class="img-circle img-responsive center center-block" src="{% gravatar_url student.user.email 100 %}" alt="{{ student.user.first_name }} Gravatar picture">
<h4><a href="{{ student.get_absolute_url }}"><strong>{{ student.user.first_name }} {{ student.user.last_name }}</strong></a></h4>
<h5><em>{{ student.major.name }}</em></h5>
<h5><a href="{{ student.room.get_absolute_url }}">{{ student.room }}</a></h5>
</div>
{% endfor %}
</div>
<br />
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="alert alert-info text-center"><strong><em>
{% if notOnFloor %}
You don't live on this floor. Depending on individual privacy settings, not all students may be displayed.
{% elif notInBuilding %}
You don't live in this building. Depending on individual privacy settings, not all students may be displayed.
{% else %}
Don't see someone you know who lives here? Tell them about SRCT Roomlist!
{% endif %}
</em></strong></div>
</div>
</div>
{% endblock %}
......@@ -5,16 +5,38 @@
<div class="page-header" id="banner">
<div class="row">
<div class="col-lg-12 text-center">
<h1><strong>GMU</strong>ROOMLIST</h1>
<p class="lead"><strong>{{ room.floor.building.name }}{{ room.number }}</strong></p>
<h1><strong>SRCT</strong>ROOMLIST</h1>
<p class="lead"><strong>{{ room.floor.building.name }} {{ room.number }}</strong></p>
</div>
</div>
</div>
{% load gravatar %}
<div class="row">
{% for student in students %}
{{ student }}
<div class="col-sm-3 text-center">
<img class="img-circle img-responsive center center-block" src="{% gravatar_url student.user.email 100 %}" alt="{{ student.user.first_name }} Gravatar picture">
<h4><a href="{{ student.get_absolute_url }}"><strong>{{ student.user.first_name }} {{ student.user.last_name }}</strong></a></h4>
<h5><em>{{ student.major.name }}</em></h5>
</div>
{% endfor %}
</div>
<br />
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="alert alert-info text-center"><strong><em>
{% if notOnFloor %}
You don't live on this floor. Depending on individual privacy settings, not all students may be displayed.
{% elif notInBuilding %}
You don't live in this building. Depending on individual privacy settings, not all students may be displayed.
{% else %}
Don't see one of your roommates? Tell them about SRCT Roomlist!
{% endif %}
</em></strong></div>
</div>
</div>
{% endblock %}
......@@ -8,29 +8,35 @@ SRCT RoomList &bull; Homepage
<div class="row">
<div class="col-lg-12 text-center">
<h1><strong>GMU</strong>ROOMLIST</h1>
<p class="lead">Building List</p>
<p class="lead"><strong>Buildings</strong></p>
</div>
</div>
</div>
<legend>Rappahannock</legend>
<legend><strong>Rappahannock</strong></legend>
<ul>
<div class="row">
{% for building in rappahannock %}
<li>
<a href="/housing/buildings/{{ building.name }}">{{ building.name }}</a> - {{ building.address }} {{ building.address.zip_code }}, {{ building.address.state}}
</li>
<div class="col-sm-3 text-center">
<a href="{{ building.get_absolute_url }}" class="btn btn-primary btn-lg btn-block">{{ building.name }}</a>
</div>
{% endfor %}
</ul>
</div>
<legend>Shenandoah</legend>
<br />
<ul>
<legend><strong>Shenandoah</strong></legend>
<div class="row">
{% for building in shenandoah %}
<li>
<a href="/housing/buildings/{{ building.name }}">{{ building.name }}</a> - {{ building.address }} {{ building.address.zip_code }}, {{ building.address.state}}
</li>
<div class="col-sm-3 text-center">
<a href="{{ building.get_absolute_url }}" class="btn btn-primary btn-lg btn-block">{{ building.name }}</a>
</div>
{% endfor %}
</ul>
</div>
<br />
<legend><strong>Aquia</strong></legend>
{% endblock %}
......@@ -22,17 +22,17 @@ urlpatterns = patterns('',
template_name='detail_building.html'),
name='detail_building'),
# url(r'^buildings/whitetop/(?P<slug>[\w-]+)/$',
# DetailFloor.as_view(
# model=Floor,
# context_object_name='floor',
# template_name='detail_floor.html'),
# name='detail_floor'),
url(r'^buildings/(?P<building>[\w-]+)/(?P<slug>[\w-]+)/$',
DetailFloor.as_view(
model=Floor,
context_object_name='floor',
template_name='detail_floor.html'),
name='detail_floor'),
# url(r'^buildings/whitetop/5/5542/$',
# DetailRoom.as_view(
# model=Room,
# context_object_name='room',
# template_name='detail_room.html'),
# name='detail_room'),
url(r'^buildings/(?P<building>[\w-]+)/(?P<floor>[\w-]+)/(?P<slug>[\w-]+)/$',
DetailRoom.as_view(
model=Room,
context_object_name='room',
template_name='detail_room.html'),
name='detail_room'),
)
......@@ -12,9 +12,9 @@ class ListBuildings(LoginRequiredMixin, ListView):
def get_context_data(self, **kwargs):
context = super(ListBuildings, self).get_context_data(**kwargs)
context['rappahannock'] = Building.objects.filter(neighbourhood='ra')
context['shenandoah'] = Building.objects.filter(neighbourhood='sh')
context['aquia'] = Building.objects.filter(neighbourhood='aq')
context['rappahannock'] = Building.objects.filter(neighbourhood='ra').order_by('name')
context['shenandoah'] = Building.objects.filter(neighbourhood='sh').order_by('name')
context['aquia'] = Building.objects.filter(neighbourhood='aq').order_by('name')
return context
# building floors, other information
......@@ -68,6 +68,8 @@ class DetailFloor(LoginRequiredMixin, DetailView):
floor_students.extend(Student.objects.filter(room=room).students())
context['students'] = floor_students
context['notOnFloor'] = not onFloor()
context['notInBuilding'] = not inBuilding()
return context
class DetailRoom(LoginRequiredMixin, DetailView):
......@@ -85,14 +87,14 @@ class DetailRoom(LoginRequiredMixin, DetailView):
# if self.request.user is on the floor
def onFloor():
floor_status = False
if requesting_student.get_floor == self.get_object().floor:
if requesting_student.get_floor() == self.get_object().floor:
floor_status = True
return floor_status
# if self.request.user is in the building
def inBuilding():
building_status = False
if requesting_student.get_building == self.get_object().get_building:
if requesting_student.get_building() == self.get_object().floor.building:
building_status = True
return building_status
......@@ -104,6 +106,9 @@ class DetailRoom(LoginRequiredMixin, DetailView):
students = Student.objects.filter(room=self.get_object()).students()
context['students'] = students
context['notOnFloor'] = not onFloor()
context['notInBuilding'] = not inBuilding()
return context
login_url = '/'
......
......@@ -62,6 +62,7 @@ INSTALLED_APPS = (
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.humanize',
# apps
'api',
'housing',
......
......@@ -35,10 +35,14 @@
</div>
</div>
{% if not user.is_authenticated %}
<br />
<div class="row">
<div class=".col-md-12 text-center">
<button type="button" class="btn btn-primary" id="get-started">Get Started</button>
<div class="col-md-4 col-md-offset-4 text-center">
<a href="#" class="btn btn-primary btn-lg btn-block">Get Started</a>
</div>
</div>
{% endif %}
{% endblock %}
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