From db652484c1f6316ca3a15c82fe4649e6368572d6 Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Fri, 29 Jan 2016 14:07:55 +0000 Subject: [PATCH] Fixed bill number problem and added fee extra lines --- TODO.md | 4 +++ orchestra/contrib/bills/models.py | 5 +++- .../templates/bills/microspective-fee.html | 29 +++++++++++++++++-- .../bills/templates/bills/microspective.html | 5 ++++ orchestra/contrib/mailboxes/signals.py | 12 ++++++-- orchestra/contrib/saas/backends/owncloud.py | 2 +- 6 files changed, 51 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index 9bf5144d..bfad8a93 100644 --- a/TODO.md +++ b/TODO.md @@ -456,3 +456,7 @@ mkhomedir_helper or create ssh homes with bash.rc and such * setuppostgres use porject_name for db name and user instead of orchestra * show all available choices (plugins) on admin settings value i.e. payment methods + + + +# POSTFIX web traffic monitor '": uid=" from=<%(user)s>' diff --git a/orchestra/contrib/bills/models.py b/orchestra/contrib/bills/models.py index f14f9a33..69f56342 100644 --- a/orchestra/contrib/bills/models.py +++ b/orchestra/contrib/bills/models.py @@ -227,7 +227,7 @@ class Bill(models.Model): if self.is_open: prefix = 'O{}'.format(prefix) year = timezone.now().strftime("%Y") - bills = cls.objects.filter(number__regex=r'^%s%s[1-9]+' % (prefix, year)) + bills = cls.objects.filter(number__regex=r'^%s%s[0-9]+' % (prefix, year)) last_number = bills.order_by('-number').values_list('number', flat=True).first() if last_number is None: last_number = 0 @@ -412,6 +412,9 @@ class BillLine(models.Model): amended_line = models.ForeignKey('self', verbose_name=_("amended line"), related_name='amendment_lines', null=True, blank=True) + class Meta: + get_latest_by = 'id' + def __str__(self): return "#%i" % self.pk if self.pk else self.description diff --git a/orchestra/contrib/bills/templates/bills/microspective-fee.html b/orchestra/contrib/bills/templates/bills/microspective-fee.html index 8868851c..21f48170 100644 --- a/orchestra/contrib/bills/templates/bills/microspective-fee.html +++ b/orchestra/contrib/bills/templates/bills/microspective-fee.html @@ -24,6 +24,14 @@ margin: 10px; } +#extralines { + clear: left; + clear: right; + text-align: right; + color: #A40000; + font-weight: bold; + text-align: center; +} #number-date { font-size: large; @@ -66,7 +74,7 @@ clear: left; clear: right; text-align: right; - margin: 240px 10px 50px 10px; + margin: 40px 10px 50px 10px; font-weight: bold; color: #666; } @@ -110,13 +118,28 @@ hr {
-{% with line=bill.lines.get %} +{% with line=bill.lines.first %} {% blocktrans with ini=line.start_on|date:"F j, Y" end=line.end_on|date:"F j, Y" %}From {{ ini }} to {{ end }}{% endblocktrans %} {% endwith %}
{% endblock %} + + {% block content %} +{% block lines %} +
+{% for line in bill.lines.all %} + +{% endfor %} +
+{% endblock %} + +{% block text %}
{% blocktrans %} With your membership you are supporting ... @@ -124,6 +147,8 @@ hr {
{% endblock %} +{% endblock %} + {% block footer %}
{{ block.super }} diff --git a/orchestra/contrib/bills/templates/bills/microspective.html b/orchestra/contrib/bills/templates/bills/microspective.html index 98a9f4c8..52091115 100644 --- a/orchestra/contrib/bills/templates/bills/microspective.html +++ b/orchestra/contrib/bills/templates/bills/microspective.html @@ -69,6 +69,7 @@ {% endblock %} {% block content %} +{% block lines %}
id {% trans "description" %} @@ -106,6 +107,9 @@ {% endwith %} {% endfor %}
+{% endblock %} + +{% block totals %}

 
{% for tax, subtotal in bill.compute_subtotals.items %} @@ -121,6 +125,7 @@
{% endblock %} +{% endblock %} {% block footer %} diff --git a/orchestra/contrib/mailboxes/signals.py b/orchestra/contrib/mailboxes/signals.py index 467ce89b..bf859dac 100644 --- a/orchestra/contrib/mailboxes/signals.py +++ b/orchestra/contrib/mailboxes/signals.py @@ -1,4 +1,4 @@ -from django.db.models.signals import pre_save, post_delete +from django.db.models.signals import pre_save, post_delete, post_save from django.dispatch import receiver from . import settings @@ -37,7 +37,15 @@ def create_local_address(sender, *args, **kwargs): name=mbox.name, domain=domain, account_id=domain.account_id) if created: if domain.account_id == mbox.account_id: - addr.mailboxes.add(mbox) + mbox._post_save_add_address = addr else: addr.forward = mbox.name addr.save(update_fields=('forward',)) + + +@receiver(post_save, sender=Mailbox, dispatch_uid='mailboxes.add_local_address') +def add_local_address(sender, *args, **kwargs): + mbox = kwargs['instance'] + addr = getattr(mbox, '_post_save_add_address', None) + if addr: + addr.mailboxes.add(mbox) diff --git a/orchestra/contrib/saas/backends/owncloud.py b/orchestra/contrib/saas/backends/owncloud.py index a603ec3e..118fe3c1 100644 --- a/orchestra/contrib/saas/backends/owncloud.py +++ b/orchestra/contrib/saas/backends/owncloud.py @@ -161,7 +161,7 @@ class OwnCloudDiskQuota(OwnClouwAPIMixin, ServiceMonitor): user = self.get_user(saas) context = { 'object_id': saas.pk, - 'used': user['quota'].get('used', 0), + 'used': int(user['quota'].get('used', 0)), } sys.stdout.write('%(object_id)i %(used)i\n' % context)