Small improvement to display of rights management logs

This commit is contained in:
Frisk 2021-05-16 17:08:41 +02:00
parent a38babfd19
commit 5a3f6eee5a
No known key found for this signature in database
GPG key ID: 213F7C15068AF8AC

View file

@ -811,7 +811,7 @@ def compact_import_interwiki(ctx, change):
# rights/rights - Assigning rights groups # rights/rights - Assigning rights groups
def get_changed_groups(change: dict, separator: str): def get_changed_groups(change: dict, separator: str) -> [str, str]:
"""Creates strings comparing the changes between the user groups for the user""" """Creates strings comparing the changes between the user groups for the user"""
old_groups = {_(x) for x in change["logparams"]["oldgroups"]} # translate all groups and pull them into a set old_groups = {_(x) for x in change["logparams"]["oldgroups"]} # translate all groups and pull them into a set
new_groups = {_(x) for x in change["logparams"]["newgroups"]} new_groups = {_(x) for x in change["logparams"]["newgroups"]}
@ -851,13 +851,13 @@ def compact_rights_rights(ctx, change):
parsed_comment = compact_summary(ctx) parsed_comment = compact_summary(ctx)
if ctx.event == "rights/rights": if ctx.event == "rights/rights":
content = _( content = _(
"[{author}]({author_url}) changed group membership for [{target}]({target_url}) {added} {removed}{comment}").format( "[{author}]({author_url}) changed group membership for [{target}]({target_url}) {added}{comma} {removed}{comment}").format(
author=author, author_url=author_url, target=sanitize_to_markdown(change["title"].split(":")[1]), target_url=link, author=author, author_url=author_url, target=sanitize_to_markdown(change["title"].split(":")[1]), target_url=link,
added=added, removed=removed, comment=parsed_comment) added=added, comma="," if added and removed else "", removed=removed, comment=parsed_comment)
else: else:
content = _("{author} autopromoted [{target}]({target_url}) {added} {removed}{comment}").format( content = _("{author} autopromoted [{target}]({target_url}) {added}{comma} {removed}{comment}").format(
author=_("System"), author_url=author_url, target=sanitize_to_markdown(change["title"].split(":")[1]), target_url=link, author=_("System"), author_url=author_url, target=sanitize_to_markdown(change["title"].split(":")[1]), target_url=link,
added=added, removed=removed, comment=parsed_comment) added=added, comma="," if added and removed else "",removed=removed, comment=parsed_comment)
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content) return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)