Fakultas Ilmu Komputer UI

Commit 2e422a7b authored by Jonathan Christopher Jakub's avatar Jonathan Christopher Jakub
Browse files

Merge branch 'jojo/uuid-user' into 'staging'

[Bugfix] Generalized related ID field on History creation method

See merge request !36
parents 9a170c4e 06ad0adf
Pipeline #41565 passed with stages
in 18 minutes and 25 seconds
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)
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)
......@@ -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
......
......@@ -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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment