Example #1
0
def book_delete(app, book, profile):
    if dbapi.book_delete(app.db, book, profile):
        # Close any open windows # TODO
        yield resp.status(key='book_deleted', code=1, template={'book': book})
    else:
        yield resp.status(key='book_not_found',
                          code=0,
                          template={'book': book})
Example #2
0
def profile_create(app, profile):
    if dbapi.profile_create(app.db, profile):
        yield resp.status(key='profile_created',
                          code=1,
                          template={'profile': profile})
    else:
        yield resp.status(key='profile_taken',
                          code=0,
                          template={'profile': profile})
Example #3
0
def profile_delete(app, profile):
    if dbapi.profile_delete(app.db, profile):
        yield resp.status(key='profile_deleted',
                          code=1,
                          template={'profile': profile})
    else:
        yield resp.status(key='profile_not_found',
                          code=0,
                          template={'profile': profile})
Example #4
0
def book_create(app, profile, book, hotkey, active_profile, **kwargs):
    try:
        dbapi.book_create(app.db, profile, book, hotkey, **kwargs)
    except dbapi.UniqueNameError:
        yield resp.status(key='book_taken', code=0)
    except dbapi.UniqueHotkeyError:
        yield resp.status(key='hotkey_taken', code=0)
    except dbapi.NoHotkeyError:
        yield resp.status(key='hotkey_missing', code=0)
    else:
        if profile == active_profile:
            for aresp in req.hotkeys_load(app, profile, book, hotkey):
                yield aresp
        yield resp.status(key='book_created', code=1, template={'book': book})
Example #5
0
def page_create(app,
                profile,
                book,
                program,
                specific=None,
                loose=None,
                init_text=None):
    id = dbapi.page_create(app.db, profile, book, program, specific, loose)
    if id:
        yield resp.status(key='page_created',
                          code=1,
                          page_id=id,
                          init_text=init_text)
    else:
        id = dbapi.page_rowid_get(app.db, profile, book, program, specific,
                                  loose)
        yield resp.status(key='page_taken', code=0, page_id=id)
Example #6
0
def settings_from_pageid(app, page_id, level: SettingSelector):
    data = {}
    page_settings = dbapi.page_get(app.db, page_id)
    if page_settings:
        data['page_settings'] = page_settings
    else:
        yield resp.status(key='page_not_found', code=0)
        return

    # Get the profile settings
    profile = page_settings.get('Profile')
    if level in (SettingSelector.all, SettingSelector.profile,
                 SettingSelector.book_and_profile,
                 SettingSelector.page_and_profile):
        profile_settings = dbapi.profile_get(app.db, profile)
        if profile_settings:
            data['profile_settings'] = profile_settings
        else:
            yield resp.status(key='profile_not_found',
                              code=0,
                              template={'profile': profile})
            return

    # Get the Book settings
    book = page_settings.get('Book')
    if level in (SettingSelector.all, SettingSelector.book,
                 SettingSelector.book_and_profile,
                 SettingSelector.page_and_book):
        book_settings = dbapi.book_get(app.db, profile, book)
        if book_settings:
            data['book_settings'] = book_settings
        else:
            yield resp.status(key='book_not_found',
                              code=0,
                              template={'book': book})
            return

    yield resp.resp('page_settings_view', settings=data)
Example #7
0
def profile_set_active(app, profile):
    dbapi.profile_set_active(app.db, profile)
    yield resp.status(key='profile_changed',
                      code=1,
                      template={'profile': profile})
Example #8
0
def page_delete(app, profile, book, program, specific=None, loose=None):
    if dbapi.page_delete(app.db, profile, book, program, specific, loose):
        yield resp.status(key='page_deleted', code=1)
    else:
        yield resp.status(key='page_not_found', code=0)
Example #9
0
def page_update_from_id(app, page_id, data):
    if dbapi.page_update_from_id(app.db, page_id, data):
        yield resp.status(key='page_updated', code=1)
    else:
        yield resp.status(key='page_not_found', code=0)