From 2c2c9d3aa2498b19f2bb025ec04c942915718316 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Mon, 13 Nov 2017 23:48:54 -0600 Subject: [PATCH] moved to bootstrap4 --- applications/welcome/controllers/default.py | 37 ++++++++++++------- applications/welcome/models/menu.py | 5 --- applications/welcome/private/appconfig.ini | 1 + applications/welcome/views/default/index.html | 3 ++ applications/welcome/views/generic.html | 3 -- applications/welcome/views/layout.html | 1 + 6 files changed, 28 insertions(+), 22 deletions(-) diff --git a/applications/welcome/controllers/default.py b/applications/welcome/controllers/default.py index 8dbd426f..2225081f 100644 --- a/applications/welcome/controllers/default.py +++ b/applications/welcome/controllers/default.py @@ -1,26 +1,35 @@ # -*- coding: utf-8 -*- -# this file is released under public domain and you can use without limitations - # ------------------------------------------------------------------------- # This is a sample controller -# - index is the default action of any application -# - user is required for authentication and authorization -# - download is for downloading files uploaded in the db (does streaming) +# this file is released under public domain and you can use without limitations # ------------------------------------------------------------------------- - +# ---- example index page ---- def index(): - """ - example action using the internationalization operator T and flash - rendered by views/default/index.html or views/generic.html - - if you need a simple wiki simply replace the two lines below with: - return auth.wiki() - """ response.flash = T("Hello World") return dict(message=T('Welcome to web2py!')) +# ---- API (example) ----- +@auth.requires_login() +def api_get_user_email(): + if not request.env.request_method == 'GET': raise HTTP(403) + return response.json({'status':'success', 'email':auth.user.email}) +# ---- Smart Grid (example) ----- +@auth.requires_membership('admin') # can only be accessed by members of admin groupd +def grid(): + response.view = 'generic.html' # use a generic view + tablename = request.args(0) + if not tablename in db.tables: raise HTTP(403) + grid = SQLFORM.smartgrid(db[tablename], args=[tablename], deletable=False, editable=False) + return dict(grid=grid) + +# ---- Embedded wiki (example) ---- +def wiki(): + auth.wikimenu() # add the wiki to the menu + return auth.wiki() + +# ---- Action for login/register/etc (required for auth) ----- def user(): """ exposes: @@ -39,7 +48,7 @@ def user(): """ return dict(form=auth()) - +# ---- action to server uploaded static content (required) --- @cache.action() def download(): """ diff --git a/applications/welcome/models/menu.py b/applications/welcome/models/menu.py index 7644a1b5..1aed04d3 100644 --- a/applications/welcome/models/menu.py +++ b/applications/welcome/models/menu.py @@ -108,8 +108,3 @@ if not configuration.get('app.production'): ]), ] -# ---------------------------------------------------------------------------------------------------------------------- -# maybe add a wiki menu if app embeds wiki pages -# ---------------------------------------------------------------------------------------------------------------------- -if "auth" in locals(): - auth.wikimenu() diff --git a/applications/welcome/private/appconfig.ini b/applications/welcome/private/appconfig.ini index 30887335..e367e963 100644 --- a/applications/welcome/private/appconfig.ini +++ b/applications/welcome/private/appconfig.ini @@ -6,6 +6,7 @@ description = a cool new app keywords = web2py, python, framework generator = Web2py Web Framework production = false +toolbar = false ; Host configuration [host] diff --git a/applications/welcome/views/default/index.html b/applications/welcome/views/default/index.html index 355cb537..4a614a1f 100644 --- a/applications/welcome/views/default/index.html +++ b/applications/welcome/views/default/index.html @@ -29,6 +29,9 @@ {{=T("Online examples")}} web2py.com {{=T('Documentation')}} + {{=T('API Example')}} + {{=T('Grid Example')}} + {{=T('Wiki Example')}} {{elif 'content' in globals():}} {{=content}} diff --git a/applications/welcome/views/generic.html b/applications/welcome/views/generic.html index 2ffbd521..56e0f78d 100644 --- a/applications/welcome/views/generic.html +++ b/applications/welcome/views/generic.html @@ -11,6 +11,3 @@ It is used as default when a view is not provided for your controllers {{elif len(response._vars)>1:}} {{=BEAUTIFY(response._vars)}} {{pass}} -{{if request.is_local:}} -{{=response.toolbar()}} -{{pass}} diff --git a/applications/welcome/views/layout.html b/applications/welcome/views/layout.html index bb87c987..41981fd0 100644 --- a/applications/welcome/views/layout.html +++ b/applications/welcome/views/layout.html @@ -94,6 +94,7 @@ {{block center}} {{include}} {{end}} + {{=response.toolbar() if configuration.get('app.toolbar') else ''}}