the grid doesn't allow to edit in a single form fields coming from
different tables, so there's no way to accomplish what you need with the
standard SQLFORM.grid.
On Friday, February 13, 2015 at 3:34:50 PM UTC+1, Simon Marshall wrote:
>
> Hi All,
>
> I'm trying to create a management interface for the following tables, but
> i cannot get it to work the way i want.
>
> i'm trying to manage the auth_user table and another table containing a
> reference to auth_user. but i cannot get them to show as i'm unsure the
> best way to construct the query my code below:
>
> Models
>
> #########player_stats.py#################
>
> db.define_table('player_stats', Field('player', 'reference auth_user'),
> Field('events_attended','integer',
> default=0),
> Field('player_kills','integer', default=0),
> Field('player_deaths','integer', default=0)
> )
> db.player_stats._singular = "Player Stats"
> db.player_stats._plural = "Player Stats"
>
>
> ######auth_user extra fields#####
>
> auth.settings.extra_fields['auth_user']= [
> Field('IOA_number', writable=False, unique=True,
> default=IOA_GEN(5,True)),
> Field('user_status', default='Active',
> requires=IS_IN_SET(['Active','Suspended','Banned'])),
> Field('nickname', 'string'),
> Field('date_of_birth', 'date', requires=IS_NOT_EMPTY()),
> Field('mobile', 'string', requires=IS_NOT_EMPTY()),
> Field('phone','string', requires=IS_NOT_EMPTY()),
> Field('address_line_1', 'string', requires=IS_NOT_EMPTY()),
> Field('address_line_2', 'string'),
> Field('address_line_3', 'string'),
> Field('city','string', requires=IS_NOT_EMPTY()),
> Field('post_code', 'string', requires=IS_NOT_EMPTY()),
> Field('county', 'string', requires=IS_NOT_EMPTY()),
> Field('country','string', requires=IS_NOT_EMPTY()),
> Field('medical_conditions', 'text'),
>
>
> #########################Manage.py ####################################
>
> db.auth_user.id.readable=False
>
> #Define the fields to show on grid.
> fields = (db.auth_user.IOA_number, db.auth_user.first_name,
> db.auth_user.last_name, db.auth_user.ioa_team_pref)
>
> #Define headers as tuples/dictionaries
> headers = {'auth_user.IOA_number': 'IOA ID',
> 'auth_user.first_name': 'First Name',
> 'auth_user.last_name': 'Last Name',
> 'auth_user.last_name': 'Last Name',
> 'ioa_team_pref': 'Team Preference',
> }
> #Default sort order in grid
> default_sort_order=[db.auth_user.IOA_number]
>
> #query to select the user profile and player stats
> query = (db.auth_user)
>
> form = SQLFORM.grid(query=query, fields=fields, headers=headers,
> orderby=default_sort_order,
> create=auth.has_membership('Staff'),
> deletable=auth.has_membership('Staff'),
> editable=auth.has_membership('Staff'), maxtextlength=64, paginate=25)
> return dict(form=form)
>
> what i am aftef, when i click on the view/edit buttons i would like to
> show field from both auth_user and player_stats. would i need to creating a
> custom view file.
>
> Thanks in Advance,
>
> Simon
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.