Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
roomlist
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SRCT
roomlist
Commits
b4b5639b
Commit
b4b5639b
authored
Oct 26, 2015
by
Daniel W Bond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added method to see if Student should be able to change floor
parent
8894f89e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
roomlist/accounts/models.py
roomlist/accounts/models.py
+20
-0
No files found.
roomlist/accounts/models.py
View file @
b4b5639b
...
...
@@ -4,6 +4,7 @@ import hashlib
from
datetime
import
date
# core django imports
from
django.db
import
models
from
django.utils
import
timezone
from
model_utils.models
import
TimeStampedModel
from
django.contrib.auth.models
import
User
from
django.core.urlresolvers
import
reverse
...
...
@@ -127,6 +128,8 @@ class Student(TimeStampedModel):
room
=
models
.
ForeignKey
(
Room
,
null
=
True
,
blank
=
True
)
major
=
models
.
ForeignKey
(
'Major'
,
null
=
True
,
blank
=
True
)
times_changed_room
=
models
.
IntegerField
(
default
=
0
)
current_year
=
date
.
today
().
year
graduating_year
=
models
.
IntegerField
(
default
=
current_year
,
blank
=
True
)
...
...
@@ -160,6 +163,23 @@ class Student(TimeStampedModel):
else
:
return
"magic"
def
can_change_floor
(
self
):
# part of TimeStampedModel
now
=
timezone
.
now
()
created
=
self
.
created
# could make this more formal with dateutil, but...
days
=
(
now
-
created
).
days
half_years
=
days
/
float
(
30
*
6
)
# we want you to be able to change your room at most
# twice in a six month period before blocking you
if
(
self
.
times_changed_room
/
half_years
)
<=
2
:
return
True
else
:
return
False
def
get_floor
(
self
):
try
:
floor
=
self
.
room
.
floor
...
...
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