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):
|
class RequirementNotMet(Exception):
|
||||||
|
"""Exception raised when the requirement is not met and another requirement must be processed"""
|
||||||
pass
|
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"""
|
"""This function resolves group discussions and raises RequirementNotMet when requirement is not met"""
|
||||||
if settings_data:
|
if settings_data:
|
||||||
for required_group in settings_data:
|
for required_group in settings_data:
|
||||||
for required_item in required_group:
|
# test all items in required_group are in change_data (one group fulfills the requirement) return the function
|
||||||
if required_item not in change_data:
|
if all([required_item in change_data for required_item in required_group]):
|
||||||
raise RequirementNotMet
|
return
|
||||||
|
raise RequirementNotMet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@post_hook
|
@post_hook
|
||||||
|
@ -98,9 +101,26 @@ def edit_alerts_hook(message, metadata, context, change):
|
||||||
raise RequirementNotMet
|
raise RequirementNotMet
|
||||||
check_group_requirements(change.get("tags", []), requirement.get("tags", []))
|
check_group_requirements(change.get("tags", []), requirement.get("tags", []))
|
||||||
if requirement.get("categories", []):
|
if requirement.get("categories", []):
|
||||||
for reqCats in requirement.get("categories", []):
|
for req_cats in requirement.get("categories", []):
|
||||||
check_group_requirements(context.categories.new, reqCats.get("added", []))
|
if req_cats.get("added", []):
|
||||||
check_group_requirements(context.categories.removed, reqCats.get("removed", []))
|
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:
|
except RequirementNotMet:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue