def admin_date(*args, **kwargs): instance = args[-1] value = get_field_value(instance, kwargs['field']) if not value: return kwargs.get('default', '') return '<span title="{0}">{1}</span>'.format( escape(str(value)), escape(naturaldate(value)), )
def display_billed_until(self, order): value = order.billed_until color = '' if value and value < timezone.now().date(): color = 'style="color:red;"' return '<span title="{raw}" {color}>{human}</span>'.format( raw=escape(str(value)), color=color, human=escape(naturaldate(value)), )
def admin_date(*args, **kwargs): instance = args[-1] value = get_field_value(instance, kwargs['field']) if not value: return kwargs.get('default', '') if isinstance(value, datetime.datetime): natural = humanize.naturaldatetime(value) else: natural = humanize.naturaldate(value) return '<span title="{0}">{1}</span>'.format( escape(str(value)), escape(natural), )
def display_billed_until(self, order): billed_until = order.billed_until red = False if billed_until: if order.service.payment_style == order.service.POSTPAY: boundary = order.service.handler.get_billing_point(order) if billed_until < boundary: red = True elif billed_until < timezone.now().date(): red = True color = 'style="color:red;"' if red else '' return '<span title="{raw}" {color}>{human}</span>'.format( raw=escape(str(billed_until)), color=color, human=escape(naturaldate(billed_until)), )
def admin_date(*args, **kwargs): instance = args[-1] date = get_field_value(instance, kwargs['field']) if not date: return kwargs.get('default', '') if isinstance(date, datetime.datetime): natural = humanize.naturaldatetime(date) else: natural = humanize.naturaldate(date) if hasattr(date, 'hour'): date = timezone.localtime(date) date = date.strftime("%Y-%m-%d %H:%M:%S %Z") else: date = date.strftime("%Y-%m-%d") return '<span title="{0}">{1}</span>'.format(date, escape(natural))
def display_billed_until(self, order): billed_until = order.billed_until red = False human = escape(naturaldate(billed_until)) if billed_until: if order.cancelled_on and order.cancelled_on <= billed_until: pass elif order.service.billing_period == order.service.NEVER: human = _("Forever") elif order.service.payment_style == order.service.POSTPAY: boundary = order.service.handler.get_billing_point(order) if billed_until < boundary: red = True elif billed_until < timezone.now().date(): red = True color = 'style="color:red;"' if red else '' return '<span title="{raw}" {color}>{human}</span>'.format( raw=escape(str(billed_until)), color=color, human=human, )