def get_deposit_link(self, instance): deposit = instance.deposit if deposit is None: return "None" else: url = get_change_url(deposit) return "<a href=\"%s\">%s</a>" % (url, unicode(deposit))
def delete(self, *args, **kwargs): if self.deposit: message = "Can't delete: " + unicode(self) + " has been deposited" url = get_change_url(self) raise DepositedPaymentsException(message, url=url) else: super(Payment, self).delete(*args, **kwargs)
def quote_to_invoice(request): if request.POST: quote = Quote.objects.get(pk=request.POST["quote_id"]) invoice = quote.create_invoice(request.user) messages.info(request, "Invoice successfully created.") return HttpResponseRedirect(get_change_url(invoice)) else: messages.error(request, ("The location %s shouldn't be directly " + " browsed to.") % reverse("quote_to_invoice")) return HttpResponseRedirect(reverse("mercury:index"))
def get_template(self): try: return loader.get_template(self.template_name) except TemplateDoesNotExist: error = ("Couldn't render. " + "Template \"%s\" not found." % self.template_name) error_page = get_changelist_url(Template) raise AccountsRedirect(error, url=error_page) except TemplateSyntaxError as e: instance = Template.objects.get(name=self.template_name) error = "Couldn't render template. %s" % str(e) error_page = get_change_url(instance) raise AccountsRedirect(error, url=error_page)
def get_change_url(self): return get_change_url(self)
def get_invoice_link(self, instance): invoice = instance.invoice url = get_change_url(invoice) return "<a href=\"%s\">%s</a>" % (url, unicode(invoice))
def get_customer_link(self, instance): url = get_change_url(instance.invoice.customer) return "<a href=\"%s\">%s</a>" % (url, instance.invoice.customer.name)
def get_invoice_link(self, instance): invoice = instance.invoice url = get_change_url(invoice) return "<a href=\"%s\">%s - %s</a>" % (url, invoice, invoice.date_created)