예제 #1
0
파일: profile.py 프로젝트: wichert/checking
    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))
예제 #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))
예제 #3
0
파일: invoice.py 프로젝트: wichert/checking
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))
예제 #4
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))
예제 #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))
예제 #6
0
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))
예제 #7
0
파일: signup.py 프로젝트: wichert/checking
 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))
예제 #8
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))
예제 #9
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))
예제 #10
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))
예제 #11
0
파일: invoice.py 프로젝트: wichert/checking
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),
    )
예제 #12
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)
예제 #13
0
파일: invoice.py 프로젝트: wichert/checking
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),
    )
예제 #14
0
 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))
예제 #15
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)
예제 #16
0
    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))
예제 #17
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))
예제 #18
0
 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))
예제 #19
0
 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))
예제 #20
0
    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))
예제 #21
0
 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))
예제 #22
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)
예제 #23
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)
예제 #24
0
    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))
예제 #25
0
    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))
예제 #26
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)
예제 #27
0
파일: invoice.py 프로젝트: wichert/checking
    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),
        )
예제 #28
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))
예제 #29
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)
예제 #30
0
파일: views.py 프로젝트: vilos/rstlibrary
    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)
예제 #31
0
파일: views.py 프로젝트: vilos/rstlibrary
 def base_url(self, model=''):
     path = model_path(model) if model  else ''
     return route_url('books', self.request, traverse=path)
예제 #32
0
 def handle_cancel(self):
     statusmessage.show(self.request, u"No changes saved.", "notice")
     return HTTPFound(location=route_url('invoices', self.request))
예제 #33
0
 def route_url(self, name, *args, **kw):
     return route_url(name, self.request, *args, **kw)
예제 #34
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)
예제 #35
0
def Logout(request):
    response = HTTPFound(location=route_url("home", request))
    logoutUser(request, response)
    return response
예제 #36
0
파일: invoice.py 프로젝트: wichert/checking
 def action(self):
     return route_url("customer_add_invoice", self.request, id=self.customer.id)
예제 #37
0
def View(request):
    return render("frontpage.pt", request,
            login_url=route_url("login", request))
예제 #38
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)
예제 #39
0
def Logout(request):
    response=HTTPFound(location=route_url("home", request))
    logoutUser(request, response)
    return response
예제 #40
0
 def cancel(self):
     return HTTPFound(location=route_url(
         "customer_view", self.request, id=self.customer.id))
예제 #41
0
파일: invoice.py 프로젝트: wichert/checking
 def cancel(self):
     return HTTPFound(location=route_url("invoice_view", self.request, id=self.context.id))
예제 #42
0
 def action(self):
     return route_url("customer_add_invoice",
                      self.request,
                      id=self.customer.id)
예제 #43
0
 def cancel(self):
     return HTTPFound(location=route_url(
         "invoice_view", self.request, id=self.context.id))
예제 #44
0
 def action(self):
     return route_url("invoice_edit", self.request, id=self.context.id)
예제 #45
0
 def handle_cancel(self):
     statusmessage.show(self.request, u"No changes saved.", "notice")
     return HTTPFound(location=route_url('invoices', self.request))
예제 #46
0
파일: utils.py 프로젝트: wichert/checking
 def route_url(self, name, *args, **kw):
     return route_url(name, self.request, *args, **kw)
예제 #47
0
파일: invoice.py 프로젝트: wichert/checking
 def action(self):
     return route_url("invoice_edit", self.request, id=self.context.id)
예제 #48
0
파일: invoice.py 프로젝트: wichert/checking
 def cancel(self):
     return HTTPFound(location=route_url("customer_view", self.request, id=self.customer.id))