When you try... would you submit some screenshots in this thread?

On Sep 13, 1:13 am, Massimo Di Pierro <[email protected]>
wrote:
> Here is a complete implementation of a multi-tenant todo list with
> search, assignments, emails, janrain, etc....
> Try understand it. Requires trunk!
>
> """
> Complete web2py program to create, search assign and manage
> tasks
> Has multi-tenancy supports (same app can manage different
> hostnames)
> Uses janrain for
> login
> """
>
> ### File: models/db.py
> #################################
>
> from gluon.tools import Auth
> db = DAL('sqlite://storage.sqlite')
> auth = Auth(db,hmac_key=Auth.get_or_create_key())
> auth.define_tables()
>
> # configure email and
> janrain
> auth.settings.mailer.settings.server = 'logging' or 'smtp.gmail.com:
> 587'
> auth.settings.mailer.settings.sender = '[email protected]'
> auth.settings.mailer.settings.login = 'username:password'
> from gluon.contrib.login_methods.rpx_account import use_janrain
> use_janrain(auth,filename='private/janrain.key')
>
> db._common_fields.append(Field('request_tenant',writable=False,default=requ 
> est.env.host_name))
>
> db.define_table('task',
>                 Field('name',requires=IS_NOT_EMPTY()),
>                 Field('assigned_to',db.auth_user),
>                 Field('due_date','datetime'),
>                 Field('notify','boolean'),
>                 Field('note'),
>                 auth.signature)
>
> ### File: controllers/default.py
> #################################
>
> response.menu = []
> response.menu.append(('My Tasks',False,URL('index')))
> response.menu.append(('Create/Manage
> Tasks',False,URL('manage_tasks')))
> link = 'http://%s%s' % (request.env.http_host,URL('view_task'))
>
> @auth.requires_login()
> def index():
>     """ Allows me to browse, search, view, update tasks assigned to me
> """
>     grid=SQLFORM.grid(db.task.assigned_to==auth.user_id,create=False)
>     form = grid.element('form')
>     if form and form.accepted:
>         mail.send(to=form.record.created_by,subject="todo",
>                   message = "task %s/%i updated" %
> (link,form.record_id))
>     return dict(grid=grid)
>
> @auth.requires_login()
> def manage_tasks():
>     """ Allows me to browse, serach, view, create and assign new tasks
> """
>     grid=SQLFORM.grid(db.task.created_by==auth.user_id)
>     form = grid.element('form')
>     if form and form.accepted:
>         mail.send(to=form.vars.assigned_to,subject="todo",
>                   message = "task %s/%i assigned to you" %
> (link,form.vars.id))
>     return dict(grid=grid)
>
> def view_task():
>     task = db(db.task.id==request.args(0))\
>                   ((db.task.created_by==auth.user.id)|
> (db.task.assigned_to==auth.user.id)).select().first()
>     return dict(task = task)
>
> def user():
>     return dict(form=auth())
>
> ### File: views/default/index.html
> #################################
> {{extend 'layout.html'}}
> {{=form}}
>
> ### File: views/default/manage_tasks.html
> ##########################
> {{extend 'layout.html'}}
> {{=form}}
>
> ### File: views/default/view_task.html
> #############################
> {{extend 'layout.html'}}
> {{=form}}
>
> ### Requires scaffolding layout and static files
> ###################

Reply via email to