mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 00:52:03 +01:00 
			
		
		
		
	Allow anonymous users to perform a payment using a special auth token
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
		@@ -506,6 +506,10 @@ def get_receipt_filename(instance, filename):
 | 
			
		||||
    return f"authorization/receipt/receipt_{instance.id}"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_random_token():
 | 
			
		||||
    return get_random_string(32)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Payment(models.Model):
 | 
			
		||||
    registrations = models.ManyToManyField(
 | 
			
		||||
        ParticipantRegistration,
 | 
			
		||||
@@ -526,6 +530,13 @@ class Payment(models.Model):
 | 
			
		||||
        default=0,
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    token = models.CharField(
 | 
			
		||||
        verbose_name=_("token"),
 | 
			
		||||
        max_length=32,
 | 
			
		||||
        default=get_random_token,
 | 
			
		||||
        help_text=_("A token to authorize external users to make this payment."),
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    final = models.BooleanField(
 | 
			
		||||
        verbose_name=_("for final tournament"),
 | 
			
		||||
        default=False,
 | 
			
		||||
@@ -585,13 +596,13 @@ class Payment(models.Model):
 | 
			
		||||
            return Tournament.final_tournament()
 | 
			
		||||
        return self.registrations.first().team.participation.tournament
 | 
			
		||||
 | 
			
		||||
    def get_checkout_intent(self):
 | 
			
		||||
    def get_checkout_intent(self, none_if_link_disabled=False):
 | 
			
		||||
        if self.checkout_intent_id is None:
 | 
			
		||||
            return None
 | 
			
		||||
        return helloasso.get_checkout_intent(self.checkout_intent_id)
 | 
			
		||||
        return helloasso.get_checkout_intent(self.checkout_intent_id, none_if_link_disabled=none_if_link_disabled)
 | 
			
		||||
 | 
			
		||||
    def create_checkout_intent(self):
 | 
			
		||||
        checkout_intent = self.get_checkout_intent()
 | 
			
		||||
        checkout_intent = self.get_checkout_intent(none_if_link_disabled=True)
 | 
			
		||||
        if checkout_intent is not None:
 | 
			
		||||
            return checkout_intent
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user