Beispiel #1
0
def init_bookables(category_key):
    room_title = ['Sleep with  style', 'The Apartment', 'Bed & breakfast']
    room_gallery = ['https://picasaweb.google.com/110836571215849032642/FerdinandRoom3', 'https://picasaweb.google.com/110836571215849032642/FerdinandRoom2', 'https://picasaweb.google.com/110836571215849032642/FerdinandRoom1']
    room_description = ['<p>Party tassel brew art organic brony. Of helvetica brooklyn liberal dumpster gastropub anim Carles. Ut magna gluten-free fixie fresh before. Letterpress chillwave non-ethical wes gluten-free ethical. Fresh viraliphone dubstep sriracha twee wayfarers farm-to-table. Bennie art suntincididunt hog.</p><p>Beer frado delectus original sunt delectus.Delectus classy local selvage whatever bushwick. Vegan letterpresswayfarers wayfarers chowder.</p>',
                        '<br>Wes whatever anim trust-fund fin party original vinyl fixie. Polaroid <b>street-art</b> frado chowder Instagram sriracha. Art beer beer whatever dumpster <i>voluptate</i> <i>Pinterest</i>. Sriracha yr original farm-to-table. Brooklyn reprehenderit hog placeat incididunt Carles sriracha.',
                        'Capitalism incididunt shot liberal viral art local beer. Bushwick sint Pinterest latte trust-fund sint. Daisy Pinterest vintage frado Carles delectus.</p><p>&nbsp;</p><ul><li>Ethical 8-bit non brew delectus</li><li>Wayfarers daisy non delectus</li><li>Local dumpster capitalism</li></ul>'
                        ]
    for i in range(0, 3):
        bm = BookableModel(visible=True, category=category_key, album_url=room_gallery[i], quantity=i + 2)
        bm.i18n = {'en': {'title': room_title[i], 'description': room_description[i]},
                   'ro': {'title': room_title[i] + 'ro', 'description': room_description[i]},
                   'hu': {'title': room_title[i] + 'hu', 'description': room_description[i]}}
        bm.put()
    pass
Beispiel #2
0
def migrate_to_version_2():
    '''
        Change bookable prices from
        {
            'lang_id': {
                'values: []
            }
        }

        To

        {
            'values': []
        }
    '''
    for bookable in BookableModel.all():
        if bookable.prices:
            old_prices = json.loads(bookable.prices)
            if 'ro' in old_prices:
                new_prices = old_prices['ro']
                bookable.prices = json.dumps(new_prices)
            else:
                bookable.prices = None
        else:
            bookable.prices = None
        bookable.put()
Beispiel #3
0
def transform(bkng):
    to_date = lambda sstr: date_helper.to_date(sstr)
    bkng['quantity'] = int(bkng['quantity'])
    bkng['guests'] = int(bkng['guests'])
    bkng['start'] = to_date(bkng['start'])
    bkng['end'] = to_date(bkng['end'])
    bkng['bookable'] = BookableModel.get_by_id(long(bkng['bookable']))
    return bkng
    pass
Beispiel #4
0
def get_bookings_for_bookable(entity_id):
    bookable = BookableModel.get_by_id(entity_id)
    bookings = bookable.get_bookings_that_end_after(datetime.today())
    bookings = [{
        'start': date.to_str(e.start),
        'end': date.to_str(e.end),
        'quantity': e.quantity
    } for e in bookings]

    return json.dumps(bookings)
Beispiel #5
0
def admin_move_bookable(entityId):
    bookable = BookableModel.get_by_id(entityId)
    jsd = request_helper.get_json_data()
    bookable.category = CategoryModel.get_by_id(long(jsd['category_id']))
    bookable.put()
    return json.dumps(bookable.to_dict())
Beispiel #6
0
def admin_delete_bookable(entity_id):
    if request.method == 'DELETE' or request.values['_method'] == 'DELETE':
        BookableModel.get_by_id(entity_id).delete()
        return "{ 'value' : 'OK' }"
    pass