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 Comment(context, request): if request.method == "POST": try: data = form.CSRFForm(NoteSchema()).validate(request) except formish.FormError: return HTTPFound(location=route_url("invoice_view", request, id=context.id)) context.notes.append(InvoiceNote(comment=data["comment"])) return HTTPFound(location=route_url("invoice_view", request, id=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 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 Comment(context, request): if request.method == "POST": try: data = form.CSRFForm(NoteSchema()).validate(request) except formish.FormError: return HTTPFound( location=route_url("invoice_view", request, id=context.id)) context.notes.append(InvoiceNote(comment=data["comment"])) return HTTPFound( location=route_url("invoice_view", request, id=context.id))
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 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": 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 __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 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 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 handle_add(self, converted): customer = Customer() self._apply_data(customer, converted) session = DBSession() session.add(customer) statusmessage.show(self.request, u"Customer added.", "success") return HTTPFound(location=route_url('customers', self.request))
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 handle_submit(self, converted): session = DBSession() company = session.query(Company).first() changed = self._apply_data(company, converted) if changed: statusmessage.show(self.request, u"Changes saved.", "success") else: statusmessage.show(self.request, u"No changes saved.", "notice") return HTTPFound(location=route_url('company', self.request))
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 handle_submit(self, converted): customer_id = self.request.matchdict['customer'] session = DBSession() customer = session.query(Customer).filter_by(id=customer_id).one() changed = self._apply_data(customer, converted) if changed: statusmessage.show(self.request, u"Changes saved.", "success") else: statusmessage.show(self.request, u"No changes saved.", "notice") return HTTPFound(location=route_url('customers', self.request))
def handle_submit(self, converted): invoice_id = self.request.matchdict['invoice'] session = DBSession() invoice = session.query(Invoice).filter_by(id=invoice_id).one() changed = self._apply_data(invoice, converted) if changed: statusmessage.show(self.request, u"Changes saved.", "success") else: statusmessage.show(self.request, u"No changes saved.", "notice") return HTTPFound(location=route_url('invoices', 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 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 handle_add(self, converted): session = DBSession() invoice = Invoice() invoice.company = session.query(Company).first() self._apply_data(invoice, converted) session.add(invoice) # Get and add unique invoice number if invoice.invoice_number is None: invoice.invoice_number = next_invoice_number() statusmessage.show(self.request, u"Invoice added.", "success") return HTTPFound(location=route_url('invoices', 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": 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 __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 __call__(self): text = self.request.params.get('text', '') page = int(self.request.params.get('page', 1)) estimated = 0 results = [] pagebar = "" if text: catalog = getUtility(ICatalogSearch) estimated, results = catalog.search(text, page-1) link_format = route_url('search', self.request, _query=[('text',text), ('page', 1)])[:-1] pagebar = Paginator(page=page, items_per_page=20, item_count=estimated, link_format=link_format).pager(format='$link_previous $link_first ~9~ $link_next $link_last') return super(SearchView, self).__call__(text=text, results=results, pagebar=pagebar)
def base_url(self, model=''): path = model_path(model) if model else '' return route_url('books', self.request, traverse=path)
def handle_cancel(self): statusmessage.show(self.request, u"No changes saved.", "notice") return HTTPFound(location=route_url('invoices', self.request))
def route_url(self, name, *args, **kw): return route_url(name, self.request, *args, **kw)
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)
def Logout(request): response = HTTPFound(location=route_url("home", request)) logoutUser(request, response) return response
def action(self): return route_url("customer_add_invoice", self.request, id=self.customer.id)
def View(request): return render("frontpage.pt", request, login_url=route_url("login", request))
def Logout(request): response=HTTPFound(location=route_url("home", request)) logoutUser(request, response) return response
def cancel(self): return HTTPFound(location=route_url( "customer_view", self.request, id=self.customer.id))
def cancel(self): return HTTPFound(location=route_url("invoice_view", self.request, id=self.context.id))
def cancel(self): return HTTPFound(location=route_url( "invoice_view", self.request, id=self.context.id))
def action(self): return route_url("invoice_edit", self.request, id=self.context.id)
def cancel(self): return HTTPFound(location=route_url("customer_view", self.request, id=self.customer.id))