mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
Fixed both issues, partially returned the older code
This commit is contained in:
parent
ad7b0fd207
commit
69efcf2650
|
@ -66,6 +66,7 @@ edit_alerts = settings.get("hooks", {}).get("edit_alerts", [])
|
|||
|
||||
|
||||
class RequirementNotMet(Exception):
|
||||
"""Exception raised when the requirement is not met and another requirement must be processed"""
|
||||
pass
|
||||
|
||||
|
||||
|
@ -73,9 +74,11 @@ def check_group_requirements(change_data: list, settings_data: list):
|
|||
"""This function resolves group discussions and raises RequirementNotMet when requirement is not met"""
|
||||
if settings_data:
|
||||
for required_group in settings_data:
|
||||
for required_item in required_group:
|
||||
if required_item not in change_data:
|
||||
raise RequirementNotMet
|
||||
# test all items in required_group are in change_data (one group fulfills the requirement) return the function
|
||||
if all([required_item in change_data for required_item in required_group]):
|
||||
return
|
||||
raise RequirementNotMet
|
||||
|
||||
|
||||
|
||||
@post_hook
|
||||
|
@ -98,9 +101,26 @@ def edit_alerts_hook(message, metadata, context, change):
|
|||
raise RequirementNotMet
|
||||
check_group_requirements(change.get("tags", []), requirement.get("tags", []))
|
||||
if requirement.get("categories", []):
|
||||
for reqCats in requirement.get("categories", []):
|
||||
check_group_requirements(context.categories.new, reqCats.get("added", []))
|
||||
check_group_requirements(context.categories.removed, reqCats.get("removed", []))
|
||||
for req_cats in requirement.get("categories", []):
|
||||
if req_cats.get("added", []):
|
||||
for added_cats in req_cats.get("added", []):
|
||||
for added_cat in added_cats:
|
||||
if added_cat not in context.categories.new:
|
||||
break
|
||||
else:
|
||||
break
|
||||
else:
|
||||
raise RequirementNotMet
|
||||
if req_cats.get("removed", []):
|
||||
for removed_cats in req_cats.get("removed", []):
|
||||
for removed_cat in removed_cats:
|
||||
if removed_cat not in context.categories.removed:
|
||||
break
|
||||
else:
|
||||
break
|
||||
else:
|
||||
raise RequirementNotMet
|
||||
break
|
||||
except RequirementNotMet:
|
||||
continue
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue