def __call__(self): if self.request.method=="POST" and self.update(): return HTTPFound(location=route_url("home", self.request)) return render("profile.pt", self.request, context=self.context, status_int=202 if self.request.method=="POST" else 200, form=self.form, action_url=route_url("profile", self.request))
def __call__(self): if self.request.method=="POST": if self.request.POST["action"]=="cancel" or self.save(): return HTTPFound(location=route_url("customer_view", self.request, id=self.context.id)) return render("customer_edit.pt", self.request, self.context, status_int=202 if self.request.method=="POST" else 200, view=self, section="customers", action_url=route_url("customer_edit", self.request, id=self.context.id))
def __call__(self): if self.request.method == "POST" and self.update(): return HTTPFound(location=route_url("home", self.request)) return render("profile.pt", self.request, context=self.context, status_int=202 if self.request.method == "POST" else 200, form=self.form, action_url=route_url("profile", self.request))
def __call__(self): if self.request.method == "POST": if self.request.POST["action"] == "cancel" or self.save(): return self.cancel() return render("invoice_edit.pt", self.request, self.context, status_int=202 if self.request.method == "POST" else 200, view=self, section="customers")
def __call__(self): if self.request.method == "POST": if self.request.POST["action"] == "cancel" or self.save(): return HTTPFound(location=route_url("customers", self.request)) return render("customer_edit.pt", self.request, status_int=202 if self.request.method == "POST" else 200, view=self, section="customers", action_url=route_url("customer_add", self.request))
def __call__(self): if self.request.method == "POST": if self.request.POST["action"] == "cancel" or self.save(): return self.cancel() return render( "invoice_edit.pt", self.request, self.context, status_int=202 if self.request.method == "POST" else 200, view=self, section="customers", )
def View(context, request): session=meta.Session() invoices=session.query(Invoice)\ .filter(Invoice.customer==context)\ .order_by(Invoice.sent.desc())\ .options(orm.joinedload(Invoice.entries)) summary=summaryInvoices(invoices) return render("customer_view.pt", request, context, section="customers", edit_url=route_url("customer_edit", request, id=context.id), **summary)
def Overview(request): user=currentUser(request) session=meta.Session() customers=session.query(Customer.id, Customer.title, Customer.invoice_code)\ .filter(Customer.account==user)\ .order_by(Customer.title) customers=[dict(id=row.id, title=row.title, invoice_code=row.invoice_code, url=route_url("customer_view", request, id=row.id)) for row in customers] return render("customer_overview.pt", request, section="customers", customers=customers)
def __call__(self): if self.request.method=="POST": if self.request.POST["action"]=="cancel": return HTTPFound(location=route_url("home", self.request)) account=self.save() if account: response=HTTPFound(location=route_url("dashboard", self.request)) loginUser(account, self.request, response) return response return render("signup.pt", self.request, status_int=202 if self.request.method=="POST" else 200, view=self, action_url=route_url("signup", self.request))
def View(context, request): session = meta.Session() invoices=session.query(Invoice)\ .filter(Invoice.customer==context)\ .order_by(Invoice.sent.desc())\ .options(orm.joinedload(Invoice.entries)) summary = summaryInvoices(invoices) return render("customer_view.pt", request, context, section="customers", edit_url=route_url("customer_edit", request, id=context.id), **summary)
def __call__(self): if self.request.method == "POST": if self.request.POST["action"] == "cancel" or self.save(): return HTTPFound(location=route_url( "invoice_view", self.request, id=self.context.id)) return render("invoice_paid.pt", self.request, self.context, status_int=202 if self.request.method == "POST" else 200, section="customers", view=self, action_url=route_url("invoice_paid", self.request, id=self.context.id))
def Overview(request): user = currentUser(request) session = meta.Session() invoices = ( session.query(Invoice) .select_from(orm.join(Invoice, Customer)) .filter(Customer.account == user) .order_by(Invoice.sent.desc()) .options(orm.joinedload(Invoice.entries)) ) summary = summaryInvoices(invoices) return render("invoice_overview.pt", request, section="invoices", **summary)
def Send(context, request): if request.method == "POST": if not checkCSRF(request): raise Forbidden("Invalid CSRF token") if request.POST.get("action", "cancel") == "confirm": context.send() return HTTPFound( location=route_url("invoice_view", request, id=context.id)) return render("invoice_send.pt", request, context, status_int=202 if request.method == "POST" else 200, section="customers", action_url=route_url("invoice_send", request, id=context.id))
def __call__(self): if self.request.method=="POST": account=self.login() if account: came_from=self.request.POST.get("came_from") if came_from: response=HTTPFound(location=came_from) else: response=HTTPFound(location=route_url("dashboard", self.request)) loginUser(account, self.request, response) return response return render("login.pt", self.request, status_int=202 if self.request.method=="POST" else 200, login_url=route_url("login", self.request), form=self.form)
def Print(context, request): from z3c.rml.document import Document from repoze.bfg.renderers import render from lxml import etree from cStringIO import StringIO from webob import Response rml = render("checking:rml/invoice.rml.pt", {}, request) doc = Document(etree.fromstring(rml)) output = StringIO() doc.process(output) output.seek(0) response = Response(output.read()) response.content_type = "application/pdf" response.headers.add("Content-Disposition", "attachment; filename=%s.pdf" % (context.number or "draft")) return response
def __call__(self): if self.request.method == "POST": if self.request.POST["action"] == "cancel": return dict(action="close") if self.save(): return dict(action="reload") return render( "invoice_paid.pt", self.request, self.context, status_int=202 if self.request.method == "POST" else 200, section="customers", view=self, action_url=route_url("invoice_paid", self.request, id=self.context.id), )
def Send(context, request): if request.method == "POST": if not checkCSRF(request): raise Forbidden("Invalid CSRF token") if request.POST.get("action", "cancel") == "confirm": context.send() return HTTPFound(location=route_url("invoice_view", request, id=context.id)) return render( "invoice_send.pt", request, context, status_int=202 if request.method == "POST" else 200, section="customers", action_url=route_url("invoice_send", request, id=context.id), )
def Overview(request): user = currentUser(request) session = meta.Session() invoices=session.query(Invoice)\ .select_from(orm.join(Invoice, Customer))\ .filter(Customer.account==user)\ .order_by(Invoice.sent.desc())\ .options(orm.joinedload(Invoice.entries)) summary = summaryInvoices(invoices) return render("invoice_overview.pt", request, section="invoices", **summary)
def __call__(self): if self.request.method == "POST": if self.request.POST["action"] == "cancel": return HTTPFound(location=route_url("home", self.request)) account = self.save() if account: response = HTTPFound( location=route_url("dashboard", self.request)) loginUser(account, self.request, response) return response return render("signup.pt", self.request, status_int=202 if self.request.method == "POST" else 200, view=self, action_url=route_url("signup", self.request))
def __call__(self): if self.request.method == "POST": if self.request.POST["action"] == "cancel": return dict(action="close") if self.save(): return dict(action="reload") return render("invoice_paid.pt", self.request, self.context, status_int=202 if self.request.method == "POST" else 200, section="customers", view=self, action_url=route_url("invoice_paid", self.request, id=self.context.id))
def Overview(request): user = currentUser(request) session = meta.Session() customers=session.query(Customer.id, Customer.title, Customer.invoice_code)\ .filter(Customer.account==user)\ .order_by(Customer.title) customers = [ dict(id=row.id, title=row.title, invoice_code=row.invoice_code, url=route_url("customer_view", request, id=row.id)) for row in customers ] return render("customer_overview.pt", request, section="customers", customers=customers)
def AjaxDelete(context, request): if request.method == "POST": if not checkCSRF(request): raise Forbidden("Invalid CSRF token") if request.POST.get("action", "cancel") == "confirm": meta.Session.delete(context) return dict(action="redirect", location=route_url("customer_view", request, id=context.customer_id)) return dict(action="close") return render( "invoice_delete.pt", request, context, status_int=202 if request.method == "POST" else 200, section="customers", action_url=route_url("invoice_delete", request, id=context.id), )
def Print(context, request): from z3c.rml.document import Document from repoze.bfg.renderers import render from lxml import etree from cStringIO import StringIO from webob import Response rml = render("checking:rml/invoice.rml.pt", {}, request) doc = Document(etree.fromstring(rml)) output = StringIO() doc.process(output) output.seek(0) response = Response(output.read()) response.content_type = "application/pdf" response.headers.add( "Content-Disposition", "attachment; filename=%s.pdf" % (context.number or "draft")) return response
def __call__(self): if self.request.method == "POST": account = self.login() if account: came_from = self.request.POST.get("came_from") if came_from: response = HTTPFound(location=came_from) else: response = HTTPFound( location=route_url("dashboard", self.request)) loginUser(account, self.request, response) return response return render("login.pt", self.request, status_int=202 if self.request.method == "POST" else 200, login_url=route_url("login", self.request), form=self.form)
def AjaxDelete(context, request): if request.method == "POST": if not checkCSRF(request): raise Forbidden("Invalid CSRF token") if request.POST.get("action", "cancel") == "confirm": meta.Session.delete(context) return dict(action="redirect", location=route_url("customer_view", request, id=context.customer_id)) return dict(action="close") return render("invoice_delete.pt", request, context, status_int=202 if request.method == "POST" else 200, section="customers", action_url=route_url("invoice_delete", request, id=context.id))
def View(request): return render("frontpage.pt", request, login_url=route_url("login", request))
def View(request): return render("dashboard.pt", request, context=currentUser(request))
def View(context, request): return render("invoice_view.pt", request, context, section="customers")
def Forbidden(request): form = formish.Form(LoginSchema(), defaults=dict(came_from=request.url)) return render("login.pt", request, login_url=route_url("login", request), form=form)