Fundraising in PDF.
[wolnelektury.git] / src / paypal / models.py
1 # This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
3 #
4 # from django.contrib.auth import get_user_model
5 from django.contrib.auth.models import User
6 from django.db import models
7
8
9 class BillingPlan(models.Model):
10     plan_id = models.CharField(max_length=32)
11     amount = models.IntegerField(db_index=True, unique=True)
12
13
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)
20
21     def check_agreement(self):
22         from .rest import check_agreement
23         return check_agreement(self.agreement_id)
24
25     def get_donations(self, year):
26         from .rest import get_donations
27         return get_donations(self.agreement_id, year)