Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
3ec31d2f
Verified
Commit
3ec31d2f
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Add created_by and updated_by properties
Advances
#182
.
parent
4cd5d27d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!163
Mandate use of AlekSIS base model
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/core/mixins.py
+30
-6
30 additions, 6 deletions
aleksis/core/mixins.py
with
30 additions
and
6 deletions
aleksis/core/mixins.py
+
30
−
6
View file @
3ec31d2f
...
...
@@ -69,21 +69,45 @@ class ExtensibleModel(CRUDMixin):
- Dominik George <dominik.george@teckids.org>
"""
@property
def
crud_event_create
(
self
)
->
Optional
[
CRUDEvent
]:
"""
Return create event of this object
"""
return
self
.
crud_events
.
filter
(
event_type
=
CRUDEvent
.
CREATE
).
latest
(
"
datetime
"
)
@property
def
crud_event_update
(
self
)
->
Optional
[
CRUDEvent
]:
"""
Return last event of this object
"""
return
self
.
crud_events
.
latest
(
"
datetime
"
)
@property
def
created_at
(
self
)
->
Optional
[
datetime
]:
"""
Determine creation timestamp from CRUD log
"""
event
=
self
.
crud_events
.
filter
(
event_type
=
CRUDEvent
.
CREATE
).
latest
(
"
datetime
"
)
if
event
:
return
event
.
datetime
if
self
.
crud_event_create
:
return
self
.
crud_event_create
.
datetime
@property
def
updated_at
(
self
)
->
Optional
[
datetime
]:
"""
Determine last timestamp from CRUD log
"""
event
=
self
.
crud_events
.
latest
(
"
datetime
"
)
if
event
:
return
event
.
datetime
if
self
.
crud_event_update
:
return
self
.
crud_event_update
.
datetime
extended_data
=
JSONField
(
default
=
dict
,
editable
=
False
)
@property
def
created_by
(
self
)
->
Optional
[
models
.
Model
]:
"""
Determine user who created this object from CRUD log
"""
if
self
.
crud_event_create
:
return
self
.
crud_event_create
.
user
@property
def
updated_by
(
self
)
->
Optional
[
models
.
Model
]:
"""
Determine user who last updated this object from CRUD log
"""
if
self
.
crud_event_update
:
return
self
.
crud_event_update
.
user
extended_data
=
JSONField
(
default
=
dict
,
editable
=
False
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment