示例#1
0
def top_nav():
    lsg = LeftSubgroup(
        View('News', '.blog'), View('About Us', '.about'),
        Subgroup('Education', View('Students', '.students'),
                 View('Lessons', '.lessons')))
    if current_user.is_authenticated:
        user_menu = [
            View('My Events', '.events'),
            View('Submitted Abstracts', '.theses'),
            Separator(),
            View('Profile', '.user', _user=current_user.id),
            View('Edit Profile', '.profile'),
            Separator(),
            View('Logout', '.logout')
        ]
        if current_user.role_is(UserRole.ADMIN):
            user_menu.insert(2, View('Email Templates', '.emails'))

        rsg = RightSubgroup(
            Subgroup('Searching', View('Search', '.search'), Separator(),
                     View('History', '.queries')),
            Subgroup('Modeling', View('Modeling', '.predictor'), Separator(),
                     View('History', '.results')),
            Subgroup(current_user.full_name, *user_menu))
    else:
        rsg = RightSubgroup(
            View('Searching', '.search'), View('Modeling', '.predictor'),
            View('Login', '.login', next=get_redirect_target()
                 or request.path))

    return Navbar(View(LAB_SHORT, '.index'), *[lsg, rsg])
示例#2
0
def createFuzzjobLinks():
    fuzzjobLinks = [
        Link('Overview', '/projects'),
        Separator(),
        Link('Create Fuzzjob', '/projects/createProject'),
        Separator()
    ]
    return createFuzzjobsNav(fuzzjobLinks)
示例#3
0
def createLocationsLinks():
    locationsLinks = [
        Link('Overview', '/locations'),
        Separator(),
        Link('Create Location', '/locations/createLocation'),
        Separator()
    ]

    return createLocationsNav(locationsLinks)
示例#4
0
def mynavbar():
    if current_user.is_anonymous:
        navbar = Navbar('', View(gettext(u'Login'), 'user.login'))
    elif current_user.has_roles('Admin'):
        navbar = Navbar(
            '',
            View(gettext(u'Home'), 'books.index'),
            Subgroup(
                gettext(u'Books'),
                View(gettext(u'New Book'), 'books.new_book'),
                View(gettext(u'List'), 'books.index'),
                View(gettext(u'Search'), 'books.search'),
            ),
            Subgroup(
                current_user.username,
                View(gettext(u'Add user'), 'auth.register'),
                View(gettext(u'User list'), 'auth.userlist'),
                View(gettext(u'Show Barcde'),
                     'auth.barcode',
                     userid=current_user.id),
                View(gettext(u'Edit password'),
                     'auth.edit',
                     userid=current_user.id),
                Separator(),
                View(gettext(u'Logout'), 'user.logout'),
            ),
        )
    else:
        navbar = Navbar(
            '',
            View(gettext(u'Home'), 'books.index'),
            Subgroup(
                gettext(u'Books'),
                View(gettext(u'List'), 'books.index'),
                View(gettext(u'Search'), 'books.search'),
            ),
            Subgroup(
                current_user.username,
                View(gettext(u'Show Barcde'),
                     'auth.barcode',
                     userid=current_user.id),
                View(gettext(u'Edit password'),
                     'auth.edit',
                     userid=current_user.id),
                Separator(),
                View(gettext(u'Logout'), 'user.logout'),
            ),
        )

    return navbar
示例#5
0
def moodnavbar():
    sg1 = Subgroup("Moods", View("Mood", "mood"), View(
        "Mood List", "moodlist"), Separator(), View("Statistics", "personalstats"))
    sg2 = Subgroup("Teams", View("Team", "team"),
                   View("Team List", "teamlist"))
    sg3 = Subgroup("Auth", View("Login", "security.login"), View("Profile", "profile"), View("Logout", "security.logout"), View("Change password", "security.change_password"),
                   Separator(), View("Register", "security.register"))
    if (current_user.is_authenticated):
        msg = "Welcome "
        if current_user.name:
            msg = msg + current_user.name
        else:
            msg = msg + current_user.email
    else:
        msg = "Please login or register"
    return (Navbar('Mood', View('Home', 'index'), sg1, sg2, sg3, View("Admin", "admin.index"), Text(msg)))
示例#6
0
def navbar():
    return Navbar(
        'Ryan Ground Hotel',
        View('Home', 'home'),
        View('Register', 'register'),
        View('Log in', 'login'),
        View('Log out', 'logout'),
        View('Profile', 'profile'),
        View('Check in', 'checkin'),
        View('Check out', 'checkout'),
        Subgroup(
            'Staff',
            View('Add Staff', 'add_staff'),
            View('Remove Staff', 'remove_staff'),
        ),
        Subgroup(
            'Bookings',
            View('View Bookings', 'booking'),
            View('Make a Booking', 'make_book_form'),
            View('Cancel', 'cancel_booking_form'),
            View('Price', 'change_price_form'),
        ),
        Subgroup(
            'Test',
            View('admin role', 'special_admin'),
            View('guest role', 'special_guest'),
            Separator(),
            Text('Testing'),
            View('Login required', 'special'),
        ),
    )
示例#7
0
def mynavbar():
    """Menu da aplicação."""
    items = [
        View(logo, 'index'),
        View('Pesquisar arquivos', 'files'),
        View('Pesquisa lote com anomalia', 'lotes_anomalia'),
        View('Estatísticas', 'stats'),
        Subgroup(
            'Outros',
            View('Pesquisa imagem externa', 'similar_file'),
            View('Pesquisa textual', 'text_search'),
            Separator(),
            View('Cadastra Filtro de Auditoria', 'auditoria'),
            View('Mudar senha', 'account'),
            Separator(),
            View('Importar Bson', 'upload_bson'),
        ),
    ]
    if current_user.is_authenticated:
        items.append(View('Sair', 'commons.logout'))
    return Navbar(*items)
示例#8
0
def mynavbar():
    return Navbar(
        'Sample App',
        View('Standard', 'index'),
        View('Alternative', 'alternative'),
        Subgroup(
            'Products',
            View('Standard SG1', 'index'),
            Separator(),
            View('Alternative SG1', 'alternative'),
            Link('Github', '//github.com/hfilimonescu/flask-bs4/'),
        ),
        Link('Github', '//github.com/hfilimonescu/flask-bs4/'),
    )
示例#9
0
def mynavbar():
    """Menu da aplicação."""
    items = [
        View('Home', 'index'),
        View('Risco', 'risco'),
        View('Editar Riscos', 'edita_risco'),
        View('Pesquisa Fichas', 'pesquisa_ovr'),
        View('Minhas Fichas', 'minhas_ovrs'),
        View('Kanban', 'fichas_em_abas'),
        Subgroup(
            'Pesquisas/relatórios',
            View('Pesquisa Contêiner', 'consulta_container'),
            View('Pesquisa CE Mercante', 'consulta_ce'),
            View('Pesquisa DUE', 'consulta_due'),
            View('Pesquisa Empresa', 'consulta_empresa'),
            View('Pesquisa Verificações físicas', 'pesquisa_rvf'),
            Separator(),
            View('Relatórios', 'ver_relatorios'),
            View('Painel de OKRs', 'ver_okrs'),
            Separator(),
            View('Assistente de Contrafação', 'autos_contrafacao'),
        ),
        Subgroup(
            'Administração/exportações',
            View('Exporta Planilha CEN Rilo', 'exporta_cen_rilo'),
            View('Gerador de documentos docx', 'gera_docx'),
            View('Lista para escaneamento no Operador',
                 'escaneamento_operador'),
            Separator(),
            View('Importa planilhas recintos', 'importa_planilha_recinto'),
            View('Administração', 'admin.index'),
        )
    ]
    if current_user.is_authenticated:
        items.append(View('Sair (%s)' % current_user.id, 'commons.logout'))
    return Navbar(logo, *items)
示例#10
0
def append_dynamic():
    to_append: list = []

    if data.SESSION_LOGIN_KEY in session:
        lgn_key = session[data.SESSION_LOGIN_KEY]
        acc = account_manager.get_account_by_login_key(lgn_key)

        if acc is None:
            to_append.append(View("Login", "frontend_user.login"))
            del session[data.SESSION_LOGIN_KEY]
        else:
            to_append.append(Subgroup("Account Management",
                                      View("My Account Data", "frontend_user.user_summary"),
                                      Separator(),
                                      View("Logout", "frontend_user.logout")))
    else:
        to_append.append(View("Login", "frontend_user.login"))

    return nav_items + to_append
示例#11
0
def member():
    return Navbar(
        SidedViewImage(
            'https://pf1010.systemsbiology.net/static/images/pflogo_isblogo.png',
            'Project Feed 1010', True, 'social.index'),
        View('Home', 'social.index'), View('Explore', 'dav.explore'),
        View('Search Systems', 'social.search_systems'),
        Subgroup('Socialize', View('Friends', 'social.friends'),
                 View('Groups', 'social.groups')),
        View('Resources', 'frontend.resources'),
        View('Questions?', 'frontend.contact'),
        SidedSubgroup(
            session['displayName'],
            False,
            View('View Profile', 'social.profile', google_id='me'),
            View('Edit Profile', 'social.editprofile'),
            Separator(),
            View('Logout', 'social.logout'),
        ))
示例#12
0
def append_dynamic(navitems):
    to_append = []

    if identity_entry_uid_key in session:
        to_append.append(
            Subgroup(
                "我的資料",
                View("我的開鍋紀錄",
                     "frontend.recent_new_data_by_user",
                     uid=session[identity_entry_uid_key]), Separator(),
                Text("精靈管理"), View("我的精靈一覽",
                                   "frontend_user.view_owned_pokemon"),
                View("新增我的精靈", "frontend_user.submit_owned_pokemon")))
    else:
        to_append.append(
            View("登記身分",
                 "frontend_user.user_verify",
                 prev=url_for("frontend.index")))

    return navitems + to_append
示例#13
0
def top_nav():
    return Navbar(
        View('Flask-Bootstrap', '.index'),
        View('Home', '.index'),
        View('Logout', '.logout') if session.get('logged_in') else View(
            'Login', '.form_login'),
        View('Artikel', '.artikel'),
        Subgroup(
            'Docs',
            Link('Flask-Bootstrap', 'http://pythonhosted.org/Flask-Bootstrap'),
            Link('Flask-AppConfig', 'https://github.com/mbr/flask-appconfig'),
            Link('Flask-Debug', 'https://github.com/mbr/flask-debug'),
            Separator(),
            Text('Bootstrap'),
            Link('Getting started',
                 'http://getbootstrap.com/getting-started/'),
            Link('CSS', 'http://getbootstrap.com/css/'),
            Link('Components', 'http://getbootstrap.com/components/'),
            Link('Javascript', 'http://getbootstrap.com/javascript/'),
            Link('Customize', 'http://getbootstrap.com/customize/'),
        ),
        # Text('Using Flask-Bootstrap {}'.format(FLASK_BOOTSTRAP_VERSION)),
    )
示例#14
0
def homenavbar():
    return Navbar(
        'Story Tracker',
        View('Flask-Bootstrap', 'storys.index'),
        View('Home', 'storys.index'),
        View('Register', 'users.register'),
        View('Login', 'users.login'),
        # View('Forms Example', '.example_form'),
        # View('Debug-Info', 'debug.debug_root'),
        Subgroup(
            'Docs',
            Link('Flask-Bootstrap', 'http://pythonhosted.org/Flask-Bootstrap'),
            Link('Flask-AppConfig', 'https://github.com/mbr/flask-appconfig'),
            Link('Flask-Debug', 'https://github.com/mbr/flask-debug'),
            Separator(),
            Text('Bootstrap'),
            Link('Getting started', 'http://getbootstrap.com/getting-started/'),
            Link('CSS', 'http://getbootstrap.com/css/'),
            Link('Components', 'http://getbootstrap.com/components/'),
            Link('Javascript', 'http://getbootstrap.com/javascript/'),
            Link('Customize', 'http://getbootstrap.com/customize/'), ),
        Text('Using Flask-Bootstrap {}'.format(FLASK_BOOTSTRAP_VERSION)),
    )
示例#15
0
def frontend_top():
    # Sample navbar with left and right align
    # TODO: Adapt to dnd map and incorporate dynamic logged in/out nav items
    return ExtendedNavbar(
        title=View('Flask-Bootstrap', 'frontend.index'),
        root_class='navbar navbar-inverse',
        items=(
            View('Home', 'frontend.index'),
            View('Debug-Info', 'frontend.index'),
            Subgroup(
                'Docs',
                Link(
                    'Flask-Bootstrap',
                    'http://pythonhosted.org/Flask-Bootstrap',
                ),
                Link(
                    'Flask-AppConfig', 'https://github.com/mbr/flask-appconfig'
                ),
                Link('Flask-Debug', 'https://github.com/mbr/flask-debug'),
                Separator(),
                Text('Bootstrap'),
                Link(
                    'Getting started',
                    'http://getbootstrap.com/getting-started/',
                ),
                Link('CSS', 'http://getbootstrap.com/css/'),
                Link('Components', 'http://getbootstrap.com/components/'),
                Link('Javascript', 'http://getbootstrap.com/javascript/'),
                Link('Customize', 'http://getbootstrap.com/customize/'),
            ),
        ),
        right_items=(
            Text('Using Flask-Bootstrap {}'.format(FLASK_BOOTSTRAP_VERSION)),
            View('SignUp', 'frontend.index'),
        ),
    )
示例#16
0
文件: nav.py 项目: louking/members
def nav_menu():
    navbar = Navbar('nav_menu')

    contexthelp = {}

    class add_view():
        def __init__(self, basehelp):
            self.basehelp = basehelp.format(docversion=__docversion__)

        def __call__(self, navmenu, text, endpoint, **kwargs):
            prelink = kwargs.pop('prelink', None)
            navmenu.items.append(View(text, endpoint, **kwargs))
            contexthelp[url_for(
                endpoint, **kwargs)] = self.basehelp + slugify(text + ' view')
            if not prelink:
                contexthelp[url_for(
                    endpoint,
                    **kwargs)] = self.basehelp + slugify(text + ' view')
            else:
                contexthelp[url_for(
                    endpoint,
                    **kwargs)] = self.basehelp + slugify(prelink + ' ' + text +
                                                         ' view')

        def nomenu_help(self, text, endpoint, **kwargs):
            prelink = kwargs.pop('prelink', None)
            if not prelink:
                contexthelp[url_for(
                    endpoint,
                    **kwargs)] = self.basehelp + slugify(text + ' view')
            else:
                contexthelp[url_for(
                    endpoint,
                    **kwargs)] = self.basehelp + slugify(prelink + ' ' + text +
                                                         ' view')

    org_admin_view = add_view(
        'https://members.readthedocs.io/en/{docversion}/organization-admin-reference.html#'
    )
    leadership_admin_view = add_view(
        'https://members.readthedocs.io/en/{docversion}/leadership-task-admin-reference.html#'
    )
    leadership_superadmin_view = add_view(
        'https://members.readthedocs.io/en/{docversion}/super-admin-reference.html#'
    )
    leadership_member_view = add_view(
        'https://members.readthedocs.io/en/{docversion}/leadership-task-member-guide.html#'
    )
    membership_admin_view = add_view(
        'https://members.readthedocs.io/en/{docversion}/membership-admin-guide.html#'
    )
    meetings_admin_view = add_view(
        'https://members.readthedocs.io/en/{docversion}/meetings-admin-reference.html#'
    )
    meetings_member_view = add_view(
        'https://members.readthedocs.io/en/{docversion}/meetings-member-guide.html#'
    )
    racingteam_admin_view = add_view(
        'https://members.readthedocs.io/en/{docversion}/racingteam-admin-reference.html#'
    )

    # create context help menu items for views which can't be navigated to from the main menu
    if g.interest:
        meetings_member_view.nomenu_help('My Status Report',
                                         'admin.memberstatusreport',
                                         interest=g.interest)
        meetings_member_view.nomenu_help('RSVP',
                                         'admin.rsvp',
                                         interest=g.interest)
        meetings_admin_view.nomenu_help('Meeting',
                                        'admin.meeting',
                                        interest=g.interest)
        meetings_admin_view.nomenu_help('Meeting Status',
                                        'admin.meetingstatus',
                                        interest=g.interest)

    if current_user.is_authenticated:
        navbar.items.append(View('Home', 'admin.home', interest=g.interest))
        # deeper functions are only accessible when interest is set
        if g.interest:
            # leadership member stuff
            if (current_user.has_role(ROLE_LEADERSHIP_MEMBER)
                    or current_user.has_role(ROLE_LEADERSHIP_ADMIN)
                    or current_user.has_role(ROLE_SUPER_ADMIN)):
                leadership_member_view(navbar,
                                       'Task Checklist',
                                       'admin.taskchecklist',
                                       interest=g.interest)

            # organization admin stuff visible to all members admins
            if (current_user.has_role(ROLE_MEETINGS_ADMIN)
                    or current_user.has_role(ROLE_LEADERSHIP_ADMIN)
                    or current_user.has_role(ROLE_MEMBERSHIP_ADMIN)
                    or current_user.has_role(ROLE_SUPER_ADMIN)):
                orgadmin = Subgroup('Organization')
                navbar.items.append(orgadmin)
                org_admin_view(orgadmin,
                               'Distribution List',
                               'admin.distribution',
                               interest=g.interest)
                org_admin_view(orgadmin, 'Members', 'userrole.members')
                org_admin_view(orgadmin,
                               'Positions',
                               'admin.positions',
                               interest=g.interest)
                org_admin_view(orgadmin,
                               'Position Dates',
                               'admin.positiondates',
                               interest=g.interest)
                org_admin_view(orgadmin,
                               'Tags',
                               'admin.tags',
                               interest=g.interest)

            # meetings member stuff
            if (current_user.has_role(ROLE_MEETINGS_MEMBER)
                    or current_user.has_role(ROLE_MEETINGS_ADMIN)
                    or current_user.has_role(ROLE_SUPER_ADMIN)):
                meetingsviews = Subgroup('Meetings')
                navbar.items.append(meetingsviews)
                # meetings admin stuff
                if current_user.has_role(
                        ROLE_MEETINGS_ADMIN) or current_user.has_role(
                            ROLE_SUPER_ADMIN):
                    meetings_admin_view(meetingsviews,
                                        'Meetings',
                                        'admin.meetings',
                                        interest=g.interest)
                    meetings_admin_view(meetingsviews,
                                        'Action Items',
                                        'admin.actionitems',
                                        interest=g.interest)
                    meetings_admin_view(meetingsviews,
                                        'Motions',
                                        'admin.motions',
                                        interest=g.interest)
                    meetings_admin_view(meetingsviews,
                                        'Motion Votes',
                                        'admin.motionvotes',
                                        interest=g.interest)
                    meetings_admin_view(meetingsviews,
                                        'Agenda Headings',
                                        'admin.agendaheadings',
                                        interest=g.interest)
                    meetings_admin_view(meetingsviews,
                                        'Invites',
                                        'admin.invites',
                                        interest=g.interest)
                    meetings_admin_view(meetingsviews,
                                        'Meeting Types',
                                        'admin.meetingtypes',
                                        interest=g.interest)
                    meetingsviews.items.append(Separator())

                meetings_member_view(meetingsviews,
                                     'My Meetings',
                                     'admin.mymeetings',
                                     interest=g.interest)
                meetings_member_view(meetingsviews,
                                     'My Action Items',
                                     'admin.myactionitems',
                                     interest=g.interest)
                # todo: should this be disabled if no motionvotes for this user?
                meetings_member_view(meetingsviews,
                                     'My Motion Votes',
                                     'admin.mymotionvotes',
                                     interest=g.interest)
                # not sure there is any need for this
                # meetings_member_view(meetingsviews, 'My Discussion Items', 'admin.memberdiscussions', interest=g.interest)

                # meetings member, not admin
                if not (current_user.has_role(ROLE_MEETINGS_ADMIN)
                        or current_user.has_role(ROLE_SUPER_ADMIN)):
                    meetings_member_view(meetingsviews,
                                         'Action Items',
                                         'admin.memberactionitems',
                                         interest=g.interest,
                                         prelink='member')
                    meetings_member_view(meetingsviews,
                                         'Motions',
                                         'admin.membermotions',
                                         interest=g.interest,
                                         prelink='member')

            # leadership admin stuff
            if current_user.has_role(
                    ROLE_LEADERSHIP_ADMIN) or current_user.has_role(
                        ROLE_SUPER_ADMIN):
                leadershipadmin = Subgroup('Tasks')
                navbar.items.append(leadershipadmin)
                leadership_admin_view(leadershipadmin,
                                      'Member Summary',
                                      'admin.membersummary',
                                      interest=g.interest)
                leadership_admin_view(leadershipadmin,
                                      'Task Details',
                                      'admin.taskdetails',
                                      interest=g.interest)
                leadership_admin_view(leadershipadmin,
                                      'Task Groups',
                                      'admin.taskgroups',
                                      interest=g.interest)
                leadership_admin_view(leadershipadmin,
                                      'Tasks',
                                      'admin.tasks',
                                      interest=g.interest)
                leadership_admin_view(leadershipadmin,
                                      'Task Fields',
                                      'admin.taskfields',
                                      interest=g.interest)
                leadership_admin_view(leadershipadmin,
                                      'History',
                                      'admin.history',
                                      interest=g.interest)

            # membership admin stuff
            if current_user.has_role(
                    ROLE_MEMBERSHIP_ADMIN) or current_user.has_role(
                        ROLE_SUPER_ADMIN):
                membershipadmin = Subgroup('Membership')
                navbar.items.append(membershipadmin)
                membership_admin_view(membershipadmin,
                                      'Club Members',
                                      'admin.clubmembers',
                                      interest=g.interest)
                membership_admin_view(membershipadmin,
                                      'Memberships',
                                      'admin.memberships',
                                      interest=g.interest)
                membershipadmin.items.append(
                    View('Membership Stats',
                         'frontend.membershipstats',
                         interest=g.interest))

            # racingteam admin stuff
            if current_user.has_role(
                    ROLE_RACINGTEAM_ADMIN) or current_user.has_role(
                        ROLE_SUPER_ADMIN):
                racingteamadmin = Subgroup('Racing Team')
                navbar.items.append(racingteamadmin)
                racingteam_admin_view(racingteamadmin,
                                      'Members',
                                      'admin.rt_members',
                                      interest=g.interest)
                racingteam_admin_view(racingteamadmin,
                                      'Info Results',
                                      'admin.rt_inforesults',
                                      interest=g.interest)
                racingteam_admin_view(racingteamadmin,
                                      'Info Volunteer',
                                      'admin.rt_infovol',
                                      interest=g.interest)
                racingteam_admin_view(racingteamadmin,
                                      'Applications',
                                      'admin.rt_applns',
                                      interest=g.interest)
                racingteam_admin_view(racingteamadmin,
                                      'Application Results',
                                      'admin.rt_applnresults',
                                      interest=g.interest)
                racingteam_admin_view(racingteamadmin,
                                      'Date Range',
                                      'admin.rt_daterange',
                                      interest=g.interest)
                racingteam_admin_view(racingteamadmin,
                                      'Config',
                                      'admin.rt_config',
                                      interest=g.interest)

        # superadmin stuff
        if current_user.has_role(ROLE_SUPER_ADMIN):
            userroles = Subgroup('Super')
            navbar.items.append(userroles)
            leadership_superadmin_view(userroles, 'Interest Attributes',
                                       'admin.interestattrs')

            if g.interest:
                leadership_superadmin_view(userroles,
                                           'Email Templates',
                                           'admin.emailtemplates',
                                           interest=g.interest)
                leadership_superadmin_view(userroles,
                                           'Document Templates',
                                           'admin.doctemplates',
                                           interest=g.interest)

            leadership_superadmin_view(userroles, 'Roles', 'userrole.roles')
            leadership_superadmin_view(userroles, 'Interests',
                                       'userrole.interests')
            leadership_superadmin_view(userroles, 'Applications',
                                       'userrole.applications')

            if g.interest:
                leadership_superadmin_view(userroles,
                                           'Files',
                                           'admin.files',
                                           interest=g.interest)

            navbar.items.append(View('My Account', 'security.change_password'))
            userroles.items.append(View('Debug', 'admin.debug'))

        # finally for non ROLE_SUPER_ADMIN
        else:
            navbar.items.append(View('My Account', 'security.change_password'))

    else:
        navbar.items.append(View('Home', 'frontend.home', interest=g.interest))
        if g.interest:
            usermemberssviews = Subgroup('Membership')
            navbar.items.append(usermemberssviews)
            usermemberssviews.items.append(
                View('Registered Members',
                     'frontend.members',
                     interest=g.interest))
            usermemberssviews.items.append(
                View('Membership Stats',
                     'frontend.membershipstats',
                     interest=g.interest))

    # common items
    if g.interest:
        pass
    navbar.items.append(View('About', 'admin.sysinfo'))
    if request.path in contexthelp:
        navbar.items.append(Link('Help', contexthelp[request.path]))

    return navbar
示例#17
0
from flask import session, render_template, url_for, request
from flask_nav import Nav
from flask_nav.elements import Navbar, View, Subgroup, Link, Text, Separator, RawTag

from data.thirdparty import identity_entry_uid_key

nav = Nav()

nav_items = [
    View("探險尋寶攻略情報站", "frontend.index"),
    View("首頁", "frontend.index"),
    Subgroup("資料查詢", View("查詢精靈資料", "frontend.pokemon_profile_index"),
             Separator(), View("從精靈查食譜", "frontend.find_recipe_index"),
             View("從食譜查精靈", "frontend.find_pokemon_index"),
             View("從技能查精靈", "frontend.poke_skill_index")),
    View("提交結果", "frontend_user.submit_result"),
    View("關於", "frontend.about")
]


def append_dynamic(navitems):
    to_append = []

    if identity_entry_uid_key in session:
        to_append.append(
            Subgroup(
                "我的資料",
                View("我的開鍋紀錄",
                     "frontend.recent_new_data_by_user",
                     uid=session[identity_entry_uid_key]), Separator(),
                Text("精靈管理"), View("我的精靈一覽",
示例#18
0
from flask_nav.elements import Navbar, View, Link, Text, Separator
from flask_nav.renderers import Renderer
from dominate import tags


class JustDivRenderer(Renderer):
    def visit_Navbar(self, node):

        sub = []
        for item in node.items:
            sub.append(self.visit(item))

        return tags.div('Navigation:', *sub)

    def visit_View(self, node):

        return tags.div('{} ({})'.format(node.title, node.get_url()))

    def visit_Subgroup(self, node):

        # almost the same as visit_Navbar, but written a bit more concise
        return tags.div(node.title, *[self.visit(item) for item in node.items])


nav_bar = (View('Home', 'landing'), View('Visual One', 'visual_1'),
           View('Visual Two', 'visual_2'), View('Visual Three', 'visual_3'),
           View('Visual Four', 'visual_4'), View('Visual Five', 'visual_5'),
           Link('Google', 'www.google.com'), Separator(), Text('HR'))
示例#19
0
def create_app():

    # instantiate the app
    app = Flask(__name__,
                template_folder='../client/templates',
                static_folder='../client/static')

    from cabotage.server.models.auth import User, Role
    user_datastore = SQLAlchemyUserDatastore(db, User, Role)

    from cabotage.server.user.forms import (
        ExtendedConfirmRegisterForm,
        ExtendedLoginForm,
        ExtendedRegisterForm,
    )

    from flask_nav import Nav
    from flask_nav.elements import Navbar, View, Separator, Subgroup

    nav = Nav()

    anonymous_nav = Navbar(
        'Cabotage',
        View('Register', 'security.register'),
        View('Log In', 'security.login'),
    )
    logged_in_nav = Navbar(
        'Cabotage',
        Subgroup(
            'Orgs',
            View('All My Orgs', 'user.organizations'),
        ),
        Subgroup(
            'Projects',
            View('All My Projects', 'user.projects'),
        ),
        Subgroup(
            'Account',
            Separator(),
            View('Change Password', 'security.change_password'),
            View('Log Out', 'security.logout'),
        ),
    )
    nav.register_element('anonymous', anonymous_nav)
    nav.register_element('logged_in', logged_in_nav)

    # set config
    app_settings = os.getenv('APP_SETTINGS', 'cabotage.server.config.Config')
    app.config.from_object(app_settings)

    # set up extensions
    bcrypt.init_app(app)
    toolbar.init_app(app)
    bootstrap.init_app(app)
    security.init_app(
        app,
        user_datastore,
        confirm_register_form=ExtendedConfirmRegisterForm,
        register_form=ExtendedRegisterForm,
        login_form=ExtendedLoginForm,
    )
    vault_db_creds.init_app(app)
    db.init_app(app)
    mail.init_app(app)
    migrate.init_app(app, db)
    nav.init_app(app)
    humanize.init_app(app)
    consul.init_app(app)
    vault.init_app(app)
    kubernetes.init_app(app)
    config_writer.init_app(app, consul, vault)
    minio.init_app(app)
    celery.init_app(app)
    github_app.init_app(app)

    # register blueprints
    from cabotage.server.user.views import user_blueprint
    from cabotage.server.main.views import main_blueprint
    app.register_blueprint(user_blueprint)
    app.register_blueprint(main_blueprint)

    # error handlers
    @app.errorhandler(401)
    def unauthorized_page(error):
        return render_template('errors/401.html'), 401

    @app.errorhandler(403)
    def forbidden_page(error):
        return render_template('errors/403.html'), 403

    @app.errorhandler(404)
    def page_not_found(error):
        return render_template('errors/404.html'), 404

    @app.errorhandler(500)
    def server_error_page(error):
        return render_template('errors/500.html'), 500

    return app
示例#20
0
from flask import Flask, render_template
from flask_nav import Nav
from flask_nav.elements import Navbar, Subgroup, View, Link, Text, Separator
from flask_bootstrap import Bootstrap
app = Flask(__name__)
Bootstrap(app)

nav = Nav(app)

view1 = View('Home Page', 'index')
view2 = View('Item One', 'items', item = 1)
link1 = Link('Google', 'https://www.google.com')
sep1 = Separator()
text = Text('Here is some text')
subgroup = Subgroup('Subgroup', view1, view2, link1)
navbar = Navbar('name_doesnt_matter', view1, view2, link1, text, subgroup)
nav.register_element('my_navbar',navbar)

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/items/<item>')
def items(item):
    return '<h1>The item is {}</h1>'.format(item)

if __name__ == '__main__':
    app.run(debug = True)
示例#21
0
# navbar has an usual amount of Link-Elements, more commonly you will have a
# lot more View instances.
nav.register_element(
    'frontend_top',
    Navbar(
        View('PyLoggi', '.index'),
        View('Home', '.index'),
        View('Forms Example', '.example_form'),
        View('Debug-Info', 'debug.debug_root'),
        View('About', '.about'),
        Subgroup(
            'Docs',
            Link('About', '/about'),
            Link('Flask-AppConfig', 'https://github.com/mbr/flask-appconfig'),
            Link('Flask-Debug', 'https://github.com/mbr/flask-debug'),
            Separator(),
            Text('Bootstrap'),
            Link('Getting started',
                 'http://getbootstrap.com/getting-started/'),
            Link('CSS', 'http://getbootstrap.com/css/'),
            Link('Components', 'http://getbootstrap.com/components/'),
            Link('Javascript', 'http://getbootstrap.com/javascript/'),
            Link('Customize', 'http://getbootstrap.com/customize/'),
        ),
        Text('Using Flask-Bootstrap {}'.format(FLASK_BOOTSTRAP_VERSION)),
    ))


# Our index-page just shows a quick explanation. Check out the template
# "templates/index.html" documentation for more details.
@frontend.route('/')
示例#22
0
from flask import Flask, render_template, request, redirect, url_for

from model import Donor, Donation

from flask_nav import Nav
from flask_nav.elements import Navbar, View, Separator

app = Flask(__name__)
nav = Nav(app)

app.secret_key = b'\x92+\x9b\x0fK{\xc1m\xe5\xe0\xaee\xbe\xcfA\xb0\xe9j|\xce\x8c\xa2\xc0\xf4'

nav.register_element(
    'my_navbar',
    Navbar('thenav', View('Home Page', 'home'), View('Donate', 'donate'),
           Separator()))


@app.route('/')
def home():
    return redirect(url_for('all'))


@app.route('/donations/')
def all():
    donations = Donation.select()
    return render_template('donations.jinja2', donations=donations)


@app.route('/donate/', methods=['GET', 'POST'])
def donate():