Commit 26010c61 authored by Jason D Yeomans's avatar Jason D Yeomans
Browse files

moved student to accounts.models, added major model in accounts

parent ff271f59
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 housing.models import Student
from accounts.models import Student
from django.contrib import admin
admin.autodiscover()
......
......@@ -2,7 +2,7 @@ from django.shortcuts import render
from django.views.generic import DetailView, ListView, CreateView, UpdateView, DeleteView
from housing.models import Student
from accounts.models import Student
from braces.views import LoginRequiredMixin
......
from django.contrib import admin
from housing.models import Class, Building, Address, Room, Student
from housing.models import Class, Building, Address, Room
# Register your models here.
admin.site.register(Class)
admin.site.register(Building)
admin.site.register(Address)
admin.site.register(Room)
admin.site.register(Student)
# -*- 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)
from django.conf.urls import patterns, include, url
from housing.views import ListBuildings, DetailBuilding, ListRooms, DetailRoom
from housing.models import Building, Room, Student
from housing.models import Building, Room
urlpatterns = patterns('',
......
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
......
......@@ -20,7 +20,7 @@
</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>
......
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