Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8cd8d2bf
authored
Oct 16, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common: abstract model for activities
parent
685d5c82
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
circle/common/__init__.py
+0
-0
circle/common/models.py
+42
-0
No files found.
circle/common/__init__.py
0 → 100644
View file @
8cd8d2bf
circle/common/models.py
0 → 100644
View file @
8cd8d2bf
from
django.contrib.auth.models
import
User
from
django.db.models
import
(
CharField
,
DateTimeField
,
ForeignKey
,
TextField
)
from
django.utils
import
timezone
from
django.utils.translation
import
ugettext_lazy
as
_
from
model_utils.models
import
TimeStampedModel
def
activitycontextimpl
(
act
):
try
:
yield
act
except
Exception
as
e
:
act
.
finish
(
str
(
e
))
raise
e
else
:
act
.
finish
()
class
ActivityModel
(
TimeStampedModel
):
activity_code
=
CharField
(
max_length
=
100
,
verbose_name
=
_
(
'activity code'
))
parent
=
ForeignKey
(
'self'
,
blank
=
True
,
null
=
True
)
task_uuid
=
CharField
(
blank
=
True
,
max_length
=
50
,
null
=
True
,
unique
=
True
,
help_text
=
_
(
'Celery task unique identifier.'
),
verbose_name
=
_
(
'task_uuid'
))
user
=
ForeignKey
(
User
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'user'
),
help_text
=
_
(
'The person who started this activity.'
))
started
=
DateTimeField
(
verbose_name
=
_
(
'started at'
),
blank
=
True
,
null
=
True
,
help_text
=
_
(
'Time of activity initiation.'
))
finished
=
DateTimeField
(
verbose_name
=
_
(
'finished at'
),
blank
=
True
,
null
=
True
,
help_text
=
_
(
'Time of activity finalization.'
))
result
=
TextField
(
verbose_name
=
_
(
'result'
),
blank
=
True
,
null
=
True
,
help_text
=
_
(
'Human readable result of activity.'
))
class
Meta
:
abstract
=
True
def
finish
(
self
,
result
=
None
):
if
not
self
.
finished
:
self
.
finished
=
timezone
.
now
()
self
.
result
=
result
self
.
save
()
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