Beispiel #1
0
def __build_dynamic_content(htmlerror):
    body = loadhtml('signin.html')
    if result == 'all':
        htmlerror = valiadtionMessage.replace('**error**',
                                              'Contrasena es requerida')
        htmlerrorUser = valiadtionMessage.replace('**error**',
                                                  'Usuario es requerido')
        body = body.replace('</password>',
                            htmlerror).replace('errorClassPass',
                                               'form-invalid-data')
        body = body.replace('</username>',
                            htmlerrorUser).replace('errorClassUser',
                                                   'form-invalid-data')
    if result == 'pass':
        htmlerror = valiadtionMessage.replace('**error**',
                                              'Contrasena es requerida')
        body = body.replace('</password>',
                            htmlerror).replace('errorClassPass',
                                               'form-invalid-data')
    elif result == 'user':
        htmlerror = valiadtionMessage.replace('**error**',
                                              'Usuario es requerido')
        body = body.replace('</username>',
                            htmlerror).replace('errorClassUser',
                                               'form-invalid-data')
    if err:
        body = body.replace('</error>',
                            htmlerror).replace('errorClass',
                                               'form-invalid-data')

    wholepage = pagetemplate.replace('**title**', 'Log In').replace('**css**', constants.DEFAULT_CSS).replace('**body**', body).replace('**scripts**', '').replace('#action', 'signin.py') \
    .replace('**menu**', helpers.header_menu_non_registered())
    print("Content-type: text/html\n\n")
    helpers.ucgiprint(wholepage)
Beispiel #2
0
def __build_dynamic_content():
    if helpers.is_request():
        __PARSER.discover_values()
    html = loadhtml("index.html").replace("**keywords**", __field_keywords())
    if not __field_keywords():
        return html.replace(
            "**content**",
            "<p>No se ha aplicado ningun criterio de busqueda.</p>")
    detail_list = __build_detail_list_html()
    if not detail_list:
        return html.replace("**content**",
                            "<p>No se ha encontrado coincidencias.</p>")
    return html.replace("**content**",
                        __content_html()).replace("**details**", detail_list)
Beispiel #3
0
def __build_dynamic_content():
    parser = FormParser()
    parser.discover_values()
    code = parser.get_value("code", "")

    if not code or not parser.elements_count:
        return ''

    conn = Connection()
    product = conn.fetch_product_by_code(code)
    if not product:
        return ''

    return loadhtml("productdetail.html").format(product.code, product.descr, product.price, \
    product.username, product.entry_date).replace("**add_qty**", __form_add_qty_content().format(product.code) if helpers.check_user_session() else '')
Beispiel #4
0
#!/usr/bin/python3
"""This script shows the suggerents for no register users"""

import sys, os

__SCRIPT_DIR = os.path.dirname(
    os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
__SCRIPT_DIR = os.path.normpath(os.path.join(__SCRIPT_DIR, '..'))
if not __SCRIPT_DIR in sys.path:
    sys.path.append(__SCRIPT_DIR)

from utils import constants
from utils.helpers import pagetemplate, valiadtionMessage, ucgiprint, loadhtml, FormParser, check_user_seesion
import urllib
from utils import helpers

body = loadhtml('survey1.html')
wholepage = pagetemplate.replace('**title**', 'Sugerencias').replace('**css**', constants.DEFAULT_CSS).replace('**body**', body).replace('#action', 'signin.py').replace('**scripts**', '<script src="../js/create_suge.js"></script>') \
.replace('**menu**', helpers.header_menu_registered())
if check_user_seesion():
    print("Content-type: text/html\n\n")
    ucgiprint(wholepage)
else:
    print("Location: signin.py")
    print("Content-type: text/plain\n")
Beispiel #5
0
def __build_dynamic_content():
    conn = Connection()
    product_list = conn.fetch_products_by_user_id(
        request_handler.fetch_authorized_user_session().user_id)
    return loadhtml("myproducts.html").replace(
        "**details**", __build_detail_list_html(product_list))
Beispiel #6
0

if helpers.request_method() == 'POST' and __process_request():
    helpers.redirect('signin.py')


def __replace_body_error(validation_name, tag_name, div_name):
    if validation_name not in __ERRORS:
        return
    html_error = valiadtionMessage.replace('**error**',
                                           __ERRORS[validation_name])
    __BODY['content'] = __BODY['content'].replace(tag_name, html_error)\
    .replace(div_name, 'form-invalid-data')


__BODY['content'] = loadhtml('signup.html')
if __CONN.errors():
    __ERRORS['validation_error'] = str(__CONN.errors())
    __replace_body_error('validation_error', '</error>', 'errorClass')

if __ERRORS:
    __replace_body_error('invalid_name', '</name>', 'errorClassName')
    __replace_body_error('invalid_username', '</username>', 'errorClassUser')
    __replace_body_error('invalid_email', "</email>", 'errorClassEmail')
    __replace_body_error('invalid_password', '</password>', 'errorClassPass')

print("Content-type: text/html\n\n")
wholepage = pagetemplate.replace('**title**', 'Sign Up').replace('**css**', constants.DEFAULT_CSS).replace('**body**', __BODY['content']).replace('**scripts**', '').replace('#action', 'signup.py') \
.replace('**menu**', helpers.header_menu_non_registered())
ucgiprint(wholepage)
Beispiel #7
0
def __build_dynamic_content():
    conn = Connection()
    results = conn.fetch_cart_products_by_user_id(request_handler.fetch_authorized_user_session().user_id)
    subtotal = sum(c.total() for c in results)
    return loadhtml("cart.html").replace("**details**", __build_detail_list_html(results)) \
    .replace("**subtotal**", str(subtotal))