1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 # from django.contrib.auth import get_user_model
5 from django.contrib.auth.models import User
6 from django.db import models
9 class BillingPlan(models.Model):
10 plan_id = models.CharField(max_length=32)
11 amount = models.IntegerField(db_index=True, unique=True)
14 class BillingAgreement(models.Model):
15 agreement_id = models.CharField(max_length=32)
16 schedule = models.ForeignKey('club.Schedule', models.PROTECT)
17 plan = models.ForeignKey(BillingPlan, models.PROTECT)
18 active = models.BooleanField(max_length=32)
19 token = models.CharField(max_length=32)
21 def check_agreement(self):
22 from .rest import check_agreement
23 return check_agreement(self.agreement_id)
25 def get_donations(self, year):
26 from .rest import get_donations
27 return get_donations(self.agreement_id, year)