Skip to content

Conversation

@joris97jansen
Copy link

Doing this as a cronjob might be the better way of doing it, but for a smaller project that doesn't allow setting up a cronjob or because of the lack of knowledge, it might be convenient to add this to the Admin.

@joris97jansen
Copy link
Author

@Andrew-Chen-Wang Ready for review.

@Andrew-Chen-Wang Andrew-Chen-Wang requested a review from 2ykwang July 3, 2023 10:09
ordering = ("token__user",)
actions = ["flush_expired_tokens"]

def flush_expired_tokens(self, request, queryset):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def flush_expired_tokens(self, request, queryset):
@admin.action(permissions=["change"], description = _("Flush expired tokens"))
def flush_expired_tokens(self, request, queryset):

What are your thoughts on using the @admin.action decorator?
It allows you to set the required permissions for executing an action and provides a description for it as well. Additionally, you can use gettext_lazy to provide localization support. @tpotjj

@2ykwang
Copy link
Member

2ykwang commented Jul 5, 2023

Can you please execute the 'makemessages' command to generate the 'po' file? @tpotjj

@2ykwang 2ykwang assigned 2ykwang and joris97jansen and unassigned 2ykwang Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants