Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cf8b2842
authored
Jul 08, 2014
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common: model class for human-readable objects
parent
61b90140
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
circle/common/models.py
+28
-0
No files found.
circle/common/models.py
View file @
cf8b2842
...
...
@@ -299,3 +299,31 @@ try:
],
patterns
=
[
'common
\
.models
\
.'
])
except
ImportError
:
pass
class
HumanReadableObject
(
object
):
def
__init__
(
self
,
user_text_template
,
admin_text_template
,
params
):
self
.
user_text_template
=
user_text_template
self
.
admin_text_template
=
admin_text_template
self
.
params
=
params
@classmethod
def
create
(
cls
,
user_text_template
,
admin_text_template
,
**
params
):
return
cls
(
user_text_template
,
admin_text_template
,
params
)
@classmethod
def
from_dict
(
cls
,
d
):
return
None
if
d
is
None
else
cls
(
**
d
)
def
get_admin_text
(
self
):
return
_
(
self
.
admin_text_template
)
%
self
.
params
def
get_user_text
(
self
):
return
_
(
self
.
user_text_template
)
%
self
.
params
def
to_dict
(
self
):
return
{
"user_text_template"
:
self
.
user_text_template
,
"admin_text_template"
:
self
.
admin_text_template
,
"params"
:
self
.
params
}
create_readable
=
HumanReadableObject
.
create
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