Commit 0671b9b9 authored by Michal Čihař's avatar Michal Čihař

Add better billing state tracking

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 82481281
......@@ -36,14 +36,14 @@ class PlanAdmin(admin.ModelAdmin):
class BillingAdmin(admin.ModelAdmin):
list_display = (
'user', 'plan', 'trial',
'user', 'plan', 'state',
'list_projects',
'count_changes_1m', 'count_changes_1q', 'count_changes_1y',
'count_repositories', 'count_strings', 'count_words',
'count_languages',
'in_limits',
)
list_filter = ('plan', 'trial')
list_filter = ('plan', 'state')
search_fields = ('user__username', 'projects__name')
def list_projects(self, obj):
......
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-02-10 12:59
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('billing', '0007_invoice'),
]
operations = [
migrations.AddField(
model_name='billing',
name='state',
field=models.IntegerField(choices=[(0, 'Active'), (1, 'Trial'), (2, 'Expired')], default=0),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-02-10 12:59
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('billing', '0008_billing_state'),
]
operations = [
migrations.RemoveField(
model_name='billing',
name='trial',
),
]
......@@ -55,10 +55,21 @@ class Plan(models.Model):
@python_2_unicode_compatible
class Billing(models.Model):
STATE_ACTIVE = 0
STATE_TRIAL = 1
STATE_EXPIRED = 2
plan = models.ForeignKey(Plan)
user = models.OneToOneField(User)
projects = models.ManyToManyField(Project, blank=True)
trial = models.BooleanField(default=False)
state = models.IntegerField(
choices=(
(STATE_ACTIVE, _('Active')),
(STATE_TRIAL, _('Trial')),
(STATE_EXPIRED, _('Expired')),
),
default=STATE_ACTIVE,
)
def __str__(self):
return '{0} ({1})'.format(self.user, self.plan)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment