Exemplo n.º 1
0
def home():
    lang_id = si18n.get_lang_id()
    is_admin = users.is_current_user_admin()

    qry = CategoryModel.all().filter("parent_category", None)
    if not is_admin:
        qry = qry.filter("visible", True)

    categories = [e.to_dict() for e in qry]
    prod = "Development" not in os.environ["SERVER_SOFTWARE"]
    return render_template(
        "/main.html",
        js_data={
            "categories": categories,
            "languages": prop.get_languages(),
            "currency": currency.get_data(),
            "language": lang_id,
            "bookings": [],
            "si18n": si18n.translations_js,
            "is_admin": is_admin,
            "new_bookings_nr": BookingModel.get_number_of_new() if is_admin else 0,
        },
        is_admin=is_admin,
        is_production=prod,
        logout_url=users.create_logout_url("/"),
    )
    pass
Exemplo n.º 2
0
def get_or_create_user(user):
    email = user['email']
    usr = UserModel.all().filter('email', email).get()
    if not usr:
        usr = UserModel(
            email=email,
            phone=user['phone'],
            full_name=user['full_name'],
            language=si18n.get_lang_id(),
            citizenship=user['citizenship']
        )
        usr.put()
    else:
        usr.language = si18n.get_lang_id()
        usr.put()
    return usr
Exemplo n.º 3
0
def render_mail_template(which, booking_info):
    key_base = 'mail.' + which + '.' + si18n.get_lang_id()
    subject_template = unicode(prop.get_all_props()[key_base + '.subject'])
    body_template = unicode(prop.get_all_props()[key_base + '.body'])

    return (
        render(subject_template, booking_info),
        render(body_template, booking_info)
    )
Exemplo n.º 4
0
def render(string, booking_info):
    lang_id = si18n.get_lang_id()
    string = iterate_and_replace(string, 'user', booking_info['user'])
    string = iterate_and_replace(
        string,
        'bookable.i18n',
        booking_info['bookable']['i18n'][lang_id])
    string = iterate_and_replace(string, 'bookable', booking_info['bookable'])
    string = iterate_and_replace(string, 'booking', booking_info)
    return string