Sure - here are the model and controller method. The model is very long but only a handful of the fields will be enabled for editing at one time. Let me know if you have questions or need more info...

Thanks

    -Jim

----- model -----

railLoad = db.define_table('railLoad',
    Field('railLoadId', 'id', readable=False),
    Field('railCarId', db.railCar, required=True, label='Rail Car'),
    Field('loadedById', db.auth_user, required=True, label='Loaded By'),
    Field('unloadedById', db.auth_user, label='Unloaded By'),
    Field('loadedOn', 'date', required=True, label='Loaded On'),
    Field('unloadedOn', 'date', label='Unloaded On'),
    Field('product', length=50, required=True),
    Field('outageIn', 'integer', label='Outage - Loading'),
    Field('poundsIn', 'integer', label='Pounds - Loading'),
    Field('temperatureIn', 'integer', label='Temperature - Loading'),
    Field('retainsIn', 'integer', label='Retains - Loading'),
    Field('valveIn', length=30, label='Valve - Loading'),
Field('valveConditionIn', length=30, label='Value Condition - Loading'),
    Field('manwayBoltsIn', 'boolean',
          label='Manway Bolts In Place And In Good Condition - Loading'),
    Field('manwayGasketIn', 'boolean',
          label='Manway Gasket In Place And In Good Condition - Loading'),
    Field('manwayThreadsIn', 'boolean',
          label='Manway Threads In Good Condition - Loading'),
    Field('valveWorkingIn', 'boolean',
          label='Valve In Good Working Condition - Loading'),
    Field('stemBrokenIn', 'boolean', label='Stem Broken - Loading'),
    Field('capIn', 'boolean',
          label='Cap & Threads Cleaned / Cap Securely Fastened - Loading'),
    Field('steamLineCapsIn', 'boolean',
          label='Steamline Caps Present And Attached - Loading'),
    Field('steamCoilsIn', 'boolean',
          label='Steam Coils In working Condition - Loading'),
    Field('ladderHandrailIn', 'boolean',
label='Ladder And Handrail Attached And In Good Condition - Loading'),
    Field('steamPortLeakIn', 'boolean',
          label='Product Leaking From Steam Ports - Loading'),
    Field('outletValveLeakIn', 'boolean',
          label='Product Leaking From Outlet Valves - Loading'),
    Field('decalIn', 'boolean', label='QLF Decal - Loading'),
    Field('manwaySealsIn', 'boolean', label='Manway Seals - Loading'),
    Field('valveSealsIn', 'boolean', label='Valve Seals - Loading'),
Field('stuffingBoxSealsIn', 'boolean', label='Stuffing Box Seals - Loading'),
    Field('commentsIn', 'text', label='Comments - Loading'),
    Field('outageOut', 'integer', label='Outage - Unloading'),
    Field('poundsOut', 'integer', label='Pounds - Unloading'),
    Field('temperatureOut', 'integer', label='Temperature - Unloading'),
Field('sweatHoursOut', 'decimal(5,2)', label='Hours to Sweat - Unloading'),
    Field('retainsOut', 'integer', label='Retains - Unloading'),
    Field('tankNumberOut', length=10,
          label='Plant Tank # Unloading To - Unloading'),
    Field('valveOut', length=30, label='Valve - Unloading'),
Field('valveConditionOut', length=30, label='Value Condition - Unloading'),
    Field('manwayBoltsOut', 'boolean',
          label='Manway Bolts In Place And In Good Condition - Unloading'),
    Field('manwayGasketOut', 'boolean',
label='Manway Gasket In Place And In Good Condition - Unloading'),
    Field('manwayThreadsOut', 'boolean',
          label='Manway Threads In Good Condition - Unloading'),
    Field('valveWorkingOut', 'boolean',
          label='Valve In Good Working Condition - Unloading'),
    Field('stemBrokenOut', 'boolean', label='Stem Broken - Unloading'),
    Field('capOut', 'boolean',
label='Cap & Threads Cleaned / Cap Securely Fastened - Unloading'),
    Field('steamLineCapsOut', 'boolean',
          label='Steamline Caps Present And Attached - Unloading'),
    Field('steamCoilsOut', 'boolean',
          label='Steam Coils In working Condition - Unloading'),
    Field('ladderHandrailOut', 'boolean',
label='Ladder And Handrail Attached And In Good Condition - Unloading'),
    Field('steamPortLeakOut', 'boolean',
          label='Product Leaking From Steam Ports - Unloading'),
    Field('outletValveLeakOut', 'boolean',
          label='Product Leaking From Outlet Valves - Unloading'),
    Field('decalOut', 'boolean', label='QLF Decal - Unloading'),
    Field('manwaySealsOut', 'boolean', label='Manway Seals - Unloading'),
    Field('valveSealsOut', 'boolean', label='Valve Seals - Unloading'),
    Field('stuffingBoxSealsOut', 'boolean',
          label='Stuffing Box Seals - Unloading'),
    Field('commentsOut', 'text', label='Comments - Unloading'))

railLoad['_plural'] = 'Rail Loads'
railLoad.loadedOn.requires = IS_DATE('%m/%d/%Y')
railLoad.unloadedOn.requires = IS_DATE('%m/%d/%Y')


----- controller code -----

@auth.requires_permission('select', db.railLoad)
def railLoading():
    response.view='list.html'
    table = db.railLoad
    response.title = '%s - %s' % (response.section, table['_plural'])
    fields = [db.railLoad.railCarId, db.railLoad.loadedById,
              db.railLoad.loadedOn, db.railLoad.unloadedById,
              db.railLoad.unloadedOn]

    #  Setup Permissions
    securityTable = table
    currentTable = request.args(1)
    if currentTable and currentTable != 'edit':
        securityTable = currentTable.split('.')[0]

    editable = auth.has_permission('update', securityTable)
    create = auth.has_permission('create', securityTable)
    deletable = auth.has_permission('delete', securityTable)
    details = auth.has_permission('read', securityTable)

    orderby = dict(railLoad=[db.railLoad.loadedOn,
                                db.railLoad.unloadedOn])

    queries = []
    constraints = None

    #  Get filters
    searchText = request.get_vars.searchText

    if request.wsgi.environ['QUERY_STRING'] != '':
        if searchText == None:
            try:
searchText = session['searchValues']['railLoad']['searchText']
            except:
                searchText = ''

    session.searchValues = dict(railLoad={'searchText':searchText})

    #  Build query
    if searchText and searchText .strip() != '':
        queries.append(db.railLoad.commentsIn.contains(searchText))
    if len(queries) > 0:
        query = reduce(lambda a,b:(a|b),queries)
        constraints={'railLoad':query}

    linked_tables = []

    searchWidgets = {'railLoad':defaultSearch}

    grid = SQLFORM.smartgrid(table, fields=fields,
                             constraints=constraints, orderby=orderby,
                             create=create, details=details,
                             editable=editable, deletable=deletable,
                             csv=False, search_widget=searchWidgets,
                             searchable=True, linked_tables=linked_tables,
                             paginate=15, maxtextlength=45)
    return dict(grid=grid)


On 4/9/2012 10:30 AM, Massimo Di Pierro wrote:
Any chance you can post the controller and the model?

On Monday, 9 April 2012 09:49:08 UTC-5, Jim S wrote:

    Hi

    I'm having a problem when adding records to a table using
    smartgrid.  I upgraded to the latest trunk this morning.

    Here is what my grid looks like - empty:


    If I click on Add I then get this:


    ...but no create page.  The URL appears to be right, but the
    create page doesn't display.  Like I said, all my other pages are
    working, just not this one.

    If I add a record to the DB, the Edit button works and I can
    delete (through the Edit interface).  But, can't create a record.

    Any thoughts on where I start debugging this one?

        -Jim

Reply via email to