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
Sith
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
59
Issues
59
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AE
Sith
Commits
1e95fb68
Commit
1e95fb68
authored
Feb 24, 2017
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make use of cached_property in User model
parent
c66b9b05
Pipeline
#759
failed with stage
in 3 minutes and 29 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
core/models.py
core/models.py
+11
-9
No files found.
core/models.py
View file @
1e95fb68
...
...
@@ -10,6 +10,8 @@ from django.conf import settings
from
django.db
import
transaction
from
django.contrib.staticfiles.storage
import
staticfiles_storage
from
django.utils.html
import
escape
from
django.utils.functional
import
cached_property
from
phonenumber_field.modelfields
import
PhoneNumberField
from
datetime
import
datetime
,
timedelta
,
date
...
...
@@ -230,25 +232,25 @@ class User(AbstractBaseUser):
return
True
return
self
.
groups
.
filter
(
name
=
group_name
).
exists
()
@
property
@
cached_
property
def
is_root
(
self
):
return
self
.
is_superuser
or
self
.
groups
.
filter
(
id
=
settings
.
SITH_GROUP_ROOT_ID
).
exists
()
@
property
@
cached_
property
def
is_board_member
(
self
):
from
club.models
import
Club
return
Club
.
objects
.
filter
(
unix_name
=
settings
.
SITH_MAIN_CLUB
[
'unix_name'
]).
first
().
get_membership_for
(
self
)
@
property
@
cached_
property
def
is_launderette_manager
(
self
):
from
club.models
import
Club
return
Club
.
objects
.
filter
(
unix_name
=
settings
.
SITH_LAUNDERETTE_MANAGER
[
'unix_name'
]).
first
().
get_membership_for
(
self
)
@
property
@
cached_
property
def
is_banned_alcohol
(
self
):
return
self
.
is_in_group
(
settings
.
SITH_GROUP_BANNED_ALCOHOL_ID
)
@
property
@
cached_
property
def
is_banned_counter
(
self
):
return
self
.
is_in_group
(
settings
.
SITH_GROUP_BANNED_COUNTER_ID
)
...
...
@@ -422,11 +424,11 @@ class User(AbstractBaseUser):
escape
(
self
.
get_display_name
()),
)
@
property
@
cached_
property
def
subscribed
(
self
):
return
self
.
is_in_group
(
settings
.
SITH_MAIN_MEMBERS_GROUP
)
@
property
@
cached_
property
def
forum_infos
(
self
):
try
:
return
self
.
_forum_infos
...
...
@@ -666,12 +668,12 @@ class SithFile(models.Model):
else
:
return
super
(
SithFile
,
self
).
__getattribute__
(
attr
)
@
property
@
cached_
property
def
as_picture
(
self
):
from
sas.models
import
Picture
return
Picture
.
objects
.
filter
(
id
=
self
.
id
).
first
()
@
property
@
cached_
property
def
as_album
(
self
):
from
sas.models
import
Album
return
Album
.
objects
.
filter
(
id
=
self
.
id
).
first
()
...
...
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