示例#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))
示例#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
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
 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
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
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
    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
 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
 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
 def action(self):
     return route_url("invoice_edit", self.request, id=self.context.id)
示例#48
0
 def cancel(self):
     return HTTPFound(location=route_url("customer_view", self.request, id=self.customer.id))