Random fixes
This commit is contained in:
parent
09025102bc
commit
8cb36619e3
4
TODO.md
4
TODO.md
|
@ -438,8 +438,6 @@ serailzer self.instance on create.
|
|||
|
||||
# Automatically mark as paid transactions with 0 or prevent its creation?
|
||||
|
||||
# Confirmation steps on amend and other billing actions
|
||||
|
||||
|
||||
@register.filter
|
||||
def comma(value):
|
||||
|
@ -449,5 +447,3 @@ def comma(value):
|
|||
return ','.join((left, right))
|
||||
return value
|
||||
|
||||
|
||||
# db_index on date_hierarchy
|
||||
|
|
|
@ -44,22 +44,20 @@ class ChangeListDefaultFilter(object):
|
|||
if hasattr(response, 'context_data') and 'cl' in response.context_data:
|
||||
response.context_data['cl'].default_changelist_filters = defaults
|
||||
return response
|
||||
|
||||
|
||||
defaults = []
|
||||
querystring = request.META['QUERY_STRING']
|
||||
redirect = False
|
||||
for field, value in self.default_changelist_filters:
|
||||
if field not in queryseting:
|
||||
redirect = True
|
||||
querystring[field] = value
|
||||
if redirect:
|
||||
raise
|
||||
if not request.META.get('HTTP_REFERER', '').startswith(request.build_absolute_uri()):
|
||||
querystring = '&'.join('%s=%s' % filed, value in querystring.items())
|
||||
from django.http import HttpResponseRedirect
|
||||
return HttpResponseRedirect(request.path + '?%s' % querystring)
|
||||
return super(ChangeListDefaultFilter, self).changelist_view(request, extra_context=extra_context)
|
||||
# defaults = []
|
||||
# querystring = request.META['QUERY_STRING']
|
||||
# redirect = False
|
||||
# for field, value in self.default_changelist_filters:
|
||||
# if field not in queryseting:
|
||||
# redirect = True
|
||||
# querystring[field] = value
|
||||
# if redirect:
|
||||
# raise
|
||||
# if not request.META.get('HTTP_REFERER', '').startswith(request.build_absolute_uri()):
|
||||
# querystring = '&'.join('%s=%s' % filed, value in querystring.items())
|
||||
# from django.http import HttpResponseRedirect
|
||||
# return HttpResponseRedirect(request.path + '?%s' % querystring)
|
||||
# return super(ChangeListDefaultFilter, self).changelist_view(request, extra_context=extra_context)
|
||||
|
||||
|
||||
class AtLeastOneRequiredInlineFormSet(BaseInlineFormSet):
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import datetime
|
||||
import importlib
|
||||
import inspect
|
||||
from functools import wraps
|
||||
|
||||
|
@ -8,7 +9,6 @@ from django.core.exceptions import ObjectDoesNotExist
|
|||
from django.core.urlresolvers import reverse, NoReverseMatch
|
||||
from django.db import models
|
||||
from django.shortcuts import redirect
|
||||
import importlib
|
||||
from django.utils.html import escape
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
|
|
|
@ -331,7 +331,9 @@ class BillAdmin(AccountAdminMixin, ExtendedModelAdmin):
|
|||
(F('lines__subtotal') + Coalesce(F('lines__sublines__total'), 0)) * (1+F('lines__tax')/100)
|
||||
),
|
||||
)
|
||||
qs = qs.prefetch_related(Prefetch('amends', queryset=Bill.objects.filter(is_open=False), to_attr='closed_amends'))
|
||||
qs = qs.prefetch_related(
|
||||
Prefetch('amends', queryset=Bill.objects.filter(is_open=False), to_attr='closed_amends')
|
||||
)
|
||||
return qs
|
||||
|
||||
def change_view(self, request, object_id, **kwargs):
|
||||
|
|
|
@ -62,10 +62,10 @@ class OrderQuerySet(models.QuerySet):
|
|||
conflictive = self.filter(service__metric='')
|
||||
conflictive = conflictive.exclude(service__billing_period=Service.NEVER)
|
||||
# Exclude rates null or all rates with quantity 0
|
||||
conflictive = conflictive.annotate(quantity_sum=Sum('service__rates__quantity')).exclude(quantity_sum=0)
|
||||
conflictive = conflictive.select_related('service').distinct().group_by('account_id', 'service')
|
||||
conflictive = conflictive.annotate(quantity_sum=Sum('service__rates__quantity'))
|
||||
conflictive = conflictive.exclude(quantity_sum=0).select_related('service').distinct()
|
||||
qs = Q()
|
||||
for account_id, services in conflictive.items():
|
||||
for account_id, services in conflictive.group_by('account_id', 'service').items():
|
||||
for service, orders in services.items():
|
||||
ini = datetime.date.max
|
||||
end = datetime.date.min
|
||||
|
@ -137,7 +137,8 @@ class Order(models.Model):
|
|||
else:
|
||||
services = [service]
|
||||
for service in services:
|
||||
orders = Order.objects.by_object(instance, service=service).select_related('service').active()
|
||||
orders = Order.objects.by_object(instance, service=service)
|
||||
orders = orders.select_related('service').active()
|
||||
if service.handler.matches(instance):
|
||||
if not orders:
|
||||
account_id = getattr(instance, 'account_id', instance.pk)
|
||||
|
|
|
@ -66,7 +66,10 @@ class TransactionQuerySet(models.QuerySet):
|
|||
source = kwargs.get('source')
|
||||
if source is None or not hasattr(source.method_class, 'process'):
|
||||
# Manual payments don't need processing
|
||||
kwargs['state']=self.model.WAITTING_EXECUTION
|
||||
kwargs['state'] = self.model.WAITTING_EXECUTION
|
||||
amount = kwargs.get('amount')
|
||||
if amount == 0:
|
||||
kwargs['state'] = self.model.SECURED
|
||||
return super(TransactionQuerySet, self).create(**kwargs)
|
||||
|
||||
def secured(self):
|
||||
|
@ -100,8 +103,8 @@ class Transaction(models.Model):
|
|||
related_name='transactions')
|
||||
source = models.ForeignKey(PaymentSource, null=True, blank=True,
|
||||
verbose_name=_("source"), related_name='transactions')
|
||||
process = models.ForeignKey('payments.TransactionProcess', null=True, on_delete=models.SET_NULL,
|
||||
blank=True, verbose_name=_("process"), related_name='transactions')
|
||||
process = models.ForeignKey('payments.TransactionProcess', null=True, blank=True,
|
||||
on_delete=models.SET_NULL, verbose_name=_("process"), related_name='transactions')
|
||||
state = models.CharField(_("state"), max_length=32, choices=STATES,
|
||||
default=WAITTING_PROCESSING)
|
||||
amount = models.DecimalField(_("amount"), max_digits=12, decimal_places=2)
|
||||
|
|
|
@ -101,8 +101,9 @@ class PHPApp(AppType):
|
|||
init_vars['disable_functions'] = ','.join(disable_functions)
|
||||
# Process timeout
|
||||
if timeout:
|
||||
timeout = max(settings.WEBAPPS_PYTHON_DEFAULT_TIMEOUT, int(timeout))
|
||||
# Give a little slack here
|
||||
timeout = str(int(timeout)-2)
|
||||
timeout = str(timeout-2)
|
||||
init_vars['max_execution_time'] = timeout
|
||||
# Custom error log
|
||||
if self.PHP_ERROR_LOG_PATH and 'error_log' not in init_vars:
|
||||
|
@ -147,4 +148,3 @@ class PHPApp(AppType):
|
|||
def get_php_version_number(self):
|
||||
php_version = self.get_php_version()
|
||||
return utils.extract_version_number(php_version)
|
||||
|
||||
|
|
Loading…
Reference in New Issue