Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2eac5bff
authored
Oct 13, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common: refactor get_user_text and get_admin_text
parent
a7e9781e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
circle/common/models.py
+13
-10
No files found.
circle/common/models.py
View file @
2eac5bff
...
@@ -444,24 +444,27 @@ class HumanReadableObject(object):
...
@@ -444,24 +444,27 @@ class HumanReadableObject(object):
def
from_dict
(
cls
,
d
):
def
from_dict
(
cls
,
d
):
return
None
if
d
is
None
else
cls
(
**
d
)
return
None
if
d
is
None
else
cls
(
**
d
)
def
get_admin_text
(
self
):
def
_get_parsed_text
(
self
,
key
):
if
self
.
admin_text_template
==
""
:
value
=
getattr
(
self
,
key
)
if
value
==
""
:
return
""
return
""
try
:
try
:
return
_
(
self
.
admin_text_template
)
%
self
.
params
return
_
(
value
)
%
self
.
params
except
KeyError
:
logger
.
exception
(
"Can't render
%
s '
%
s'
%% %
s"
,
key
,
value
,
unicode
(
self
.
params
))
raise
def
get_admin_text
(
self
):
try
:
return
self
.
_get_parsed_text
(
"admin_text_template"
)
except
KeyError
:
except
KeyError
:
logger
.
exception
(
"Can't render admin_text_template '
%
s'
%% %
s"
,
self
.
admin_text_template
,
unicode
(
self
.
params
))
return
self
.
get_user_text
()
return
self
.
get_user_text
()
def
get_user_text
(
self
):
def
get_user_text
(
self
):
if
self
.
user_text_template
==
""
:
return
""
try
:
try
:
return
_
(
self
.
user_text_template
)
%
self
.
params
return
self
.
_get_parsed_text
(
"user_text_template"
)
except
KeyError
:
except
KeyError
:
logger
.
exception
(
"Can't render user_text_template '
%
s'
%% %
s"
,
self
.
user_text_template
,
unicode
(
self
.
params
))
return
self
.
user_text_template
return
self
.
user_text_template
def
get_text
(
self
,
user
):
def
get_text
(
self
,
user
):
...
...
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