Commit f8e5efe3 authored by Jason Yeomans's avatar Jason Yeomans
Browse files

Merge branch 'master' of git.gmu.edu:srct/roomlist

parents 36847005 93473bd1
from django.conf.urls import patterns, include, url
from accounts.views import DetailStudent
from housing.models import Student
from django.contrib import admin
admin.autodiscover()
......@@ -7,4 +9,11 @@ urlpatterns = patterns('',
# login and logout
url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}, name='login'),
url(r'^logout/$', 'django.contrib.auth.views.logout', {'template_name': 'index.html'}, name='logout'),
url(r'^student/(?P<slug>[\w-]+)/$',
DetailStudent.as_view(
model=Student,
context_object_name='student',
template_name='detailStudent.html'),
name='detailStudent'),
)
from django.shortcuts import render
# Create your views here.
from django.views.generic import DetailView, ListView, CreateView, UpdateView, DeleteView
from housing.models import Student
from braces.views import LoginRequiredMixin
# details about the student
class DetailStudent(LoginRequiredMixin, DetailView):
model = Student
login_url = '/'
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import autoslug.fields
import django.utils.timezone
from django.conf import settings
import model_utils.fields
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Address',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('street', models.CharField(max_length=100)),
('zip_code', models.IntegerField(max_length=5)),
('state', models.CharField(max_length=2)),
],
options={
'abstract': False,
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Building',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('name', models.CharField(max_length=100)),
('neighbourhood', models.CharField(default=b'na', max_length=100, choices=[(b'na', b'None'), (b'aq', b'Aquia'), (b'ra', b'Rappahannock'), (b'sh', b'Shenandoah')])),
('slug', autoslug.fields.AutoSlugField(unique=True, editable=False)),
('address', models.ForeignKey(to='housing.Address')),
],
options={
'abstract': False,
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Class',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('year_int', models.IntegerField()),
('year_in_school', models.CharField(default=b'FR', max_length=2, choices=[(b'FR', b'Freshman'), (b'SO', b'Sophomore'), (b'JR', b'Junior'), (b'SR', b'Senior')])),
],
options={
'abstract': False,
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Room',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('number', models.IntegerField()),
('floor', models.IntegerField()),
('bedA', models.CharField(max_length=80)),
('bedB', models.CharField(max_length=80, blank=True)),
('bedC', models.CharField(max_length=80, blank=True)),
('bedD', models.CharField(max_length=80, blank=True)),
('slug', autoslug.fields.AutoSlugField(unique=True, editable=False)),
('building', models.ForeignKey(to='housing.Building')),
],
options={
'abstract': False,
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Student',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('slug', autoslug.fields.AutoSlugField(unique=True, editable=False)),
('room', models.OneToOneField(to='housing.Room')),
('user', models.OneToOneField(to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
bases=(models.Model,),
),
]
......@@ -16,7 +16,7 @@ GMU RoomList &bull; Homepage
<ul>
{% for building in buildings %}
<li>
<a href="/building/{{ building.name }}">{{ building.name }}</a> - {{ building.address }} {{ building.address.zip_code }}, {{ building.address.state}}
<a href="/housing/buildings/{{ building.name }}">{{ building.name }}</a> - {{ building.address }} {{ building.address.zip_code }}, {{ building.address.state}}
</li>
{% endfor %}
</ul>
......
from django.conf.urls import patterns, include, url
from housing.views import ListBuildings, DetailBuilding, ListRooms, DetailRoom, DetailStudent
from housing.models import Building, Room, Student
from housing.views import ListBuildings, DetailBuilding, ListRooms, DetailRoom
from housing.models import Building, Room, Student
urlpatterns = patterns('',
url(r'^student/(?P<slug>[\w-]+)/$',
DetailStudent.as_view(
model=Student,
context_object_name='student',
template_name='detailStudent.html'),
name='detailStudent'),
url(r'^buildings/$',
ListBuildings.as_view(
model=Building,
......@@ -24,6 +17,7 @@ urlpatterns = patterns('',
url(r'^buildings/(?P<slug>[\w-]+)/$',
DetailBuilding.as_view(
model=Building,
slug_field='slug__iexact',
context_object_name='building',
template_name='detailBuilding.html'),
name='detailBuilding'),
......
......@@ -24,11 +24,6 @@ class DetailRoom(LoginRequiredMixin, ListView):
model = Room
login_url = '/'
# details about the student
class DetailStudent(LoginRequiredMixin, DetailView):
model = Student
login_url = '/'
# update a student
# update a room
......
......@@ -15,6 +15,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(__file__))
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'),
os.path.join(BASE_DIR, 'housing/templates'),
os.path.join(BASE_DIR, 'accounts/templates'),
)
STATICFILES_DIRS = (
......
......@@ -15,10 +15,6 @@ urlpatterns = patterns('',
# url(r'^contact/$', TemplateView.as_view(template_name='contact.html'), name='contact'),
# url(r'^privacy/$', TemplateView.as_view(template_name='privacy.html'), name='privacy'),
# logins
url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}, name='login'),
url(r'logout/$', 'django.contrib.auth.views.logout', {'template_name': 'index.html'}, name='logout'),
# app-level urls
url(r'^housing/', include('housing.urls')),
url(r'^accounts/', include('accounts.urls')),
......
......@@ -11,13 +11,18 @@
</div>
</div>
{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}
<form class="form-signin" role="form" action="/accounts/login/" method="post">
{% csrf_token %}
{% csrf_token %}
<h2 class="form-signin-heading">Please sign in</h2>
<label for="username" class="sr-only">Username</label>
<input type="text" id="inputUsername" name="username" class="form-control" placeholder="Mason NetID" required autofocus>
{{form.username}}
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" name="password" class="form-control" placeholder="Password" required>
{{form.password}}
<div class="checkbox">
<label>
<input type="checkbox" value="remember-me"> Remember me
......
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