mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-22 00:14:10 +00:00
Fixed wrong handling of compact block formatter
This commit is contained in:
parent
d23ba0ca5d
commit
0610a0e030
|
@ -647,33 +647,32 @@ def compact_block_block(ctx: Context, change: dict):
|
|||
link = clean_link(ctx.client.create_article_path("Special:Contributions/{user}".format(user=user)))
|
||||
except ValueError:
|
||||
link = clean_link(ctx.client.create_article_path(sanitize_to_url(change["title"])))
|
||||
else:
|
||||
if "sitewide" not in change["logparams"]:
|
||||
if "restrictions" in change["logparams"]:
|
||||
if "pages" in change["logparams"]["restrictions"] and change["logparams"]["restrictions"]["pages"]:
|
||||
restriction_description = ctx._(" on pages: ")
|
||||
restricted_pages = ["*{page}*".format(page=i["page_title"]) for i in
|
||||
change["logparams"]["restrictions"]["pages"]]
|
||||
restriction_description = restriction_description + ", ".join(restricted_pages)
|
||||
if "namespaces" in change["logparams"]["restrictions"] and change["logparams"]["restrictions"][
|
||||
"namespaces"]:
|
||||
namespaces = []
|
||||
if restriction_description:
|
||||
restriction_description = restriction_description + ctx._(" and namespaces: ")
|
||||
if "sitewide" not in change["logparams"]:
|
||||
if "restrictions" in change["logparams"]:
|
||||
if "pages" in change["logparams"]["restrictions"] and change["logparams"]["restrictions"]["pages"]:
|
||||
restriction_description = ctx._(" on pages: ")
|
||||
restricted_pages = ["*{page}*".format(page=i["page_title"]) for i in
|
||||
change["logparams"]["restrictions"]["pages"]]
|
||||
restriction_description = restriction_description + ", ".join(restricted_pages)
|
||||
if "namespaces" in change["logparams"]["restrictions"] and change["logparams"]["restrictions"][
|
||||
"namespaces"]:
|
||||
namespaces = []
|
||||
if restriction_description:
|
||||
restriction_description = restriction_description + ctx._(" and namespaces: ")
|
||||
else:
|
||||
restriction_description = ctx._(" on namespaces: ")
|
||||
for namespace in change["logparams"]["restrictions"]["namespaces"]:
|
||||
if str(namespace) == "0":
|
||||
namespaces.append("*{ns}*".format(ns=ctx._("(Main)")))
|
||||
elif str(namespace) in ctx.client.namespaces: # if we have cached namespace name for given namespace number, add its name to the list
|
||||
namespaces.append("*{ns}*".format(ns=ctx.client.namespaces[str(namespace)]["*"]))
|
||||
else:
|
||||
restriction_description = ctx._(" on namespaces: ")
|
||||
for namespace in change["logparams"]["restrictions"]["namespaces"]:
|
||||
if str(namespace) == "0":
|
||||
namespaces.append("*{ns}*".format(ns=ctx._("(Main)")))
|
||||
elif str(namespace) in ctx.client.namespaces: # if we have cached namespace name for given namespace number, add its name to the list
|
||||
namespaces.append("*{ns}*".format(ns=ctx.client.namespaces[str(namespace)]["*"]))
|
||||
else:
|
||||
namespaces.append("*{ns}*".format(ns=namespace))
|
||||
restriction_description = restriction_description + ", ".join(namespaces)
|
||||
restriction_description = restriction_description + "."
|
||||
if len(restriction_description) > 1020:
|
||||
logger.debug(restriction_description)
|
||||
restriction_description = restriction_description[:1020] + "…"
|
||||
namespaces.append("*{ns}*".format(ns=namespace))
|
||||
restriction_description = restriction_description + ", ".join(namespaces)
|
||||
restriction_description = restriction_description + "."
|
||||
if len(restriction_description) > 1020:
|
||||
logger.debug(restriction_description)
|
||||
restriction_description = restriction_description[:1020] + "…"
|
||||
content = ctx._(
|
||||
"[{author}]({author_url}) blocked [{user}]({user_url}) {time}{restriction_desc}{comment}").format(author=author,
|
||||
author_url=author_url,
|
||||
|
|
Loading…
Reference in a new issue