コード例 #1
0
ファイル: members.py プロジェクト: amarandon/opencore
def _send_signup_ai_email(request, username, profile):
    """Send email to user who has signed up to site.
    """
    info = {}
    info['system_name'] = get_setting(profile, 'system_name', 'OpenCore')
    info['system_email_domain'] = get_setting(profile, 'system_email_domain')
    info['from_name'] = '%s invitation' % info['system_name']
    info['from_email'] = 'invitation@%s' % info['system_email_domain']
    info['c_title'] = info['system_name']
    info['c_description'] = ""
    info['c_href'] = request.api.app_url
    info['mfrom'] = '%s <%s>' % (info['from_name'], info['from_email'])
    info['subject'] = 'Thank you for joining the %s community' % info['system_name']
  
    body_template = get_template('templates/email_accept_signup_invitation.pt')

    mailer = getUtility(IMailDelivery)
    msg = Message()
    msg['From'] = info['mfrom']
    msg['To'] = profile.email
    msg['Subject'] = info['subject'] 
    body = body_template(
        system_name=info['system_name'],
        system_href=info['c_href'],                 
        username=username,
        )

    if isinstance(body, unicode):
        body = body.encode("UTF-8")

    msg.set_payload(body, "UTF-8")
    msg.set_type('text/html')
    mailer.send(info['mfrom'], [profile.email,], msg)    
コード例 #2
0
ファイル: members.py プロジェクト: cguardia/karl
def _send_invitation_email(request, community, community_href, invitation):
    mailer = getUtility(IMailDelivery)
    info = _get_common_email_info(community, community_href)
    subject_fmt = 'Please join the %s community at %s'
    info['subject'] = subject_fmt % (info['c_title'],
                                     info['system_name'])
    body_template = get_template('templates/email_invite_new.pt')

    msg = Message()
    msg['From'] = info['mfrom']
    msg['To'] = invitation.email
    msg['Subject'] = info['subject']
    body = body_template(
        system_name=info['system_name'],
        community_href=info['c_href'],
        community_name=info['c_title'],
        community_description=info['c_description'],
        personal_message=invitation.message,
        invitation_url=model_url(invitation.__parent__, request,
                                 invitation.__name__)
        )

    if isinstance(body, unicode):
        body = body.encode("UTF-8")

    msg.set_payload(body, "UTF-8")
    msg.set_type('text/html')
    mailer.send([invitation.email,], msg)
コード例 #3
0
ファイル: resetpassword.py プロジェクト: reebalazs/karl
 def __call__(self):
     page_title = u"Forgot Password Request"
     snippets = get_template("forms/templates/snippets.pt")
     snippets.doctype = xhtml
     blurb_macro = snippets.macros["reset_request_blurb"]
     api = TemplateAPI(self.context, self.request, page_title)
     return {"api": api, "blurb_macro": blurb_macro}
コード例 #4
0
ファイル: members.py プロジェクト: cguardia/karl
def _send_aeu_emails(community, community_href, profiles, text):
    # To make reading the add_existing_user_view easier, move the mail
    # delivery part here.

    info = _get_common_email_info(community, community_href)
    subject_fmt = 'You have been added to the %s community'
    subject = subject_fmt % info['c_title']
    body_template = get_template('templates/email_add_existing.pt')
    html_body = text

    mailer = getUtility(IMailDelivery)
    for profile in profiles:
        to_email = profile.email

        msg = Message()
        msg['From'] = info['mfrom']
        msg['To'] = to_email
        msg['Subject'] = subject
        body = body_template(
            system_name=info['system_name'],
            community_href=info['c_href'],
            community_name=info['c_title'],
            community_description=info['c_description'],
            personal_message=html_body,
            )

        if isinstance(body, unicode):
            body = body.encode("UTF-8")

        msg.set_payload(body, "UTF-8")
        msg.set_type('text/html')
        mailer.send([to_email,], msg)
コード例 #5
0
ファイル: members.py プロジェクト: cguardia/karl
def _send_ai_email(community, community_href, username, profile):
    """Send email to user who has accepted a community invitation.
    """
    info = _get_common_email_info(community, community_href)
    subject_fmt = 'Thank you for joining the %s community'
    subject = subject_fmt % info['c_title']
    body_template = get_template('templates/email_accept_invitation.pt')

    mailer = getUtility(IMailDelivery)
    msg = Message()
    msg['From'] = info['mfrom']
    msg['To'] = profile.email
    msg['Subject'] = subject
    body = body_template(
        community_href=info['c_href'],
        community_name=info['c_title'],
        community_description=info['c_description'],
        username=username,
        )

    if isinstance(body, unicode):
        body = body.encode("UTF-8")

    msg.set_payload(body, "UTF-8")
    msg.set_type('text/html')
    mailer.send([profile.email,], msg)
コード例 #6
0
ファイル: api.py プロジェクト: boothead/karl
    def __init__(self, context, request, page_title=None):
        self.context = context
        self.request = request
        self.snippets = get_template("templates/snippets.pt")
        self.snippets.doctype = xhtml
        self.userid = authenticated_userid(request)
        self.app_url = app_url = request.application_url
        self.profile_url = app_url + "/profiles/%s" % self.userid
        self.here_url = self.context_url = model_url(context, request)
        self.view_url = model_url(context, request, request.view_name)
        settings = queryUtility(ISettings)
        self.js_devel_mode = settings and getattr(settings, "js_devel_mode", None)
        self.static_url = "%s/static/%s" % (app_url, _get_static_rev())

        # Provide a setting in the INI to fully control the entire URL
        # to the static.  This is when the proxy runs a different port
        # number, or to "pipeline" resources on a different URL path.
        full_static_path = getattr(settings, "full_static_path", False)
        if full_static_path:
            if "%d" in full_static_path:
                full_static_path = full_static_path % _start_time
            self.static_url = full_static_path
        self.page_title = page_title
        self.system_name = get_setting(context, "system_name", "KARL")
        self.user_is_admin = "group.KarlAdmin" in effective_principals(request)
        site = find_site(context)
        self.admin_url = model_url(site, request, "admin.html")
        self.site_announcement = getattr(site, "site_announcement", "")
コード例 #7
0
ファイル: views.py プロジェクト: stephenbee/lqn-demo
def login(context, request):
    referrer = request.url
    if referrer == '/login.html':
        referrer = '/'  # never use the login form itself as came_from
    came_from = request.params.get('came_from', referrer)
    logging.debug("views.py::login Logging in...")
    if 'login' in request.POST.keys():
        login = request.params['login']
        password = request.params['password']
        accounts = context['accounts']
        #import pdb; pdb.set_trace()
        if password and accounts.has_key(login) and str(password) == str(
                accounts.get(login).password):
            headers = remember(request, login)
            logging.debug("views.py::login : Login OK.")
            return HTTPFound(location=came_from, headers=headers)
    master = get_template('templates/master.pt')
    logged_in = authenticated_userid(request)
    return rtr(
        'templates/login.pt',
        context=context,
        request=request,
        master=master,
        message='',
        logged_in=logged_in,
        came_from=came_from)
コード例 #8
0
ファイル: views.py プロジェクト: stephenbee/lqn-demo
def login(context, request):
    referrer = request.url
    if referrer == "/login.html":
        referrer = "/"  # never use the login form itself as came_from
    came_from = request.params.get("came_from", referrer)
    logging.debug("views.py::login Logging in...")
    if "login" in request.POST.keys():
        login = request.params["login"]
        password = request.params["password"]
        accounts = context["accounts"]
        # import pdb; pdb.set_trace()
        if password and accounts.has_key(login) and str(password) == str(accounts.get(login).password):
            headers = remember(request, login)
            logging.debug("views.py::login : Login OK.")
            return HTTPFound(location=came_from, headers=headers)
    master = get_template("templates/master.pt")
    logged_in = authenticated_userid(request)
    return rtr(
        "templates/login.pt",
        context=context,
        request=request,
        master=master,
        message="",
        logged_in=logged_in,
        came_from=came_from,
    )
コード例 #9
0
ファイル: api.py プロジェクト: amarandon/opencore
 def render_form_widget(self, widget_id, id, label, choices=[], compulsory=False, default=None, description=None, disabled=False, alt=False):
     if default is None:
         default = self.formdata.get(id, '')
     error = self.formerrors.get(id, '')
     if isinstance(error, (list, tuple)):
         error = '\n'.join(error)
     from repoze.bfg.chameleon_zpt import get_template
     #template = template_cache.get('form_widgets', createfunc=get_form_widgets)
     template = get_template('templates/form_widgets.pt')
     if isinstance(default, (list, tuple)):
         default_list = default
     else:
         default_list = [default]
     return template.render_macro(widget_id, global_scope=True,
                                  parameters=dict(name=id,
                                                  label=label,
                                                  description=description,
                                                  choices=choices,
                                                  compulsory=compulsory,
                                                  default_value=default,
                                                  default_list=default_list,
                                                  error=error,
                                                  disabled=disabled,
                                                  alt=alt,
                                                  api=self,))
コード例 #10
0
ファイル: members.py プロジェクト: amarandon/opencore
def _send_signup_email(request, invitation):
    site = find_site(request.context)
    mailer = getUtility(IMailDelivery)
    
    info = {}
    info['system_name'] = get_setting(site, 'system_name', 'OpenCore')
    info['system_email_domain'] = get_setting(site, 'system_email_domain')
    info['from_name'] = '%s invitation' % info['system_name']
    info['from_email'] = 'invitation@%s' % info['system_email_domain']
    info['c_title'] = info['system_name']
    info['c_description'] = ""
    info['c_href'] = model_url(site, request)
    info['mfrom'] = '%s <%s>' % (info['from_name'], info['from_email'])
    info['subject'] = 'Please join the %s community' % info['system_name']
    
    body_template = get_template('templates/email_signup.pt')

    msg = Message()
    msg['From'] = info['mfrom']
    msg['To'] = invitation.email
    msg['Subject'] = info['subject']
    body = body_template(
        system_name=info['system_name'],
        personal_message=invitation.message,
        invitation_url=model_url(site, request, 'signup', invitation.__name__)
        )

    if isinstance(body, unicode):
        body = body.encode("UTF-8")

    msg.set_payload(body, "UTF-8")
    msg.set_type('text/html')
    mailer.send(info['mfrom'], [invitation.email,], msg)    
コード例 #11
0
ファイル: views.py プロジェクト: stephenbee/lqn-demo
def receive(context,request):
    logging.debug("Receiving Katz...")
    post = request.POST
    logged_in = authenticated_userid(request)
    accounts = context['accounts']
    errors={}
    message = ''
    master = get_template('templates/master.pt')
    if post.has_key('amount'):
        source = post.get('source','')    
        amount = post.get('amount','')
        target = accounts.get(logged_in)
	logging.debug("Source: %s Amount: %s Target: %s",source,amount,target)
        #errors = context['transactions'].isTransactionInvalid(source,logged_in,amount)
        if str(post.get('pin','')) != str(target.password):
	    logging.error("views.py::receive Invalid pin")
            errors['pin'] = 'invalid pin'

        try:
            tacc = accounts.get(logged_in)
            sacc = accounts.get(source)
            sacc.transfer(logged_in,amount)
            return rtr('templates/paid.pt',context=context,request=request,master=master,logged_in=logged_in,source=sacc,target=tacc,amount=amount,message=message)
        except Errors, e:
            errors.update(e.message)

        if errors:
            message= 'please correct the errors'
コード例 #12
0
ファイル: alerts.py プロジェクト: boothead/karl
    def send_digests(self, context):
        mailer = getUtility(IMailDelivery)

        system_name = get_setting(context, "system_name", "KARL")
        system_email_domain = get_setting(context, "system_email_domain")
        sent_from = "%s@%s" % (system_name, system_email_domain)
        from_addr = "%s <%s>" % (system_name, sent_from)
        subject = "[%s] Your alerts digest" % system_name

        template = get_template("email_digest.pt")
        for profile in find_profiles(context).values():
            if not profile._pending_alerts:
                continue

            # Perform each in its own transaction, so a problem with one
            # user's email doesn't block all others
            transaction.manager.begin()
            try:
                attachments = []
                for alert in profile._pending_alerts:
                    attachments += alert['attachments']

                msg = MIMEMultipart() if attachments else Message()
                msg["From"] = from_addr
                msg["To"] = "%s <%s>" % (profile.title, profile.email)
                msg["Subject"] = subject

                body_text = template(
                    system_name=system_name,
                    alerts=profile._pending_alerts,
                )

                if isinstance(body_text, unicode):
                    body_text = body_text.encode("UTF-8")

                if attachments:
                    body = MIMEText(body_text, 'html', 'utf-8')
                    msg.attach(body)
                else:
                    msg.set_payload(body_text, "UTF-8")
                    msg.set_type("text/html")

                for attachment in attachments:
                    msg.attach(attachment)

                mailer.send(sent_from, [profile.email,], msg)
                del profile._pending_alerts[:]
                transaction.manager.commit()

            except Exception, e:
                # Log error and continue
                log.error("Error sending digest to %s <%s>" %
                          (profile.title, profile.email))

                b = StringIO()
                traceback.print_exc(file=b)
                log.error(b.getvalue())
                b.close()

                transaction.manager.abort()
コード例 #13
0
ファイル: people.py プロジェクト: reebalazs/karl
 def __call__(self):
     api = TemplateAPI(self.context, self.request, "Change Password")
     layout_provider = get_layout_provider(self.context, self.request)
     layout = layout_provider("generic")
     snippets = get_template("forms/templates/snippets.pt")
     snippets.doctime = xhtml
     blurb_macro = snippets.macros["change_password_blurb"]
     return {"api": api, "layout": layout, "actions": [], "blurb_macro": blurb_macro}
コード例 #14
0
ファイル: invoice.py プロジェクト: seantis/seantisinvoice
 def __call__(self):
     if "invoice" in self.request.matchdict:
         session = DBSession()
         invoice_id = self.request.matchdict['invoice']
         invoice = session.query(Invoice).filter_by(id=invoice_id).first()
         if not invoice:
             return Response(status = 404)
     
     main = get_template('templates/master.pt')
     return dict(request=self.request, main=main, msgs=statusmessage.messages(self.request))
コード例 #15
0
ファイル: resetpassword.py プロジェクト: reebalazs/karl
 def __call__(self):
     key = self.request.params.get("key")
     if not key or len(key) != 40:
         api = TemplateAPI(self.context, self.request, "Password Reset URL Problem")
         return render_template_to_response("templates/reset_failed.pt", api=api)
     snippets = get_template("forms/templates/snippets.pt")
     snippets.doctype = xhtml
     blurb_macro = snippets.macros["reset_confirm_blurb"]
     api = TemplateAPI(self.context, self.request, "Reset Password")
     return {"api": api, "blurb_macro": blurb_macro}
コード例 #16
0
ファイル: views.py プロジェクト: stephenbee/lqn-demo
def transactions(context, request):
    master = get_template('templates/master.pt')
    logged_in = authenticated_userid(request)
    return rtr(
        'templates/transactions.pt',
        context=context,
        request=request,
        master=master,
        logged_in=logged_in,
        message=None)
コード例 #17
0
ファイル: customer.py プロジェクト: seantis/seantisinvoice
 def __call__(self):
     if "customer" in self.request.matchdict:
         customer_id = self.request.matchdict['customer']
         session = DBSession()
         customer = session.query(Customer).filter_by(id=customer_id).first()
         if not customer:
             return Response(status = 404)
     
     main = get_template('templates/master.pt')
     return dict(request=self.request, main=main, msgs=statusmessage.messages(self.request))
コード例 #18
0
ファイル: utils.py プロジェクト: wichert/checking
def render(name, request, context=None, status_int=None, view=None, section=None, **kw):
    if os.path.sep!="/":
        name=name.replace("/", os.path.sep)
    template=os.path.join("templates", name)

    response=render_template_to_response(template,
                request=request, context=context, view=view, section=section,
                layout=get_template(os.path.join("templates", "layout.pt")),
                **kw)
    if status_int is not None:
        response.status_int=status_int
    return response
コード例 #19
0
    def __call__(self):
        if "invoice" in self.request.matchdict:
            session = DBSession()
            invoice_id = self.request.matchdict['invoice']
            invoice = session.query(Invoice).filter_by(id=invoice_id).first()
            if not invoice:
                return Response(status=404)

        main = get_template('templates/master.pt')
        return dict(request=self.request,
                    main=main,
                    msgs=statusmessage.messages(self.request))
コード例 #20
0
ファイル: utils.py プロジェクト: wichert/checking
def GlobalsFactory(system):
    """Globals factory to add extra globals to the variables passed to
    a template.

    This method should be registered using
    :py:meth:`repoze.bfg.configuration.Configurator.set_renderer_globals_factory`.
    """
    request=system["request"]
    return { "tools": Tools(request),
             "locale": locale,
             "formatter": formatter,
             "layout": get_template(os.path.join("templates", "layout.pt")),
           }
コード例 #21
0
ファイル: views.py プロジェクト: stephenbee/lqn-demo
def vouchers(context,request):
    master = get_template('templates/master.pt')
    logged_in = authenticated_userid(request)
    errors={}
    post = request.POST
    if 'amount' in post:
        try:
	    logging.debug("views.py::vouchers Adding voucher")
            trans = context['vouchers'].addVoucher(logged_in,post.get('amount'),request.application_url)
	    logging.debug("views.py::vouchers Adding voucher ok")
        except Errors,e:
	    logging.error(e.message)
            errors = e.message
コード例 #22
0
ファイル: adapters.py プロジェクト: boothead/karl
    def message(self):
        if self._message is not None:
            return self._message

        community = self._community
        request = self.request
        profile = self.profile
        model = self._model

        community_href = model_url(community, request)
        model_href = model_url(model, request)
        manage_preferences_href = model_url(profile, request)
        system_name = get_setting(self.context, "system_name", "KARL")
        system_email_domain = get_setting(self.context, "system_email_domain")

        body_template = get_template(self._template)
        from_name = "%s | %s" % (self.creator.title, system_name)
        msg = Message()
        msg["From"] = "%s <%s>" % (from_name, self.mfrom)
        msg["To"] = "%s <%s>" % (community.title, profile.email)
        msg["Subject"] = self._subject
        body = body_template(
            context=self.context,
            community=community,
            community_href=community_href,
            model=model,
            model_href=model_href,
            manage_preferences_href=manage_preferences_href,
            profile=profile,
            creator=self.creator,
            content_type=self._content_type_name,
            digest=self.digest,
            alert=self,
        )

        if self.digest:
            # Only interested in body for digest
            html = document_fromstring(body)
            body_element = html.cssselect('body')[0]
            span = etree.Element("span", nsmap=body_element.nsmap)
            span[:] = body_element[:] # Copy all body elements to an empty span
            body = etree.tostring(span, pretty_print=True)

        if isinstance(body, unicode):
            body = body.encode('utf-8')

        msg.set_payload(body, 'utf-8')
        msg.set_type("text/html")
        self._message = msg
        return msg
コード例 #23
0
ファイル: utils.py プロジェクト: oskarwagner/checking
def GlobalsFactory(system):
    """Globals factory to add extra globals to the variables passed to
    a template.

    This method should be registered using
    :py:meth:`repoze.bfg.configuration.Configurator.set_renderer_globals_factory`.
    """
    request = system["request"]
    return {
        "tools": Tools(request),
        "locale": locale,
        "formatter": formatter,
        "layout": get_template(os.path.join("templates", "layout.pt")),
    }
コード例 #24
0
ファイル: views.py プロジェクト: stephenbee/lqn-demo
def redeem(context, request):
    master = get_template('templates/master.pt')
    logged_in = authenticated_userid(request)
    errors = {}
    post = request.POST
    message = ''
    if context.used:
        message = 'Voucher is already used'
        logging.error("views.py::redeem " + message)
        errors['voucher'] = message
    elif post.has_key('amount'):
        try:
            logging.debug("views.py::redeem Redeeming voucher...")
            trans = context.use(logged_in, post.get('amount'))
            logging.debug("views.py::redeem Redeeming voucher ok.")
            return HTTPFound(location='/')
        except Errors, e:
            errors = e.message
コード例 #25
0
ファイル: utils.py プロジェクト: russell/lanyard
def get_base_data(context, request):
    main = get_template("../templates/master.pt")
    data = {"main": main, "project": "lanyard"}
    home_node = find_root(context)
    data["navitems"] = [
        {"href": model_url(home_node, request), "title": "Home", "state": ""},
        {
            "href": model_url(home_node.slcs, request),
            "title": home_node.slcs.__name__.upper(),
            "state": ("", "current_page_item")[home_node.slcs == context],
        },
        {
            "href": model_url(home_node.proxies, request),
            "title": "MyProxy",
            "state": ("", "current_page_item")[home_node.proxies == context],
        },
    ]
    return data
コード例 #26
0
def view_invoices(request):
    session = DBSession()
    query = session.query(Invoice)
    today = datetime.date.today()

    if 'recurring' in request.params:
        if request.params['recurring'] == '1':
            query = query.filter(Invoice.recurring_date != None)
            # We don't show the recurring invoices that have stop date in the past
            query = query.filter(Invoice.recurring_stop >= today
                                 or Invoice.recurring_stop == None)
            title = u'Recurring Invoices'
        elif request.params['recurring'] == '0':
            query = query.filter(Invoice.recurring_date == None)
            title = u'Non-recurring Invoices'
    elif 'due' in request.params and request.params['due'] == '1':
        query = query.filter(Invoice.due_date <= today)
        query = query.filter(Invoice.payment_date == None)
        title = u'Invoices due'
    else:
        title = u'All Invoices'

    # Sorting
    if 'sort' in request.params:
        sort_key = request.params['sort']
        if hasattr(Invoice, sort_key):
            sort_attr = getattr(Invoice, sort_key)
            if 'reverse' in request.params:
                sort_attr = desc(sort_attr)
            query = query.order_by(sort_attr)
    else:
        query = query.order_by(desc(Invoice.date))

    invoices = query.all()
    company = session.query(Company).first()
    main = get_template('templates/master.pt')
    return dict(request=request,
                main=main,
                invoices=invoices,
                company=company,
                title=title,
                msgs=statusmessage.messages(request),
                formatThousands=formatThousands)
コード例 #27
0
ファイル: reports.py プロジェクト: seantis/seantisinvoice
 def __call__(self):            
     
     total_amount = 0
     total_tax = 0
     
     invoices = self.invoices()
     for invoice in invoices:
         total_amount += invoice.grand_total()
         total_tax += invoice.tax_amount()
     
     main = get_template('templates/master.pt')
     return dict(request=self.request,
                 invoices=invoices,
                 main=main,
                 total_amount=total_amount,
                 total_tax=total_tax,
                 from_date=self.from_date,
                 to_date=self.to_date,
                 msgs=statusmessage.messages(self.request),
                 formatThousands=formatThousands)
コード例 #28
0
ファイル: utils.py プロジェクト: oskarwagner/checking
def render(name,
           request,
           context=None,
           status_int=None,
           view=None,
           section=None,
           **kw):
    if os.path.sep != "/":
        name = name.replace("/", os.path.sep)
    template = os.path.join("templates", name)

    response = render_template_to_response(
        template,
        request=request,
        context=context,
        view=view,
        section=section,
        layout=get_template(os.path.join("templates", "layout.pt")),
        **kw)
    if status_int is not None:
        response.status_int = status_int
    return response
コード例 #29
0
ファイル: members.py プロジェクト: cguardia/karl
def _send_moderators_changed_email(community,
                                   community_href,
                                   new_moderators,
                                   old_moderators,
                                   cur_moderators,
                                   prev_moderators):
    info = _get_common_email_info(community, community_href)
    subject_fmt = 'Change in moderators for %s'
    subject = subject_fmt % info['c_title']
    body_template = get_template('templates/email_moderators_changed.pt')

    profiles = find_profiles(community)
    all_moderators = cur_moderators | prev_moderators
    to_profiles = [profiles[name] for name in all_moderators]
    to_addrs = ["%s <%s>" % (p.title, p.email) for p in to_profiles]

    mailer = getUtility(IMailDelivery)
    msg = Message()
    msg['From'] = info['mfrom']
    msg['To'] = ",".join(to_addrs)
    msg['Subject'] = subject
    body = body_template(
        system_name=info['system_name'],
        community_href=info['c_href'],
        community_name=info['c_title'],
        new_moderators=[profiles[name].title for name in new_moderators],
        old_moderators=[profiles[name].title for name in old_moderators],
        cur_moderators=[profiles[name].title for name in cur_moderators],
        prev_moderators=[profiles[name].title for name in prev_moderators]
        )

    if isinstance(body, unicode):
        body = body.encode("UTF-8")

    msg.set_payload(body, "UTF-8")
    msg.set_type('text/html')
    mailer.send(to_addrs, msg)
コード例 #30
0
ファイル: invoice.py プロジェクト: seantis/seantisinvoice
def view_invoices(request):
    session = DBSession()
    query = session.query(Invoice)
    today = datetime.date.today()
    
    if 'recurring' in request.params:
        if request.params['recurring'] == '1':
            query = query.filter(Invoice.recurring_date != None)
            # We don't show the recurring invoices that have stop date in the past
            query = query.filter(Invoice.recurring_stop >= today or Invoice.recurring_stop == None) 
            title = u'Recurring Invoices'
        elif request.params['recurring'] == '0':
            query = query.filter(Invoice.recurring_date == None)
            title = u'Non-recurring Invoices'
    elif 'due' in request.params and request.params['due'] == '1':
        query = query.filter(Invoice.due_date <= today)
        query = query.filter(Invoice.payment_date == None)
        title = u'Invoices due'
    else:
        title = u'All Invoices'
        
    # Sorting
    if 'sort' in request.params:
        sort_key = request.params['sort']
        if hasattr(Invoice, sort_key):
            sort_attr = getattr(Invoice, sort_key)
            if 'reverse' in request.params:
                sort_attr = desc(sort_attr)
            query = query.order_by(sort_attr)
    else:
        query = query.order_by(desc(Invoice.date))
        
    invoices = query.all()
    company = session.query(Company).first()
    main = get_template('templates/master.pt')
    return dict(request=request, main=main, invoices=invoices, company=company, 
                title=title, msgs=statusmessage.messages(request), formatThousands=formatThousands)
コード例 #31
0
def view_license(request):
    main = get_template('templates/master.pt')
    return dict(request=request,
                main=main,
                msgs=statusmessage.messages(request))
コード例 #32
0
ファイル: admin.py プロジェクト: junkafarian/opencore
def _content_selection_grid():
    return get_template('templates/admin/content_select.pt').macros['grid']
コード例 #33
0
ファイル: admin.py プロジェクト: junkafarian/opencore
def _content_selection_widget():
    return get_template('templates/admin/content_select.pt').macros['widget']
コード例 #34
0
ファイル: admin.py プロジェクト: junkafarian/opencore
def _menu_macro():
    return get_template('templates/admin/menu.pt').macros['menu']
コード例 #35
0
ファイル: adapters.py プロジェクト: amarandon/opencore
 def generic_layout(self):
     return get_template('opencore.views:templates/generic_layout.pt')
コード例 #36
0
 def __call__(self):
     main = get_template('templates/master.pt')
     return dict(request=self.request,
                 main=main,
                 msgs=statusmessage.messages(self.request))
コード例 #37
0
 def __init__(self, request):
     self.request = request
     self.main_template = get_template('templates/master.pt')
     self.journal_entries = get_template('templates/journal_entries.pt')
     self.application_url = request.application_url
     self.root = request.root