Exemple #1
0
def render_invoce_form(invoice):  
    return """
      <div class="content">
        <p>%(certificate_link)s</p>
        <p>%(Total ePoints uploaded in this session:)s </p>
        <div id="counter"><p>%(value)s EPT</p></div>
        <form method="POST" action="%(action)s">
          <p>%(Enter ePoint RAND:)s</p>
          <p><input type="text" name="B" value="%(B)s"></p>
          <input type="hidden" name="D" value="%(D)s">
          <input type="hidden" name="G" value="%(G)s">
        </form>
      </div>
    """ % {
        'certificate_link': invoice.certificate_link,
        'value': invoice.value,
        'action': invoice.issuer + '/action',
        'B': invoice.B, 'D': invoice.D, 'G': invoice.G,
        'Enter ePoint RAND:': _('Enter ePoint RAND:'),
        'Total ePoints uploaded in this session:': _('Total ePoints uploaded in this session:')
    }
Exemple #2
0
def render_email_form(E, K, sn, action, L):
    return """
      <div class="content">
        <form method="POST" action="%(action)s">
          <p>%(Enter email address:)s</p>
          <p><input type="text" name="email" value="%(E)s"></p>
          <p>%(Enter pgp encyption key ID (optional):)s</p>
          <p><input type="text" name="pgp" value="%(K)s"></p>
          <p>%(Enable PGP/MIME:)s</p>
          <p><input type="checkbox" name="mime" checked="checked"></p>
          <input type="hidden" name="sn" value="%(sn)s">
          <input type="hidden" name="L" value="%(L)s">
          <input type="submit" value="%(Send)s">
        </form>
      </div>
    """ % {
       'action': action,
       'E': E, 'K': K, 'sn': sn, 'L': L,
       'Enter email address:': _('Enter email address:'),
       'Enter pgp encyption key ID (optional):': _('Enter pgp encyption key ID (optional):'),
       'Enable PGP/MIME:': _('Enable PGP/MIME:'),
       'Send': _('Send')
    }
Exemple #3
0
def render_invoce(invoice):
    return """
      <div class="content">
        <h1>%(message)s</h1>
        <p>%(certificate_link)s</p>
        <p>%(Total ePoints uploaded in this session:)s </p>
        <div id="counter"><p>%(value)s EPT</p></div>
      </div>
    """ % {
       'message': invoice.message, 
       'certificate_link': invoice.certificate_link,
       'value': invoice.value,
       'Total ePoints uploaded in this session:': _('Total ePoints uploaded in this session:')
    }
Exemple #4
0
def render_header():
    return """
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>

    <head>
      <title>%(title)s</title>
      <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
      <link rel="stylesheet" type="text/css" href="static/style.css">
      <link rel="icon" type="image/x-icon" href="static/epoint.ico">
    </head>

    <body>

      <div id="header">
      </div>
    """ % {'title': _('WebShop Invoice')}
Exemple #5
0
def index():
    D = request.args.get('D', None)
    B = request.args.get('B', '')
    F = request.args.get('F', None)
    E = request.args.get('E', None)
    K = request.args.get('K', None)
    L = request.args.get('L', '')
    status_code = 200
    payment_required = False
    if F is not None:
        try:
            F = int(F)
        except ValueError:
            F = 0
    else:
        F = 0
    page = [render_header()]
    if D is None:
        return _render_error_page(_('Missing parameter'),
            _('Parameter D is missing'))
    invoice = Invoice(D, B=B, F=F)
    document_source = DocumentSource(settings.ISSUER, docid=invoice.D)
    document = Document(document_source)
    value = None
    verified = document.verify()
    # document.verify() returns False if verification failed
    # and None upon another error
    if verified != False:
        value = document.get_value()
    if value is not None:
        invoice.value = value
        if value > 0:
            invoice.certificate_link = '<a href="%s/info?ID=%s">%s</a>' % (settings.ISSUER,
                invoice.D, _('GET CERTIFICATE'))
        if (value >= F) and (F is not None) and (F > 0):
            invoice.message = _('The corresponding invoice has been paid')
            page.append(render_invoce(invoice))
            # Email address
            email = ''
            if E is not None:
                set_cookie_value('pfemail', E)
                email = E
            else:
                email = request.cookies.get('pfemail')
            # PGP encryption key ID
            pgpkey = ''
            if K is not None:
                set_cookie_value('pfpgpkey', K)
                pgpkey = K
            else:
                pgpkey = request_cookies_get('pfpgpkey')
            # If mailreceipt application is configured render the email form
            if settings.MAILRECEIPT_URL:
                page.append(render_email_form(email, pgpkey, document.get_sn(),
                    settings.MAILRECEIPT_URL, L))
        else:
            if F > 0:
                payment_required = True
            status_code = 402
            invoice.G = '%s/?D=%s&F=%s' % (settings.REDIRECTION_TARGET, invoice.D,
                str(invoice.F))
            page.append(render_invoce_form(invoice))

    else:
        return self._render_error_page(_('Internal error'),
            _('Sorry for the inconvenience'))

    page.append(render_footer())
    
    response = make_response(page, status_code)
    if payment_required:
        response.headers['Content-Price'] = "%s EPT" % str(F - value)

    return response