Fix potential issue when partial block doesn't have any restrictions

This commit is contained in:
Frisk 2020-11-22 14:31:40 +01:00
parent d8ef84ae84
commit dc971d0dca
No known key found for this signature in database
GPG key ID: 213F7C15068AF8AC

View file

@ -185,7 +185,7 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
date_time_obj = datetime.datetime.strptime(change["logparams"]["expiry"], '%Y-%m-%dT%H:%M:%SZ') date_time_obj = datetime.datetime.strptime(change["logparams"]["expiry"], '%Y-%m-%dT%H:%M:%SZ')
block_time = _("until {}").format(date_time_obj.strftime("%Y-%m-%d %H:%M:%S UTC")) block_time = _("until {}").format(date_time_obj.strftime("%Y-%m-%d %H:%M:%S UTC"))
if "sitewide" not in change["logparams"]: if "sitewide" not in change["logparams"]:
restriction_description = "" if "restrictions" in change["logparams"]:
if "pages" in change["logparams"]["restrictions"] and change["logparams"]["restrictions"]["pages"]: if "pages" in change["logparams"]["restrictions"] and change["logparams"]["restrictions"]["pages"]:
restriction_description = _(" on pages: ") restriction_description = _(" on pages: ")
for page in change["logparams"]["restrictions"]["pages"]: for page in change["logparams"]["restrictions"]["pages"]:
@ -676,6 +676,7 @@ def embed_formatter(action, change, parsed_comment, categories, recent_changes):
block_time = _("unknown expiry time") # THIS IS HERE JUST TEMPORARY AS A HOT FIX TO #157, will be changed with release of 1.13 block_time = _("unknown expiry time") # THIS IS HERE JUST TEMPORARY AS A HOT FIX TO #157, will be changed with release of 1.13
if "sitewide" not in change["logparams"]: if "sitewide" not in change["logparams"]:
restriction_description = "" restriction_description = ""
if "restrictions" in change["logparams"]:
if "pages" in change["logparams"]["restrictions"] and change["logparams"]["restrictions"]["pages"]: if "pages" in change["logparams"]["restrictions"] and change["logparams"]["restrictions"]["pages"]:
restriction_description = _("Blocked from editing the following pages: ") restriction_description = _("Blocked from editing the following pages: ")
for page in change["logparams"]["restrictions"]["pages"]: for page in change["logparams"]["restrictions"]["pages"]: