-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove unnecessary code in created
method.
#438
Conversation
@2ykwang, the main part of the These are the outputs of your version, the current version, and a compromise version which delegates the formatting to Django code: def created(self, obj):
return obj.timestamp Created: def created(self, obj):
return localtime(obj.timestamp).strftime("%Y-%m-%d %H:%M:%S") Created: def created(self, obj):
return localtime(obj.timestamp) Created: I would argue that precision to seconds and implicit server-local timezone are beneficial to the readability. |
@alieh-rymasheuski When the def created(self, obj):
return localtime(obj.timestamp).strftime("%Y-%m-%d %H:%M:%S")
# output: created - 2022-09-12 23:33:09 def created(self, obj):
return obj.timestamp
# output: created - 2022년 9월 12일 11:33 오후 # display timestamp field instead of the created method.
class LogEntryAdmin(admin.ModelAdmin, LogEntryAdminMixin):
# ...
list_display = ["created", "resource_url", "action", "msg_short", "user_url"]
# ...
# output: timestamp - 2022년 9월 12일 11:33 오후 I think it's natural to match the |
Agree. But please make sure to keep the |
Codecov Report
@@ Coverage Diff @@
## master #438 +/- ##
==========================================
+ Coverage 92.29% 92.30% +0.01%
==========================================
Files 24 24
Lines 727 728 +1
==========================================
+ Hits 671 672 +1
Misses 56 56
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@alieh-rymasheuski |
@2ykwang, please add a changelog entry as well. @hramezani, would you like to take a look too? |
@alieh-rymasheuski done! |
auditlog/mixins.py
Outdated
@@ -16,11 +17,11 @@ | |||
|
|||
|
|||
class LogEntryAdminMixin: | |||
@admin.display(description="created") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@admin.display(description="created") | |
@admin.display(description="Created") |
Use the `display` decorator instead of `short_description`
CHANGELOG.md
Outdated
@@ -7,6 +7,7 @@ | |||
|
|||
#### Fixes | |||
|
|||
- fix: Remove unnecessary code in `created` method. ([#438](https://github.com/jazzband/django-auditlog/pull/438)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need to mention this here as it's not adding/changing a feature.
Please remove it.
for more information, see https://pre-commit.ci
Thanks @2ykwang for the patch and @alieh-rymasheuski for reviewing! |
related #404
already run the same code in the Django
ref: https://github.com/django/django/blob/3.2/django/contrib/admin/utils.py#L381-L429