django-orchestra-test/orchestra/apps/prices/models.py

37 lines
1.2 KiB
Python
Raw Normal View History

2014-05-27 15:55:09 +00:00
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import ugettext_lazy as _
2014-09-03 14:51:07 +00:00
from orchestra.core import accounts, services
2014-07-16 15:20:16 +00:00
2014-05-27 15:55:09 +00:00
from . import settings
class Pack(models.Model):
account = models.ForeignKey('accounts.Account', verbose_name=_("account"),
related_name='packs')
name = models.CharField(_("pack"), max_length=128,
choices=settings.PRICES_PACKS,
default=settings.PRICES_DEFAULT_PACK)
def __unicode__(self):
2014-07-17 16:09:24 +00:00
return self.name
2014-05-27 15:55:09 +00:00
class Rate(models.Model):
2014-07-16 15:20:16 +00:00
service = models.ForeignKey('orders.Service', verbose_name=_("service"))
2014-05-27 15:55:09 +00:00
pack = models.CharField(_("pack"), max_length=128, blank=True,
choices=(('', _("default")),) + settings.PRICES_PACKS)
quantity = models.PositiveIntegerField(_("quantity"), null=True, blank=True)
2014-07-16 15:20:16 +00:00
value = models.DecimalField(_("value"), max_digits=12, decimal_places=2)
2014-05-27 15:55:09 +00:00
class Meta:
2014-07-16 15:20:16 +00:00
unique_together = ('service', 'pack', 'quantity')
2014-05-27 15:55:09 +00:00
def __unicode__(self):
2014-07-16 15:20:16 +00:00
return "{}-{}".format(str(self.value), self.quantity)
accounts.register(Pack)
2014-09-03 14:51:07 +00:00
services.register(Pack, menu=False)