# Path: lambdainst/models.py
# def random_gift_code():
#     def is_paid(self):
#     def time_left(self):
#     def add_paid_time(self, time):
#     def give_trial_period(self):
#     def can_have_trial(self):
#     def remaining_trial_periods(self):
#     def on_payment_confirmed(self, payment):
#     def get_subscription(self, include_unconfirmed=False):
#     def __str__(self):
# def create_vpnuser(sender, instance, created, **kwargs):
#     def use_on(self, user):
#     def comment_head(self):
#     def __str__(self):
#     def __str__(self):
# class VPNUser(models.Model):
#     class Meta:
# class GiftCode(models.Model):
#     class Meta:
# class GiftCodeUser(models.Model):
#     class Meta:
# 
# Path: payments/models.py
# BACKENDS = {}
# 
# Path: payments/models.py
# class Payment(models.Model):
#     """ Just a payment.
#     If subscription is not null, it has been automatically issued.
#     backend_extid is the external transaction ID, backend_data is other
#     things that should only be used by the associated backend.
#     """
#     user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
#     backend_id = models.CharField(max_length=16, choices=BACKEND_CHOICES)
#     status = models.CharField(max_length=16, choices=STATUS_CHOICES, default='new')
#     created = models.DateTimeField(auto_now_add=True)
#     modified = models.DateTimeField(auto_now=True)
#     confirmed_on = models.DateTimeField(null=True, blank=True)
#     amount = models.IntegerField()
#     paid_amount = models.IntegerField(default=0)
#     time = models.DurationField()
#     subscription = models.ForeignKey('Subscription', null=True, blank=True)
#     status_message = models.TextField(blank=True, null=True)
# 
#     backend_extid = models.CharField(max_length=64, null=True, blank=True)
#     backend_data = JSONField(blank=True)
# 
#     @property
#     def currency_code(self):
#         return CURRENCY_CODE
# 
#     @property
#     def currency_name(self):
#         return CURRENCY_NAME
# 
#     @property
#     def backend(self):
#         """ Returns a global instance of the backend
#         :rtype: BackendBase
#         """
#         return BACKENDS[self.backend_id]
# 
#     def get_amount_display(self):
#         return '%.2f %s' % (self.amount / 100, CURRENCY_NAME)
# 
#     @property
#     def is_confirmed(self):
#         return self.status == 'confirmed'
# 
#     class Meta:
#         ordering = ('-created', )
# 
#     @classmethod
#     def create_payment(self, backend_id, user, months):
#         payment = Payment(
#             user=user,
#             backend_id=backend_id,
#             status='new',
#             time=timedelta(days=30 * months),
#             amount=get_price() * months
#         )
#         return payment


from datetime import timedelta, date
from .models import User
from payments.models import BACKENDS
from payments.models import Payment
import pygal
    chart = pygal.Line(fill=True, x_label_rotation=75, show_legend=False)
    chart.title = 'Users %s' % PERIOD_VERBOSE_NAME[period]
    chart.x_labels = []
    values = []
    gen = last_days(30) if period == 'm' else last_months(12)
    users = User.objects.all()

    for m in gen:
        filter_ = time_filter_future(period, m, lambda o: o.date_joined)
        users_filtered = filter(filter_, users)
        values.append(len(list(users_filtered)))
        chart.x_labels.append('%02d/%02d' % (m.month, m.day))

    chart.add('Users', values)
    return chart.render()


def payments_paid_graph(period):
    chart = pygal.StackedBar(x_label_rotation=75, show_legend=True)
    chart.x_labels = []
    gen = list(last_days(30) if period == 'm' else last_months(12))

    chart.title = 'Payments %s in €' % (PERIOD_VERBOSE_NAME[period])

    for m in gen:
        chart.x_labels.append('%02d/%02d' % (m.month, m.day))

    values = dict()
    for backend_id, backend in BACKENDS.items():
        values = []

# Path: lambdainst/models.py
# def random_gift_code():
#     def is_paid(self):
#     def time_left(self):
#     def add_paid_time(self, time):
#     def give_trial_period(self):
#     def can_have_trial(self):
#     def remaining_trial_periods(self):
#     def on_payment_confirmed(self, payment):
#     def get_subscription(self, include_unconfirmed=False):
#     def __str__(self):
# def create_vpnuser(sender, instance, created, **kwargs):
#     def use_on(self, user):
#     def comment_head(self):
#     def __str__(self):
#     def __str__(self):
# class VPNUser(models.Model):
#     class Meta:
# class GiftCode(models.Model):
#     class Meta:
# class GiftCodeUser(models.Model):
#     class Meta:
# 
# Path: payments/models.py
# BACKENDS = {}
# 
# Path: payments/models.py
# class Payment(models.Model):
#     """ Just a payment.
#     If subscription is not null, it has been automatically issued.
#     backend_extid is the external transaction ID, backend_data is other
#     things that should only be used by the associated backend.
#     """
#     user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
#     backend_id = models.CharField(max_length=16, choices=BACKEND_CHOICES)
#     status = models.CharField(max_length=16, choices=STATUS_CHOICES, default='new')
#     created = models.DateTimeField(auto_now_add=True)
#     modified = models.DateTimeField(auto_now=True)
#     confirmed_on = models.DateTimeField(null=True, blank=True)
#     amount = models.IntegerField()
#     paid_amount = models.IntegerField(default=0)
#     time = models.DurationField()
#     subscription = models.ForeignKey('Subscription', null=True, blank=True)
#     status_message = models.TextField(blank=True, null=True)
# 
#     backend_extid = models.CharField(max_length=64, null=True, blank=True)
#     backend_data = JSONField(blank=True)
# 
#     @property
#     def currency_code(self):
#         return CURRENCY_CODE
# 
#     @property
#     def currency_name(self):
#         return CURRENCY_NAME
# 
#     @property
#     def backend(self):
#         """ Returns a global instance of the backend
#         :rtype: BackendBase
#         """
#         return BACKENDS[self.backend_id]
# 
#     def get_amount_display(self):
#         return '%.2f %s' % (self.amount / 100, CURRENCY_NAME)
# 
#     @property
#     def is_confirmed(self):
#         return self.status == 'confirmed'
# 
#     class Meta:
#         ordering = ('-created', )
# 
#     @classmethod
#     def create_payment(self, backend_id, user, months):
#         payment = Payment(
#             user=user,
#             backend_id=backend_id,
#             status='new',
#             time=timedelta(days=30 * months),
#             amount=get_price() * months
#         )
#         return payment


# Path: lambdainst/graphs.py
from datetime import timedelta, date
from .models import User
from payments.models import BACKENDS
from payments.models import Payment
import pygal

    chart = pygal.Line(fill=True, x_label_rotation=75, show_legend=False)
    chart.title = 'Users %s' % PERIOD_VERBOSE_NAME[period]
    chart.x_labels = []
    values = []
    gen = last_days(30) if period == 'm' else last_months(12)
    users = User.objects.all()

    for m in gen:
        filter_ = time_filter_future(period, m, lambda o: o.date_joined)
        users_filtered = filter(filter_, users)
        values.append(len(list(users_filtered)))
        chart.x_labels.append('%02d/%02d' % (m.month, m.day))

    chart.add('Users', values)
    return chart.render()


def payments_paid_graph(period):
    chart = pygal.StackedBar(x_label_rotation=75, show_legend=True)
    chart.x_labels = []
    gen = list(last_days(30) if period == 'm' else last_months(12))

    chart.title = 'Payments %s in €' % (PERIOD_VERBOSE_NAME[period])

    for m in gen:
        chart.x_labels.append('%02d/%02d' % (m.month, m.day))

    values = dict()
    for backend_id, backend in BACKENDS.items():
        values = []

        payments = list(Payment.objects.filter(status='confirmed', backend_id=backend_id))