Skip to content

Commit

Permalink
fix: fix a bug in attributes + perform transition at the end of submi…
Browse files Browse the repository at this point in the history
…ssion
  • Loading branch information
AmooHashem committed Oct 30, 2024
1 parent a24d9f1 commit 880297b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions apps/attributes/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def is_permitted(self, *args, **kwargs) -> bool:
return is_permitted

def __str__(self):
return self.title
return f'{self.__class__.__name__}: {self.title}'


class IntrinsicAttribute(Attribute):
Expand Down Expand Up @@ -64,7 +64,7 @@ def give_reward(self, *args, **kwargs):
# Process the transfer
request_transfer(
sender_id=website.get('uuid'),
receiver_id=request.user.id,
receiver_id=str(request.user.id),
funds=total_reward,
)

Expand Down
8 changes: 8 additions & 0 deletions apps/attributes/models/performable_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ def perform(self, *arg, **kwargs):
if not self.is_permitted(*arg, **kwargs):
return False

# perform main action:
self.give_reward(*arg, **kwargs)

# perform posterior actions:
from apps.attributes.models import PerformableAction
performable_attributes = self.attributes.instance_of(
PerformableAction)
for performable_attribute in performable_attributes:
performable_attribute.perform(*arg, **kwargs)

return True
4 changes: 2 additions & 2 deletions apps/response/views/answer_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ def get_serializer_context(self):
return context

@swagger_auto_schema(responses={200: MockAnswerSerializer}, tags=['answers'])
@action(detail=False, methods=['post'])
@action(detail=False, methods=['post'], url_path='submit-answer')
@transaction.atomic
def submit_answer(self, request, *args, **kwargs):
question = get_question(request.data.get("question"))
player_id = request.data.get("player")
player_id = request.data.get("player_id")
player = None
if player_id:
player = get_object_or_404(Player, id=player_id)
Expand Down
2 changes: 0 additions & 2 deletions manage_content_service/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,6 @@ def GET_PAYMENT_CALLBACK_URL(domain, status):

########## OTHER SERVICES ##########

BANK = get_environment_var('BANK', 'http://localhost:20000/')

WMS_URL = get_environment_var('WMS_URL', 'http://localhost:10000/')

IMS_URL = get_environment_var(
Expand Down
6 changes: 3 additions & 3 deletions proxies/bank_service/bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from rest_framework import status
from rest_framework.response import Response

BANK = settings.BANK
BANK_URL = settings.BANK_URL


def _get(url, params):
Expand Down Expand Up @@ -50,7 +50,7 @@ def request_transfer(sender_id: str, receiver_id: str, funds: dict):
Returns:
dict: Response from the transfer API or Response object with error
"""
url = f'{BANK}counter/transfer/'
url = f'{BANK_URL}counter/transfer/'

payload = {
"sender_id": sender_id,
Expand All @@ -63,7 +63,7 @@ def request_transfer(sender_id: str, receiver_id: str, funds: dict):

def get_user_balances(user_uuid):

url = f'{BANK}counter/user-balances/'
url = f'{BANK_URL}counter/user-balances/'

payload = {
"user_uuid": user_uuid,
Expand Down

0 comments on commit 880297b

Please sign in to comment.