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