Skip to content

Commit

Permalink
fix: [ACI-937] fix process_requirement's unexpected keyword argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrii committed Apr 22, 2024
1 parent 73e4f08 commit 497c5a9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions credentials/apps/badges/processing/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ def process_event(sender, **kwargs):
username = identify_user(event_type=event_type, event_payload=extract_payload(kwargs))

# requirements processing
process_requirements(event_type, username, extract_payload(kwargs, as_dict=True))
process_requirements(event_type, username, extract_payload(kwargs))

# penalties processing
# FIXME: disable until "Release V"
# process_penalties(event_type, username, extract_payload(kwargs, as_dict=True))
# process_penalties(event_type, username, extract_payload(kwargs))

except StopEventProcessing:
# controlled processing dropping
Expand Down
5 changes: 3 additions & 2 deletions credentials/apps/badges/processing/progression.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import logging
from attrs import asdict
from typing import List

from credentials.apps.badges.models import BadgeRequirement
Expand All @@ -20,7 +21,7 @@ def discover_requirements(event_type: str) -> List[BadgeRequirement]:



def process_requirements(event_type, username, payload_dict):
def process_requirements(event_type, username, payload):
"""
Finds all relevant requirements, tests them one by one, marks as completed if needed.
"""
Expand All @@ -47,5 +48,5 @@ def process_requirements(event_type, username, payload_dict):
continue

# process: payload rules
if requirement.apply_rules(payload_dict):
if requirement.apply_rules(asdict(payload)):
requirement.fulfill(username)
5 changes: 3 additions & 2 deletions credentials/apps/badges/processing/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import logging
from attrs import asdict
from typing import List

from credentials.apps.badges.models import BadgePenalty
Expand All @@ -19,7 +20,7 @@ def discover_penalties(event_type: str) -> List[BadgePenalty]:
return BadgePenalty.objects.filter(event_type=event_type, template__is_active=True)


def process_penalties(event_type, username, payload_dict):
def process_penalties(event_type, username, payload):
"""
Finds all relevant penalties, tests them one by one, marks related requirement as not completed if needed.
"""
Expand All @@ -31,5 +32,5 @@ def process_penalties(event_type, username, payload_dict):
for penalty in penalties:

# process: payload rules
if penalty.apply_rules(payload_dict):
if penalty.apply_rules(asdict(payload)):
penalty.reset_requirements(username)

0 comments on commit 497c5a9

Please sign in to comment.