示例#1
0
def _before():
    # Force all connections to be secure
    if app.config['REQUIRE_SSL'] and not request.is_secure :
        return redirect(request.url.replace("http://", "https://"))

    #ensure that nothing is served from the instance directory
    if 'instance' in request.url:
        abort(404)
        
    #import pdb;pdb.set_trace()
    
    shotglass.get_app_config(app)
    shotglass.set_template_dirs(app) #g.template_list is now a list of templates
    
    get_db()
    session.permanent = True
    
    # Is the user signed in?
    g.user = None
    if 'user' in session:
        g.user = session['user']
        
        
    g.admin = Admin(g.db) # This is where user access rules are stored
    g.admin.register(User,
            url_for('tools.view_log'),
            display_name='View Log',
            top_level = True,
            minimum_rank_required=500,
        )
    shotglass.user_setup() # g.admin now holds access rules Users, Prefs and Roles
    inventory.register_admin()
    
    # g.menu_items should be a list of dicts
    #  with keys of 'title' & 'url' used to construct
    #  the non-table based items in the main menu
    g.menu_items = [
        {'title':'Home','url':url_for('item.display')},
        {'title':'Inventory Items','url':url_for('item.display')},
        {'title':'Stock Report','url':url_for('item.stock_report')},
        ]
示例#2
0
def _before():
    # Force all connections to be secure
    if app.config['REQUIRE_SSL'] and not request.is_secure:
        return redirect(request.url.replace("http://", "https://"))

    #ensure that nothing is served from the instance directory
    if 'instance' in request.url:
        return abort(404)

    #import pdb;pdb.set_trace()

    session.permanent = True

    shotglass.get_site_config(app)
    shotglass.set_template_dirs(app)

    get_db()

    # Is the user signed in?
    g.user = None
    if 'user' in session:
        g.user = session['user']

    #g.menu_items = shotglass.get_menu_items()
    g.menu_items = [
        {
            'title': 'Home',
            'url': '/'
        },
        # {'title':'RSVP','url':url_for('www.rsvp')},
        # {'title':'Where to Stay','url':url_for('www.render_for', filename='where_to_stay')},
        # {'title':'Things to Do','url':url_for('www.render_for', filename='things_to_do')},
        # {'title':'Shopping','url':url_for('www.render_for', filename='shopping')},
        # {'title':'The Menu','url':url_for('www.render_for', filename='menu')},
        # {'title':'Churches','url':url_for('www.render_for',filename='churches')},
        # {'title':'Questions','url':url_for('www.contact')},
    ]

    g.admin = Admin(g.db)  # This is where user access rules are stored
    shotglass.user_setup(
    )  # g.admin now holds access rules Users, Prefs and Roles
示例#3
0
def _before():
    # Force all connections to be secure
    if app.config['REQUIRE_SSL'] and not request.is_secure:
        return redirect(request.url.replace("http://", "https://"))

    #ensure that nothing is served from the instance directory
    if 'instance' in request.url:
        abort(404)

    #import pdb;pdb.set_trace()

    shotglass.get_app_config(app)
    shotglass.set_template_dirs(app)

    get_db()

    # Is the user signed in?
    g.user = None
    if 'user' in session:
        g.user = session['user']

    g.admin = Admin(g.db)  # This is where user access rules are stored
    shotglass.user_setup(
    )  # g.admin now holds access rules Users, Prefs and Roles
示例#4
0
def _before():
    # Force all connections to be secure
    if app.config['REQUIRE_SSL'] and not request.is_secure:
        return redirect(request.url.replace("http://", "https://"))

    #ensure that nothing is served from the instance directory
    if 'instance' in request.url:
        return abort(404)

    # import pdb;pdb.set_trace()
    # print(app.url_map)
    session.permanent = True

    shotglass.get_site_config(app)
    shotglass.set_template_dirs(app)

    get_db()

    # Is the user signed in?
    g.user = None
    if 'user' in session:
        g.user = session['user']

    # g.menu_items should be a list of dicts
    #  with keys of 'title' & 'url' used to construct
    #  the non-table based items in the main menu
    g.menu_items = [
        {
            'title': 'Home',
            'url': url_for('www.home')
        },
        {
            'title': 'About',
            'url': url_for('www.about')
        },
        {
            'title': 'Contact Us',
            'url': url_for('www.contact')
        },
    ]

    # g.admin items are added to the navigation menu by default
    g.admin = Admin(g.db)  # This is where user access rules are stored

    # # Add a module to the menu
    g.admin.register(
        Event,
        url_for('event.display'),
        display_name='Events',
        top_level=True,
        minimum_rank_required=500,
    )
    g.admin.register(
        Location,
        url_for('location.display'),
        display_name='Locations',
        top_level=True,
        minimum_rank_required=500,
    )

    # This one will set up the view log item
    g.admin.register(
        User,
        url_for('tools.view_log'),
        display_name='View Log',
        top_level=True,
        minimum_rank_required=500,
    )

    shotglass.user_setup(
    )  # g.admin now holds access rules Users, Prefs and Roles