Ejemplo n.º 1
0
    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))
Ejemplo n.º 2
0
 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))
Ejemplo n.º 3
0
    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))
Ejemplo n.º 4
0
    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")
Ejemplo n.º 5
0
    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))
Ejemplo n.º 6
0
    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",
        )
Ejemplo n.º 7
0
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)
Ejemplo n.º 8
0
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)
Ejemplo n.º 9
0
 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))
Ejemplo n.º 10
0
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)
Ejemplo n.º 11
0
    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))
Ejemplo n.º 12
0
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)
Ejemplo n.º 13
0
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))
Ejemplo n.º 14
0
 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)
Ejemplo n.º 15
0
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
Ejemplo n.º 16
0
    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),
        )
Ejemplo n.º 17
0
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),
    )
Ejemplo n.º 18
0
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)
Ejemplo n.º 19
0
    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))
Ejemplo n.º 20
0
    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))
Ejemplo n.º 21
0
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)
Ejemplo n.º 22
0
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),
    )
Ejemplo n.º 23
0
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
Ejemplo n.º 24
0
    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)
Ejemplo n.º 25
0
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))
Ejemplo n.º 26
0
def View(request):
    return render("frontpage.pt", request,
            login_url=route_url("login", request))
Ejemplo n.º 27
0
def View(request):
    return render("dashboard.pt", request,
            context=currentUser(request))
Ejemplo n.º 28
0
def View(context, request):
    return render("invoice_view.pt", request, context, section="customers")
Ejemplo n.º 29
0
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)
Ejemplo n.º 30
0
def View(request):
    return render("dashboard.pt", request, context=currentUser(request))
Ejemplo n.º 31
0
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)
Ejemplo n.º 32
0
def View(context, request):
    return render("invoice_view.pt", request, context, section="customers")