Commit 3c9ee9d1 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

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

parents fdcc82b2 26010c61
from django.contrib import admin
from accounts.models import Student, Major
# Register your models here.
admin.site.register(Major)
admin.site.register(Student)
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import model_utils.fields
import autoslug.fields
import django.utils.timezone
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
('housing', '0002_auto_20141126_0908'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Major',
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)),
('major_name', models.CharField(max_length=30)),
],
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)),
('clas', models.OneToOneField(to='housing.Class')),
('major', models.OneToOneField(to='accounts.Major')),
('room', models.OneToOneField(to='housing.Room')),
('user', models.OneToOneField(to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
bases=(models.Model,),
),
]
from django.db import models
from housing.models import User, Room, Class
from autoslug import AutoSlugField
from model_utils.models import TimeStampedModel
# Create your models here.
class Major(TimeStampedModel):
major_name = models.CharField(max_length = 30)
class Student(TimeStampedModel):
user = models.OneToOneField(User)
# Django user includes a username, password, email, first name, and last name
room = models.OneToOneField(Room)
clas = models.OneToOneField(Class)
major = models.OneToOneField(Major)
# major = models.
# social media accounts
slug = AutoSlugField(populate_from='user', unique=True)
def __str__(self): # __unicode__ on Python 2
return self.user.username
......@@ -26,7 +26,7 @@
</tr>
<tr>
<td><strong>Major</strong>: Biology</td>
<td><strong>Major</strong>: {{ student.major.major_name }}</td>
</tr>
<tr>
......
from django.conf.urls import patterns, include, url
from accounts.views import DetailStudent
from accounts.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 accounts.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,),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('housing', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='student',
name='room',
),
migrations.RemoveField(
model_name='student',
name='user',
),
migrations.DeleteModel(
name='Student',
),
]
......@@ -71,20 +71,4 @@ class Class(TimeStampedModel):
default=FRESHMAN)
def __str__(self): # __unicode__ on Python 2
return self.year_int
class Student(TimeStampedModel):
user = models.OneToOneField(User)
# Django user includes a username, password, email, first name, and last name
room = models.OneToOneField(Room)
# class = models.OneToOneField(Class)
# major = models.
# social media accounts
slug = AutoSlugField(populate_from='user', unique=True)
def __str__(self): # __unicode__ on Python 2
return self.user.username
return str(self.year_int)
......@@ -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
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'),
......
from django.views.generic import DetailView, ListView, CreateView, UpdateView, DeleteView
from housing.models import Building, Room, Student
from housing.models import Building, Room
from accounts.models import Student
from braces.views import LoginRequiredMixin
......@@ -24,11 +25,6 @@ class DetailRoom(LoginRequiredMixin, ListView):
model = Room
login_url = '/'
# details about the student
class DetailStudent(LoginRequiredMixin, DetailView):
model = Student
login_url = '/'
# update a student
#class UpdateStudent(LoginRequiredMixin, UpdateView):
# model = Student
......
......@@ -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 = (
......@@ -65,6 +66,7 @@ INSTALLED_APPS = (
'django.contrib.staticfiles',
'api',
'housing',
'accounts',
'crispy_forms',
'django_gravatar',
)
......
......@@ -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')),
......
{% extends 'layouts/base.html' %}
{% block title %}
GMU RoomList &bull; Homepage
{% endblock %}
{% block content %}
<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">List of buildings in database:</p>
</div>
</div>
</div>
<div class="row">
</div>
{% endblock %}
......@@ -15,12 +15,12 @@
</li>
<li><a href="/#about">About</a>
</li>
<li><a href="/buildings">Buildings</a>
<li><a href="/housing/buildings">Buildings</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
{% if user.is_authenticated %}
<li><a href="#">{{ user.username }}</a>
<li><a href="/accounts/student/{{ user.username }}">{{ user.username }}</a>
</li>
<li><a href="/accounts/logout/">Logout</a>
</li>
......
......@@ -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