Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
2020
PPL-C
PPTI-Mobile Apps Monitoring Wabah Tuberkolosis
Neza-Backend
Commits
06ad0adf
Commit
06ad0adf
authored
Apr 19, 2020
by
Jonathan Christopher Jakub
Browse files
[Bugfix] Generalized related ID field on History creation method
parent
9a170c4e
Changes
4
Hide whitespace changes
Inline
Side-by-side
apps/accounts/admin.py
View file @
06ad0adf
from
django.contrib
import
admin
from
apps.accounts.models
import
Account
from
apps.accounts.models
import
Account
,
AccountHistory
admin
.
site
.
register
(
Account
)
admin
.
site
.
register
(
AccountHistory
)
apps/cases/admin.py
View file @
06ad0adf
from
django.contrib
import
admin
from
apps.cases.models
import
(
CaseSubject
,
CaseSubjectHistory
,
InvestigationCase
,
InvestigationCaseHistory
,
MonitoringCase
,
MonitoringCaseHistory
,
)
admin
.
site
.
register
(
CaseSubject
)
admin
.
site
.
register
(
CaseSubjectHistory
)
admin
.
site
.
register
(
InvestigationCase
)
admin
.
site
.
register
(
InvestigationCaseHistory
)
admin
.
site
.
register
(
MonitoringCase
)
admin
.
site
.
register
(
MonitoringCaseHistory
)
apps/commons/models.py
View file @
06ad0adf
...
...
@@ -70,11 +70,11 @@ class HistoryEnabledModel(SoftDeleteModel):
instance_dict
[
"object_id"
]
=
self
.
id
instance_dict
[
"action_type"
]
=
action
if
self
.
history_class
.
_meta
.
get_field
(
"author"
).
get_internal_type
()
==
"UUIDField"
:
if
self
.
history_class
.
_meta
.
get_field
(
"author"
).
get_internal_type
()
==
"ForeignKey"
:
self
.
history_class
.
objects
.
create
(
**
instance_dict
,
author
=
author
)
else
:
author_id
=
None
if
author
is
None
else
author
.
id
self
.
history_class
.
objects
.
create
(
**
instance_dict
,
author
=
author_id
)
else
:
self
.
history_class
.
objects
.
create
(
**
instance_dict
,
author
=
author
)
def
save
(
self
,
*
args
,
**
kwargs
):
action
=
ACTIVITY_TYPE_CREATE
if
self
.
_state
.
adding
else
ACTIVITY_TYPE_EDIT
...
...
apps/logs/views.py
View file @
06ad0adf
...
...
@@ -47,8 +47,8 @@ class LogAPIView(ListAPIView):
))
def
get
(
self
,
request
):
serializer_data
=
[]
logs_querysets
=
self
.
get_queryset
(
request
)
logs_querysets
=
sorted
(
logs_querysets
,
key
=
lambda
x
:
x
.
recorded_at
,
reverse
=
True
)
paginator
=
PageNumberPagination
()
context
=
paginator
.
paginate_queryset
(
logs_querysets
,
request
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment