mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 00:52:03 +01:00 
			
		
		
		
	Configure Hello Asso return endpoint
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
		@@ -80,6 +80,14 @@ class Registration(PolymorphicModel):
 | 
			
		||||
    def participates(self):
 | 
			
		||||
        return isinstance(self, ParticipantRegistration)
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def is_student(self):
 | 
			
		||||
        return isinstance(self, StudentRegistration)
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def is_coach(self):
 | 
			
		||||
        return isinstance(self, CoachRegistration)
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def is_admin(self):
 | 
			
		||||
        return isinstance(self, VolunteerRegistration) and self.admin or self.user.is_superuser
 | 
			
		||||
@@ -566,6 +574,17 @@ class Payment(models.Model):
 | 
			
		||||
        default=False,
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def team(self):
 | 
			
		||||
        return self.registrations.first().team
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def tournament(self):
 | 
			
		||||
        if self.final:
 | 
			
		||||
            from participation.models import Tournament
 | 
			
		||||
            return Tournament.final_tournament()
 | 
			
		||||
        return self.registrations.first().team.participation.tournament
 | 
			
		||||
 | 
			
		||||
    def get_checkout_intent(self):
 | 
			
		||||
        if self.checkout_intent_id is None:
 | 
			
		||||
            return None
 | 
			
		||||
@@ -576,17 +595,15 @@ class Payment(models.Model):
 | 
			
		||||
        if checkout_intent is not None:
 | 
			
		||||
            return checkout_intent
 | 
			
		||||
 | 
			
		||||
        from participation.models import Tournament
 | 
			
		||||
        tournament = self.registrations.first().team.participation.tournament \
 | 
			
		||||
            if not self.final else Tournament.final_tournament()
 | 
			
		||||
        tournament = self.tournament
 | 
			
		||||
        year = datetime.now().year
 | 
			
		||||
        base_site = "https://" + Site.objects.first().domain
 | 
			
		||||
        checkout_intent = helloasso.create_checkout_intent(
 | 
			
		||||
            amount=100 * self.amount,
 | 
			
		||||
            name=f"Participation au TFJM² {year} - {tournament.name}",
 | 
			
		||||
            back_url=base_site + reverse('registration:update_payment', args=(self.id,)),
 | 
			
		||||
            error_url=base_site + reverse('registration:update_payment', args=(self.id,)),
 | 
			
		||||
            return_url=base_site + reverse('registration:update_payment', args=(self.id,)),
 | 
			
		||||
            error_url=f"{base_site}{reverse('registration:payment_hello_asso_return', args=(self.id,))}?type=error",
 | 
			
		||||
            return_url=f"{base_site}{reverse('registration:payment_hello_asso_return', args=(self.id,))}?type=return",
 | 
			
		||||
            contains_donation=False,
 | 
			
		||||
            metadata=dict(
 | 
			
		||||
                users=[
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user