Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
roomlist
Commits
26010c61
Commit
26010c61
authored
Nov 26, 2014
by
Jason D Yeomans
Browse files
moved student to accounts.models, added major model in accounts
parent
ff271f59
Changes
12
Hide whitespace changes
Inline
Side-by-side
roomlist/accounts/admin.py
View file @
26010c61
from
django.contrib
import
admin
from
accounts.models
import
Student
,
Major
# Register your models here.
admin
.
site
.
register
(
Major
)
admin
.
site
.
register
(
Student
)
roomlist/accounts/migrations/0001_initial.py
0 → 100644
View file @
26010c61
# -*- 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
,),
),
]
roomlist/accounts/models.py
View file @
26010c61
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
roomlist/accounts/templates/detailStudent.html
View file @
26010c61
...
...
@@ -26,7 +26,7 @@
</tr>
<tr>
<td><strong>
Major
</strong>
:
Biology
</td>
<td><strong>
Major
</strong>
:
{{ student.major.major_name }}
</td>
</tr>
<tr>
...
...
roomlist/accounts/urls.py
View file @
26010c61
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
()
...
...
roomlist/accounts/views.py
View file @
26010c61
...
...
@@ -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
...
...
roomlist/housing/admin.py
View file @
26010c61
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
)
roomlist/housing/migrations/0002_auto_20141126_0908.py
0 → 100644
View file @
26010c61
# -*- 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'
,
),
]
roomlist/housing/models.py
View file @
26010c61
...
...
@@ -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
)
roomlist/housing/urls.py
View file @
26010c61
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
(
''
,
...
...
roomlist/housing/views.py
View file @
26010c61
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
...
...
roomlist/templates/layouts/navbar.html
View file @
26010c61
...
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment