diff --git a/controllers/default.py b/controllers/default.py index 2225081..7f1f23a 100644 --- a/controllers/default.py +++ b/controllers/default.py @@ -1,58 +1,130 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------- -# This is a sample controller -# this file is released under public domain and you can use without limitations -# ------------------------------------------------------------------------- - -# ---- example index page ---- -def index(): - 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: - http://..../[app]/default/user/login - http://..../[app]/default/user/logout - http://..../[app]/default/user/register - http://..../[app]/default/user/profile - http://..../[app]/default/user/retrieve_password - http://..../[app]/default/user/change_password - http://..../[app]/default/user/bulk_register - use @auth.requires_login() - @auth.requires_membership('group name') - @auth.requires_permission('read','table name',record_id) - to decorate functions that need access control - also notice there is http://..../[app]/appadmin/manage/auth to allow administrator to manage users - """ - return dict(form=auth()) - -# ---- action to server uploaded static content (required) --- -@cache.action() -def download(): - """ - allows downloading of uploaded files - http://..../[app]/default/download/[filename] - """ - return response.download(request, db) +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------- +# This is a sample controller +# this file is released under public domain and you can use without limitations +# ------------------------------------------------------------------------- + +#https://helpmehelpyou/deafult/list_user_resources/user_id/page +#https://helpmehelpyou/deafult/list_user_resources/category/ + +# ---- example index page ---- +def index(): + return dict(message=T('Welcome to HelpYouHelpMe')) + + +def list_resources(): + user_id = request.args(0,cast=int) + row=db(db.resources.resource_owner==user_id).select() + return locals() + +def delete_resource(): + user_id = request.args(0,cast=int) + db(db.resources.resources_id == request.vars.resources_id).delete() + row = db(db.resources.resource_owner==user_id).select() + return locals() + +def list_id(): + row = db(db.auth_user).select() + return locals() + +def list_resource_by_category(): + category_name = request.args(0) + category=db.category(Name=category_name) + row = db(db.resources.resources_category==category).select() + return locals() + +def add_resources(): + user_id = session.auth.user.id + db.resources.resource_owner.default = user_id + form = SQLFORM(db.resources).process(next=URL('list_resources',args = user_id)) + return locals() + +def edit_resource(): + user_id = request.args(0,cast=int) + edit_id = request.vars.resources_id + edit_type = request.vars.resources_type + edit_qty = request.vars.resources_qty + try: + db(db.resources.resources_id == edit_id).update(resources_type = edit_type) + except: + pass + try: + db(db.resources.resources_id == edit_id).update(resources_qty = edit_qty) + except: + pass + specifications = db(db.resources.resource_owner==user_id).select() + return locals() + +def profile(): + return dict(form=auth.profile()) + +def category(): + row = db(db.category).select() + return locals() + +def test(): + form = SQLFORM(db.resources) + return locals() + +def search_resource(): + form = SQLFORM.factory(Field('title', requires=IS_NOT_EMPTY())) + if form.accepts(request): + tokens = form.vars.title.split() + query = reduce(lambda a,b:a&b,[db.resources.resources_type.contains(k) for k in tokens]) + people = db(query).select() + else: + people= [] + return dict(form=form,result=people) + +def list_single_resource(): + resource_id = request.args(0,cast=int) + row=db(db.resources.resources_id==resource_id).select() + return locals() + +# ---- 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: + http://..../[app]/default/user/login + http://..../[app]/default/user/logout + http://..../[app]/default/user/register + http://..../[app]/default/user/profile + http://..../[app]/default/user/retrieve_password + http://..../[app]/default/user/change_password + http://..../[app]/default/user/bulk_register + use @auth.requires_login() + @auth.requires_membership('group name') + @auth.requires_permission('read','table name',record_id) + to decorate functions that need access control + also notice there is http://..../[app]/appadmin/manage/auth to allow administrator to manage users + """ + return dict(form=auth()) + +# ---- action to server uploaded static content (required) --- +@cache.action() +def download(): + """ + allows downloading of uploaded files + http://..../[app]/default/download/[filename] + """ + return response.download(request, db) diff --git a/default.py b/default.py new file mode 100644 index 0000000..25d6330 --- /dev/null +++ b/default.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------- +# This is a sample controller +# this file is released under public domain and you can use without limitations +# ------------------------------------------------------------------------- + +#https://helpmehelpyou/deafult/list_user_resources/user_id/page +# ---- example index page ---- +def index(): + response.flash = T("Hello World") + return dict(message=T('Welcome to HelpYouHelpMe')) + +def list_resources(): + user_id = request.args(0,cast=int) + row=db(db.resources.resource_owner==user_id).select() + return locals() + +def list_id(): + row = db(db.auth_user).select() + return locals() + +def add_resources(): + form = SQLFORM(db.resources).process(next='list_user_resources/[resource_owner]') + return locals() + +def edit_resources(): + user_id = request.args(0,cast=int) + form = SQLFORM(db.resources,id).process('list_user_resources/[resource_owner]') + return locals() + +# ---- 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: + http://..../[app]/default/user/login + http://..../[app]/default/user/logout + http://..../[app]/default/user/register + http://..../[app]/default/user/profile + http://..../[app]/default/user/retrieve_password + http://..../[app]/default/user/change_password + http://..../[app]/default/user/bulk_register + use @auth.requires_login() + @auth.requires_membership('group name') + @auth.requires_permission('read','table name',record_id) + to decorate functions that need access control + also notice there is http://..../[app]/appadmin/manage/auth to allow administrator to manage users + """ + return dict(form=auth()) + +# ---- action to server uploaded static content (required) --- +@cache.action() +def download(): + """ + allows downloading of uploaded files + http://..../[app]/default/download/[filename] + """ + return response.download(request, db) diff --git a/menu.py b/menu.py new file mode 100644 index 0000000..79e8cd9 --- /dev/null +++ b/menu.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# this file is released under public domain and you can use without limitations + +# ---------------------------------------------------------------------------------------------------------------------- +# this is the main application menu add/remove items as required +# ---------------------------------------------------------------------------------------------------------------------- + +response.menu = [ + (T('Home'), False, URL('default', 'index'), []) +] +if session.auth: + user_id = session.auth.user.id +else: + user_id = None + +response.menu += [ + (T('Resources'), False,'#', [ + (T('My Resource'), False,URL('list_resources',args = user_id) if session.auth else URL('default','index')), + (T('List Users'), False, URL('list_id')), + ((T('Add Resources'), False, URL('add_resources') if session.auth else URL('default','index'))), + (T('Delete Resources'), False, URL('delete_resource',args = user_id) if session.auth else URL('default','index')) + ] + ) +] + +response.menu += [ + ((T('Category'),False, '#', [ + (T(row.Name), False, URL('list_resource_by_category',args=row.Name), []) for row in db(db.category).select()])) +] +# ---------------------------------------------------------------------------------------------------------------------- +# provide shortcuts for development. you can remove everything below in production +# ---------------------------------------------------------------------------------------------------------------------- diff --git a/models/db.py b/models/db.py index 0ef64e0..2c81943 100644 --- a/models/db.py +++ b/models/db.py @@ -1,155 +1,199 @@ -# -*- coding: utf-8 -*- - -# ------------------------------------------------------------------------- -# AppConfig configuration made easy. Look inside private/appconfig.ini -# Auth is for authenticaiton and access control -# ------------------------------------------------------------------------- -from gluon.contrib.appconfig import AppConfig -from gluon.tools import Auth - -# ------------------------------------------------------------------------- -# This scaffolding model makes your app work on Google App Engine too -# File is released under public domain and you can use without limitations -# ------------------------------------------------------------------------- - -if request.global_settings.web2py_version < "2.15.5": - raise HTTP(500, "Requires web2py 2.15.5 or newer") - -# ------------------------------------------------------------------------- -# if SSL/HTTPS is properly configured and you want all HTTP requests to -# be redirected to HTTPS, uncomment the line below: -# ------------------------------------------------------------------------- -# request.requires_https() - -# ------------------------------------------------------------------------- -# once in production, remove reload=True to gain full speed -# ------------------------------------------------------------------------- -configuration = AppConfig(reload=True) - -if not request.env.web2py_runtime_gae: - # --------------------------------------------------------------------- - # if NOT running on Google App Engine use SQLite or other DB - # --------------------------------------------------------------------- - db = DAL(configuration.get('db.uri'), - pool_size=configuration.get('db.pool_size'), - migrate_enabled=configuration.get('db.migrate'), - check_reserved=['all']) -else: - # --------------------------------------------------------------------- - # connect to Google BigTable (optional 'google:datastore://namespace') - # --------------------------------------------------------------------- - db = DAL('google:datastore+ndb') - # --------------------------------------------------------------------- - # store sessions and tickets there - # --------------------------------------------------------------------- - session.connect(request, response, db=db) - # --------------------------------------------------------------------- - # or store session in Memcache, Redis, etc. - # from gluon.contrib.memdb import MEMDB - # from google.appengine.api.memcache import Client - # session.connect(request, response, db = MEMDB(Client())) - # --------------------------------------------------------------------- - -# ------------------------------------------------------------------------- -# by default give a view/generic.extension to all actions from localhost -# none otherwise. a pattern can be 'controller/function.extension' -# ------------------------------------------------------------------------- -response.generic_patterns = [] -if request.is_local and not configuration.get('app.production'): - response.generic_patterns.append('*') - -# ------------------------------------------------------------------------- -# choose a style for forms -# ------------------------------------------------------------------------- -response.formstyle = 'bootstrap4_inline' -response.form_label_separator = '' - -# ------------------------------------------------------------------------- -# (optional) optimize handling of static files -# ------------------------------------------------------------------------- -# response.optimize_css = 'concat,minify,inline' -# response.optimize_js = 'concat,minify,inline' - -# ------------------------------------------------------------------------- -# (optional) static assets folder versioning -# ------------------------------------------------------------------------- -# response.static_version = '0.0.0' - -# ------------------------------------------------------------------------- -# Here is sample code if you need for -# - email capabilities -# - authentication (registration, login, logout, ... ) -# - authorization (role based authorization) -# - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss) -# - old style crud actions -# (more options discussed in gluon/tools.py) -# ------------------------------------------------------------------------- - -# host names must be a list of allowed host names (glob syntax allowed) -auth = Auth(db, host_names=configuration.get('host.names')) - -# ------------------------------------------------------------------------- -# create all tables needed by auth, maybe add a list of extra fields -# ------------------------------------------------------------------------- -auth.settings.extra_fields['auth_user'] = [] -auth.define_tables(username=False, signature=False) - -# ------------------------------------------------------------------------- -# configure email -# ------------------------------------------------------------------------- -mail = auth.settings.mailer -mail.settings.server = 'logging' if request.is_local else configuration.get('smtp.server') -mail.settings.sender = configuration.get('smtp.sender') -mail.settings.login = configuration.get('smtp.login') -mail.settings.tls = configuration.get('smtp.tls') or False -mail.settings.ssl = configuration.get('smtp.ssl') or False - -# ------------------------------------------------------------------------- -# configure auth policy -# ------------------------------------------------------------------------- -auth.settings.registration_requires_verification = False -auth.settings.registration_requires_approval = False -auth.settings.reset_password_requires_verification = True - -# ------------------------------------------------------------------------- -# read more at http://dev.w3.org/html5/markup/meta.name.html -# ------------------------------------------------------------------------- -response.meta.author = configuration.get('app.author') -response.meta.description = configuration.get('app.description') -response.meta.keywords = configuration.get('app.keywords') -response.meta.generator = configuration.get('app.generator') -response.show_toolbar = configuration.get('app.toolbar') - -# ------------------------------------------------------------------------- -# your http://google.com/analytics id -# ------------------------------------------------------------------------- -response.google_analytics_id = configuration.get('google.analytics_id') - -# ------------------------------------------------------------------------- -# maybe use the scheduler -# ------------------------------------------------------------------------- -if configuration.get('scheduler.enabled'): - from gluon.scheduler import Scheduler - scheduler = Scheduler(db, heartbeat=configuration.get('scheduler.heartbeat')) - -# ------------------------------------------------------------------------- -# Define your tables below (or better in another model file) for example -# -# >>> db.define_table('mytable', Field('myfield', 'string')) -# -# Fields can be 'string','text','password','integer','double','boolean' -# 'date','time','datetime','blob','upload', 'reference TABLENAME' -# There is an implicit 'id integer autoincrement' field -# Consult manual for more options, validators, etc. -# -# More API examples for controllers: -# -# >>> db.mytable.insert(myfield='value') -# >>> rows = db(db.mytable.myfield == 'value').select(db.mytable.ALL) -# >>> for row in rows: print row.id, row.myfield -# ------------------------------------------------------------------------- - -# ------------------------------------------------------------------------- -# after defining tables, uncomment below to enable auditing -# ------------------------------------------------------------------------- -# auth.enable_record_versioning(db) +# ------------------------------------------------------------------------- +# AppConfig configuration made easy. Look inside private/appconfig.ini +# Auth is for authenticaiton and access control +# ------------------------------------------------------------------------- +from gluon.contrib.appconfig import AppConfig +from gluon.tools import Auth +from gluon.tools import Crud + +# ------------------------------------------------------------------------- +# This scaffolding model makes your app work on Google App Engine too +# File is released under public domain and you can use without limitations +# ------------------------------------------------------------------------- + +if request.global_settings.web2py_version < "2.15.5": + raise HTTP(500, "Requires web2py 2.15.5 or newer") + +# ------------------------------------------------------------------------- +# if SSL/HTTPS is properly configured and you want all HTTP requests to +# be redirected to HTTPS, uncomment the line below: +# ------------------------------------------------------------------------- +# request.requires_https() + +# ------------------------------------------------------------------------- +# once in production, remove reload=True to gain full speed +# ------------------------------------------------------------------------- +configuration = AppConfig(reload=True) + +if not request.env.web2py_runtime_gae: + # --------------------------------------------------------------------- + # if NOT running on Google App Engine use SQLite or other DB + # --------------------------------------------------------------------- + db = DAL(configuration.get('db.uri'), + pool_size=configuration.get('db.pool_size'), + migrate_enabled=configuration.get('db.migrate'), + check_reserved=['all']) +else: + # --------------------------------------------------------------------- + # connect to Google BigTable (optional 'google:datastore://namespace') + # --------------------------------------------------------------------- + db = DAL('google:datastore+ndb') + # --------------------------------------------------------------------- + # store sessions and tickets there + # --------------------------------------------------------------------- + session.connect(request, response, db=db) + # --------------------------------------------------------------------- + # or store session in Memcache, Redis, etc. + # from gluon.contrib.memdb import MEMDB + # from google.appengine.api.memcache import Client + # session.connect(request, response, db = MEMDB(Client())) + # --------------------------------------------------------------------- + +# ------------------------------------------------------------------------- +# by default give a view/generic.extension to all actions from localhost +# none otherwise. a pattern can be 'controller/function.extension' +# ------------------------------------------------------------------------- +response.generic_patterns = [] +if request.is_local and not configuration.get('app.production'): + response.generic_patterns.append('*') + +# ------------------------------------------------------------------------- +# choose a style for forms +# ------------------------------------------------------------------------- +response.formstyle = 'bootstrap3_stacked' +response.form_label_separator = '' + +# ------------------------------------------------------------------------- +# (optional) optimize handling of static files +# ------------------------------------------------------------------------- +# response.optimize_css = 'concat,minify,inline' +# response.optimize_js = 'concat,minify,inline' + +# ------------------------------------------------------------------------- +# (optional) static assets folder versioning +# ------------------------------------------------------------------------- +# response.static_version = '0.0.0' + +# ------------------------------------------------------------------------- +# Here is sample code if you need for +# - email capabilities +# - authentication (registration, login, logout, ... ) +# - authorization (role based authorization) +# - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss) +# - old style crud actions +# (more options discussed in gluon/tools.py) +# ------------------------------------------------------------------------- + +# host names must be a list of allowed host names (glob syntax allowed) +auth = Auth(db, host_names=configuration.get('host.names')) + +# ------------------------------------------------------------------------- +# create all tables needed by auth, maybe add a list of extra fields +# ------------------------------------------------------------------------- + +auth.settings.extra_fields['resources']= [ + Field('resource_1', type='string'), + Field('resource_2', type='string'), + Field('resource_3', type='string'), + Field ('resource_4', type='string')] + +auth.define_tables(username=True, signature=False) + +# ------------------------------------------------------------------------- +# configure email +# ------------------------------------------------------------------------- +mail = auth.settings.mailer +mail.settings.server = 'logging' if request.is_local else configuration.get('smtp.server') +mail.settings.sender = configuration.get('smtp.sender') +mail.settings.login = configuration.get('smtp.login') +mail.settings.tls = configuration.get('smtp.tls') or False +mail.settings.ssl = configuration.get('smtp.ssl') or False + +# ------------------------------------------------------------------------- +# configure auth policy +# ------------------------------------------------------------------------- +auth.settings.registration_requires_verification = False +auth.settings.registration_requires_approval = False +auth.settings.reset_password_requires_verification = True + +# ------------------------------------------------------------------------- +# read more at http://dev.w3.org/html5/markup/meta.name.html +# ------------------------------------------------------------------------- +response.meta.author = configuration.get('app.author') +response.meta.description = configuration.get('app.description') +response.meta.keywords = configuration.get('app.keywords') +response.meta.generator = configuration.get('app.generator') +response.show_toolbar = configuration.get('app.toolbar') + +# ------------------------------------------------------------------------- +# your http://google.com/analytics id +# ------------------------------------------------------------------------- +response.google_analytics_id = configuration.get('google.analytics_id') + +# ------------------------------------------------------------------------- +# maybe use the scheduler +# ------------------------------------------------------------------------- +if configuration.get('scheduler.enabled'): + from gluon.scheduler import Scheduler + scheduler = Scheduler(db, heartbeat=configuration.get('scheduler.heartbeat')) + +# ------------------------------------------------------------------------- +# Define your tables below (or better in another model file) for example +# + +db.define_table('category', Field('Name',type='string'), + format='%(Name)s') + + +db.define_table('resources', + Field('resources_id', type='integer', unique=True), + Field('resources_type', type='string',requires=IS_NOT_EMPTY()), + Field('resources_qty', type='integer',requires=IS_NOT_EMPTY()), + Field('resources_category', type = 'reference category',requires = IS_IN_DB(db, 'category.id', '%(Name)s')), + Field('resource_owner', type='reference auth_user', writable=False)) + +db.define_table('pooltable', + Field('pooltable_id', type='integer', unique=True), + Field('user_id', type='reference auth_user'), + Field('resources_id', type='reference resources')) + +db2 = DAL("sqlite://storage.sqlite") + +crud = Crud(db2) + +db2.define_table('image', + Field('title', unique=True), + Field('file', 'upload'), + format = '%(title)s') + +db2.define_table('post', + Field('image_id', 'reference image'), + Field('author'), + Field('email'), + Field('body', 'text')) + +db2.image.title.requires = IS_NOT_IN_DB(db2, db2.image.title) +db2.post.image_id.requires = IS_IN_DB(db2, db2.image.id, '%(title)s') +db2.post.author.requires = IS_NOT_EMPTY() +db2.post.email.requires = IS_EMAIL() +db2.post.body.requires = IS_NOT_EMPTY() + +db2.post.image_id.writable = db2.post.image_id.readable = False + +# +# Fields can be 'string','text','password','integer','double','boolean' +# 'date','time','datetime','blob','upload', 'reference TABLENAME' +# There is an implicit 'id integer autoincrement' field +# Consult manual for more options, validators, etc. +# +# More API examples for controllers: +# +# >>> db.mytable.insert(myfield='value') +# >>> rows = db(db.mytable.myfield == 'value').select(db.mytable.ALL) +# >>> for row in rows: print row.id, row.myfield +# ------------------------------------------------------------------------- + +# ------------------------------------------------------------------------- +# after defining tables, uncomment below to enable auditing +# ------------------------------------------------------------------------- +auth.enable_record_versioning(db) diff --git a/models/menu.py b/models/menu.py index 1aed04d..ffccf4d 100644 --- a/models/menu.py +++ b/models/menu.py @@ -1,110 +1,37 @@ -# -*- coding: utf-8 -*- -# this file is released under public domain and you can use without limitations - -# ---------------------------------------------------------------------------------------------------------------------- -# this is the main application menu add/remove items as required -# ---------------------------------------------------------------------------------------------------------------------- - -response.menu = [ - (T('Home'), False, URL('default', 'index'), []) -] - -# ---------------------------------------------------------------------------------------------------------------------- -# provide shortcuts for development. you can remove everything below in production -# ---------------------------------------------------------------------------------------------------------------------- - -if not configuration.get('app.production'): - _app = request.application - response.menu += [ - (T('My Sites'), False, URL('admin', 'default', 'site')), - (T('This App'), False, '#', [ - (T('Design'), False, URL('admin', 'default', 'design/%s' % _app)), - (T('Controller'), False, - URL( - 'admin', 'default', 'edit/%s/controllers/%s.py' % (_app, request.controller))), - (T('View'), False, - URL( - 'admin', 'default', 'edit/%s/views/%s' % (_app, response.view))), - (T('DB Model'), False, - URL( - 'admin', 'default', 'edit/%s/models/db.py' % _app)), - (T('Menu Model'), False, - URL( - 'admin', 'default', 'edit/%s/models/menu.py' % _app)), - (T('Config.ini'), False, - URL( - 'admin', 'default', 'edit/%s/private/appconfig.ini' % _app)), - (T('Layout'), False, - URL( - 'admin', 'default', 'edit/%s/views/layout.html' % _app)), - (T('Stylesheet'), False, - URL( - 'admin', 'default', 'edit/%s/static/css/web2py-bootstrap3.css' % _app)), - (T('Database'), False, URL(_app, 'appadmin', 'index')), - (T('Errors'), False, URL( - 'admin', 'default', 'errors/' + _app)), - (T('About'), False, URL( - 'admin', 'default', 'about/' + _app)), - ]), - ('web2py.com', False, '#', [ - (T('Download'), False, - 'http://www.web2py.com/examples/default/download'), - (T('Support'), False, - 'http://www.web2py.com/examples/default/support'), - (T('Demo'), False, 'http://web2py.com/demo_admin'), - (T('Quick Examples'), False, - 'http://web2py.com/examples/default/examples'), - (T('FAQ'), False, 'http://web2py.com/AlterEgo'), - (T('Videos'), False, - 'http://www.web2py.com/examples/default/videos/'), - (T('Free Applications'), - False, 'http://web2py.com/appliances'), - (T('Plugins'), False, 'http://web2py.com/plugins'), - (T('Recipes'), False, 'http://web2pyslices.com/'), - ]), - (T('Documentation'), False, '#', [ - (T('Online book'), False, 'http://www.web2py.com/book'), - (T('Preface'), False, - 'http://www.web2py.com/book/default/chapter/00'), - (T('Introduction'), False, - 'http://www.web2py.com/book/default/chapter/01'), - (T('Python'), False, - 'http://www.web2py.com/book/default/chapter/02'), - (T('Overview'), False, - 'http://www.web2py.com/book/default/chapter/03'), - (T('The Core'), False, - 'http://www.web2py.com/book/default/chapter/04'), - (T('The Views'), False, - 'http://www.web2py.com/book/default/chapter/05'), - (T('Database'), False, - 'http://www.web2py.com/book/default/chapter/06'), - (T('Forms and Validators'), False, - 'http://www.web2py.com/book/default/chapter/07'), - (T('Email and SMS'), False, - 'http://www.web2py.com/book/default/chapter/08'), - (T('Access Control'), False, - 'http://www.web2py.com/book/default/chapter/09'), - (T('Services'), False, - 'http://www.web2py.com/book/default/chapter/10'), - (T('Ajax Recipes'), False, - 'http://www.web2py.com/book/default/chapter/11'), - (T('Components and Plugins'), False, - 'http://www.web2py.com/book/default/chapter/12'), - (T('Deployment Recipes'), False, - 'http://www.web2py.com/book/default/chapter/13'), - (T('Other Recipes'), False, - 'http://www.web2py.com/book/default/chapter/14'), - (T('Helping web2py'), False, - 'http://www.web2py.com/book/default/chapter/15'), - (T("Buy web2py's book"), False, - 'http://stores.lulu.com/web2py'), - ]), - (T('Community'), False, None, [ - (T('Groups'), False, - 'http://www.web2py.com/examples/default/usergroups'), - (T('Twitter'), False, 'http://twitter.com/web2py'), - (T('Live Chat'), False, - 'http://webchat.freenode.net/?channels=web2py'), - ]), - ] - +# -*- coding: utf-8 -*- +# this file is released under public domain and you can use without limitations + +# ---------------------------------------------------------------------------------------------------------------------- +# this is the main application menu add/remove items as required +# ---------------------------------------------------------------------------------------------------------------------- + +response.menu = [ + (T('Home'), False, URL('default', 'index'), []) +] +if session.auth: + user_id = session.auth.user.id +else: + user_id = None + +response.menu += [ + (T('Resources'), False,'#', [ + (T('My Resource'), False,URL('list_resources',args = user_id) if session.auth else URL('default','index')), + (T('List Users'), False, URL('list_id')), + ((T('Add Resources'), False, URL('add_resources') if session.auth else URL('default','index'))), + (T('Delete Resources'), False, URL('delete_resource',args = user_id) if session.auth else URL('default','index')), + (T('Edit Resources'), False, URL('edit_resource',args = user_id) if session.auth else URL('default','index')) ] + ) +] + +response.menu += [ + ((T('Category'),False, '#', [ + (T(row.Name), False, URL('list_resource_by_category',args=row.Name), []) for row in db(db.category).select()])) +] + +response.menu +=[ + (T('Search'), False, URL('default', 'search_resource'), []) + + ] +# ---------------------------------------------------------------------------------------------------------------------- +# provide shortcuts for development. you can remove everything below in production +# ---------------------------------------------------------------------------------------------------------------------- diff --git a/views/default/delete_resource.html b/views/default/delete_resource.html new file mode 100644 index 0000000..3c6185f --- /dev/null +++ b/views/default/delete_resource.html @@ -0,0 +1,39 @@ +{{extend 'layout.html'}} + +
| Resource Id | +Resource Type | +Resource Category | +Resource Qty | +Resource Owner | + +
|---|---|---|---|---|
| {{=specification.resources_id}} | +{{=specification.resources_type}} | +{{=specification.resources_category.Name}} | +{{=specification.resources_qty}} | +{{=specification.resource_owner.username}} | +
| Resource Id | +Resource Type | +Resource Qty | +Resource Owner | + +
|---|---|---|---|
| {{=specification.resources_id}} | +{{=specification.resources_type}} | +{{=specification.resources_qty}} | +{{=specification.resource_owner.username}} | +
{{=T('How did you get here?')}}
-