Hello, I'm about 1 year that i don't program in web2py and I don't remember 
nothing!

So, easy question

I have this table (I created esplicitally the field is_active, created_on, 
created_by, do not ask me why...it's another question...)

db.define_table('ticket',
                Field('asset', 'reference asset'),
                Field('fisso', 'boolean'),
                Field('anomalia', type='string', 
requires=[IS_NOT_EMPTY(),IS_LENGTH(200)], 
widget=SQLFORM.widgets.text.widget),
                Field('chiuso', 'boolean'),
                Field('risoluzione', type='string', 
requires=[IS_LENGTH(100)], widget=SQLFORM.widgets.text.widget, default='In 
attesa'),
                Field('is_active', 'boolean', default=True),
                Field('created_on', 'datetime', default=request.now),
                Field('created_by', 'integer', default=auth.user_id),
                Field('modified_on', 'datetime', update=request.now),
                Field('modified_by', 'integer', update=auth.user_id),
                singular="Ticket", plural="Ticket",migrate='ticket.table',
                format='%(asset)s')


And I have this function

# crea il ticket per l'asset specificato
@auth.requires_login()
def ticket():
    import datetime
    # recupero l'asset di cui fare il ticket
    asset = db.asset(request.args(0)) or redirect(URL('sedi'))

    #verifico se l'asset è già oggetto di un ticket aperto - se lo è 
impedisco l'apertura del ticket
    query = (db.ticket.asset == asset) & (db.ticket.chiuso == False)
    row = db(query).select().first()
    if (row != None):
        session.flash = 'Esiste un ticket aperto per questo asset: non è 
possibile aprire un ulteriore ticket'
        redirect(URL('index'))

    db.ticket.created_by.readable=db.ticket.created_by.writable=True
    db.ticket.created_on.readable=db.ticket.created_on.writable=True
    db.ticket.asset.default=asset.id
    db.ticket.asset.writable=db.ticket.asset.readable=False
    db.ticket.fisso.default=True
    
db.ticket.chiuso.default=db.ticket.chiuso.readable=db.ticket.chiuso.writable=False
    db.ticket.risoluzione.readable=db.ticket.risoluzione.writable=False
    db.ticket.risoluzione.default="In attesa"
    # db.ticket.is_active.default=True
    # db.ticket.created_on.default=request.now
    # recupero il tipo di asset del ticket
    print request.now, auth.user_id
    db.ticket.created_by.default = auth.user_id
    db.ticket.created_on.default = request.now
    tipo_asset = asset.tipo
    # definisco la landing_page
    landing_page = 'lista_ticket_asset/' + tipo_asset
    # print landing_page
    # se il form va a buon fine allora va a finire nella lista dei ticket 
aperti di quel tipo asset
    form = crud.create(db.ticket, next=landing_page, onaccept=lambda 
form,asset=asset:send_email_ticket(form,asset), message='ticket creato')
    # form = crud.create(db.ticket, next='lista_ticket',onaccept=lambda 
form,asset=asset:send_email_ticket(form,asset))
    #form.add_button("Annulla",URL('sedi'))
    # form[0][-1][1].append(TAG.BUTTON('Annulla', _class='btn btn-default', 
_type='Cancel',_onclick="document.location='%s';return false" % 
URL('lista_ticket_asset',args=tipo_asset)))
    form[0][-1][1].append(TAG.BUTTON('Annulla', _class='btn btn-default', 
_type='Cancel',_onclick="document.location='%s';return false" % 
URL('index')))
    db.ticket.chiuso.readable=db.ticket.chiuso.writable=True
    db.ticket.risoluzione.readable=db.ticket.risoluzione.writable=True
    
    return dict(form=form, asset=asset)

When I create a "ticket" I'm not able to put into fields created_by and 
created_on the right information

This is the result

1 selezionato
ticket.id 
<http://127.0.0.1:8000/itasset2/appadmin/select/db?orderby=ticket.id>
ticket.asset 
<http://127.0.0.1:8000/itasset2/appadmin/select/db?orderby=ticket.asset>
ticket.fisso 
<http://127.0.0.1:8000/itasset2/appadmin/select/db?orderby=ticket.fisso>
ticket.anomalia 
<http://127.0.0.1:8000/itasset2/appadmin/select/db?orderby=ticket.anomalia>
ticket.chiuso 
<http://127.0.0.1:8000/itasset2/appadmin/select/db?orderby=ticket.chiuso>
ticket.risoluzione 
<http://127.0.0.1:8000/itasset2/appadmin/select/db?orderby=ticket.risoluzione>
ticket.is_active 
<http://127.0.0.1:8000/itasset2/appadmin/select/db?orderby=ticket.is_active>
ticket.created_on 
<http://127.0.0.1:8000/itasset2/appadmin/select/db?orderby=ticket.created_on>
ticket.created_by 
<http://127.0.0.1:8000/itasset2/appadmin/select/db?orderby=ticket.created_by>
ticket.modified_on 
<http://127.0.0.1:8000/itasset2/appadmin/select/db?orderby=ticket.modified_on>
ticket.modified_by 
<http://127.0.0.1:8000/itasset2/appadmin/select/db?orderby=ticket.modified_by>
24 <http://127.0.0.1:8000/itasset2/appadmin/update/db/ticket/24> PC 
CNU411DJR3 <http://127.0.0.1:8000/itasset2/appadmin/update/db/asset/3005> 
True ooo False In attesa False None 0 None 0





What is wrong? How to correct?
Thank  you

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/6d901f83-7693-4e19-862d-ef4c5644b2eco%40googlegroups.com.

Reply via email to