コード例 #1
0
ファイル: menu.py プロジェクト: paweldudzinski/alchemist
def admin_menu_add_rules_file(request):
    document_file = request.POST.get('document_file', '')
    storage_helper = StorageHelper(document_file)
    try:
        file_content = storage_helper.get_file_content()
    except BadFile:
        request.session.flash(u'ERROR: File error (PDF).')

    new_filename_with_path = storage_helper.get_new_filename_with_path(file_content)
    Documents.save_original(new_filename_with_path, file_content)
    Documents.save_fixed_to_db(new_filename_with_path, Documents.RULES_MENU_FIXED_ID)
    request.session.flash(u'INFO: Lunch is added!')
    return HTTPFound(location=request.route_url('admin_rules_edit'))
コード例 #2
0
ファイル: events.py プロジェクト: paweldudzinski/alchemist
def admin_events_add_photo_and_document(request):
    document_file = request.POST.get("document_file", "")
    photo_file = request.POST.get("photo_file", "")

    # PROCESS PDF
    storage_helper = StorageHelper(document_file)
    try:
        file_content = storage_helper.get_file_content()
    except BadFile:
        request.session.flash(u"ERROR: File error (PDF).")
        return HTTPFound(location=request.route_url("admin_events_packages"))

    new_filename_with_path = storage_helper.get_new_filename_with_path(file_content)
    Documents.save_original(new_filename_with_path, file_content)
    document = Documents.save_to_db(new_filename_with_path)

    # PROCESS IMG
    storage_helper = StorageHelper(photo_file)
    try:
        file_content = storage_helper.get_file_content()
    except BadFile:
        request.session.flash(u"ERROR: File error (IMAGE).")
        return HTTPFound(location=request.route_url("admin_events_packages"))

    new_filename_with_path = storage_helper.get_new_filename_with_path(file_content)

    Photos.save_original(new_filename_with_path, file_content)
    photo = Photos.save_to_db(new_filename_with_path)

    img = storage_helper.get_pil_object(new_filename_with_path)
    Photos.resize(img, Photos.SMALL_THUMBNAIL, storage_helper.new_filename, "small_")
    Photos.resize(img, Photos.BIG_THUMBNAIL, storage_helper.new_filename, "big_")

    Event.save(photo, document)

    request.session.flash(u"INFO: Menu is added!")
    return HTTPFound(location=request.route_url("admin_events_packages"))
コード例 #3
0
ファイル: menu.py プロジェクト: paweldudzinski/alchemist
def admin_menu_add_photo_and_document(request):
    document_file = request.POST.get('document_file', '')
    photo_file = request.POST.get('photo_file', '')
    
    #PROCESS PDF
    storage_helper = StorageHelper(document_file)
    try:
        file_content = storage_helper.get_file_content()
    except BadFile:
        request.session.flash(u'ERROR: File error (PDF).')
        return HTTPFound(location=request.route_url('admin_menu_edit'))

    new_filename_with_path = storage_helper.get_new_filename_with_path(file_content)
    Documents.save_original(new_filename_with_path, file_content)
    document = Documents.save_to_db(new_filename_with_path)
    
    #PROCESS IMG
    storage_helper = StorageHelper(photo_file)
    try:
        file_content = storage_helper.get_file_content()
    except BadFile:
        request.session.flash(u'ERROR: File error (IMAGE).')
        return HTTPFound(location=request.route_url('admin_menu_edit'))

    new_filename_with_path = storage_helper.get_new_filename_with_path(file_content)
    
    Photos.save_original(new_filename_with_path, file_content)
    photo = Photos.save_to_db(new_filename_with_path)
    
    img = storage_helper.get_pil_object(new_filename_with_path)
    Photos.resize(img, Photos.SMALL_THUMBNAIL, storage_helper.new_filename, 'small_')
    Photos.resize(img, Photos.BIG_THUMBNAIL, storage_helper.new_filename, 'big_')
    
    Menu.save(photo, document)
    
    request.session.flash(u'INFO: Menu is added!')
    return HTTPFound(location=request.route_url('admin_menu_edit'))
コード例 #4
0
ファイル: menu.py プロジェクト: paweldudzinski/alchemist
def admin_rules_edit(request):
    return {
        'rules': Documents.get_rules()
    }
コード例 #5
0
ファイル: menu.py プロジェクト: paweldudzinski/alchemist
def admin_lunch_edit(request):
    return {
        'lunch': Documents.get_lunch()
    }