Skip to content

Commit

Permalink
Merge pull request #460 from ISPP-G10/develop
Browse files Browse the repository at this point in the history
FIX: CORRECCIÓN REFERIDOS
  • Loading branch information
javiercavlop committed May 22, 2023
2 parents 1ad069d + 60be1f8 commit 4c30446
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion backend/authentication/mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def mutate(root, info, **kwargs):
if not ReferralProgram.objects.filter(code=code, is_disabled=False, end_date__gte=today, times_to_be_used__gte=1).exists():
try:
promotion = Promotion.objects.get(code=code, is_welcome_promotion=True, is_disabled=False, max_date__gte=today)
if not promotion.can_be_used_always and promotion.times_to_be_used <= 0:
if not promotion.can_be_used_always and promotion.times_to_be_used and promotion.times_to_be_used <= 0:
raise ValueError(_("El código de promoción no es válido"))
coins = promotion.quantity
if promotion.times_to_be_used is not None:
Expand Down
4 changes: 1 addition & 3 deletions backend/authentication/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
def create_referral_program_controller(sender=None, **kwargs):
if ReferralProgramController.objects.count() == 0:
ReferralProgramController.objects.create(max_days=30, max_users=10, quantity=100, quantity_referred=50)

@receiver(signals.post_migrate, sender=None)
def create_referral_program_controller(sender=None, **kwargs):

for user in FlatterUser.objects.filter(referralprogram__isnull=True):
today = timezone.now()
ReferralProgram.objects.create(initial_date=today, user=user, code=_create_code(), times_to_be_used=0, end_date=(today + timezone.timedelta(days=1)), user_quantity=0, user_referred_quantity=0, is_disabled=True)
Expand Down
6 changes: 5 additions & 1 deletion client/src/sections/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ const Header = ({scrollY, userLogged, docPage}) => {
navigator(0)
}
}).catch((error) => {
customAlert(error.message.split("\n")[0], 'error');
if (error.message.split("\n")[0] === "El código de promoción no es válido") {
customAlert('El código de promoción no es válido', 'warning');
} else{
customAlert(error.message.split("\n")[0], 'error');
}
});
}

Expand Down

0 comments on commit 4c30446

Please sign in to comment.