1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 # from django.contrib.auth import get_user_model
6 from django.contrib.auth.models import User
7 from django.db import models
10 class BillingPlan(models.Model):
11 plan_id = models.CharField(max_length=32)
12 amount = models.IntegerField(db_index=True, unique=True)
15 class BillingAgreement(models.Model):
16 agreement_id = models.CharField(max_length=32)
17 user = models.ForeignKey(User)
18 plan = models.ForeignKey(BillingPlan)
19 active = models.BooleanField(max_length=32)
20 token = models.CharField(max_length=32)
22 def get_agreement(self):
23 from .rest import get_agreement
24 return get_agreement(self.agreement_id)
26 def check_agreement(self):
27 from .rest import check_agreement
28 return check_agreement(self.agreement_id)