[web2py] SQLFORM.grid and user_signature - unexpected behavior

2021-05-10 Thread Tom Clerckx
 

I was running into some issue with SQLFORM.grid and after going through the 
code, I realized that the grid does not include request.vars when 
calculating the URL signature (ref: v2.21.1, gluon/sqlhtml.py @ 2440). 

Please correct me if I would be wrong,... else it may be useful to add 
something about this behavior in the web2py documentation:


SQLFORM.grid validates the signature without taking into account 
request.vars

As such, any constructed URL that contains a user_signature and that is 
pointing to the page that uses the controller function which creates this 
grid, should have this signature created without including request.vars! 

Thus, hash_vars should be set to False in that case. If not, you may get a 
‘not authorized’ flash message and you will be redirected.

E.g. a signed URL pointing to such page should look like:

URL(‘mypage_with_grid’, args=[‘a’, ‘b’, ‘c’], vars={‘var1’:’val1’}, 
*user_signature=True,* *hash_vars=False*)


-- 
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/4de8ab7e-497a-4bc7-8ee8-872fec9ea49en%40googlegroups.com.


Re: [web2py] SQLform.grid request not sending bool valuis

2020-11-24 Thread Vid Ogris
Yes they are writable.

V V sre., 25. nov. 2020 ob 04:31 je oseba AGRogers 
napisala:

> Are the boolean fields writable? I think unwritable fields are excluded
> from request.vars.
>
> ___
> *www.TenOutOfTen.org* 
> rogers...@gmail.com
> (+95) 09 250018669 (Myanmar)
>
>
>
> On Tue, 24 Nov 2020 at 22:21, Yebach  wrote:
>
>> Hello
>>
>> I have a SQLform.grid and when validating fields i have some issues
>>
>> so to come around i have
>>
>> if request.args and request.args[0] in ['edit', 'new']:
>> if form.update_form:
>> if form.update_form.accepts(request.vars):
>> print request.vars
>> print request.args
>> session.flash = T('Diagnoza postavljena')
>> redirect(URL())
>>
>> the problem is that reques.vars is not including fileds that are of type
>> boolean
>>
>> therefore i did a workaround and whn bool field is set as string it does
>> but i want to change the text field to be checkbox
>>
>> any suggeestion? Either on getting the bool value or changing the field
>> to be checkbox
>>
>> 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/55aa4f8e-7da4-48c6-a526-f074f6aaa9acn%40googlegroups.com
>> 
>> .
>>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/iDcA3N_NMcY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/CACWMBMPGELDe%2BKZ8nVt0dK%3DqLfCbf-mOCKQtEL9BJEU5P%3DzOCg%40mail.gmail.com
> 
> .
>


-- 
Lep pozdrav

Vid Ogris

-- 
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/CAPek6tJ3V%2BHEq70Y6vWMEmC%3DZnuYm_YbA5LV35ecNq5hDNq0iQ%40mail.gmail.com.


Re: [web2py] SQLform.grid request not sending bool valuis

2020-11-24 Thread AGRogers
Are the boolean fields writable? I think unwritable fields are excluded
from request.vars.

___
*www.TenOutOfTen.org* 
rogers...@gmail.com
(+95) 09 250018669 (Myanmar)



On Tue, 24 Nov 2020 at 22:21, Yebach  wrote:

> Hello
>
> I have a SQLform.grid and when validating fields i have some issues
>
> so to come around i have
>
> if request.args and request.args[0] in ['edit', 'new']:
> if form.update_form:
> if form.update_form.accepts(request.vars):
> print request.vars
> print request.args
> session.flash = T('Diagnoza postavljena')
> redirect(URL())
>
> the problem is that reques.vars is not including fileds that are of type
> boolean
>
> therefore i did a workaround and whn bool field is set as string it does
> but i want to change the text field to be checkbox
>
> any suggeestion? Either on getting the bool value or changing the field to
> be checkbox
>
> 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/55aa4f8e-7da4-48c6-a526-f074f6aaa9acn%40googlegroups.com
> 
> .
>

-- 
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/CACWMBMPGELDe%2BKZ8nVt0dK%3DqLfCbf-mOCKQtEL9BJEU5P%3DzOCg%40mail.gmail.com.


[web2py] SQLform.grid request not sending bool valuis

2020-11-24 Thread Yebach
Hello

I have a SQLform.grid and when validating fields i have some issues 

so to come around i have

if request.args and request.args[0] in ['edit', 'new']:
if form.update_form:
if form.update_form.accepts(request.vars):
print request.vars
print request.args
session.flash = T('Diagnoza postavljena')
redirect(URL())

the problem is that reques.vars is not including fileds that are of type 
boolean

therefore i did a workaround and whn bool field is set as string it does 
but i want to change the text field to be checkbox

any suggeestion? Either on getting the bool value or changing the field to 
be checkbox

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/55aa4f8e-7da4-48c6-a526-f074f6aaa9acn%40googlegroups.com.


[web2py] SQLFORM.grid, best approach for searching in ID type field

2020-07-06 Thread Luciano Bovio
I am reading a table from another application just to perform searches. I 
am using SQLFORM.grid, my problem is that i need to search for 
'product_code' field that in my DAL i have mapped as ID. I have no rights 
to write fields on remote DB.

/models/remote_server.py
db1.define_table('web_products',
Field('product_code','id'),
Field('product_desc','string'),
migrate=False)

/controllers/example_search.py
def index():
grid=SQLFORM.grid(db1.web_products)
return dict(grid=grid)

Which will be the right way to perform a search in that field ? Do i 
explain myself correctly ?

Thanks

-- 
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/f5d90e3b-ab3c-4312-baa8-598f3925c672o%40googlegroups.com.


[web2py] SQLFORM.grid in ajax function with signed urls

2019-11-15 Thread cdbaron
Hello

I have a component that is loaded by ajax and this component has an 
SQLFORM.grid.
This component has a variable in the url.
For security reasons I want the ajax component to have the url signed.
The problem is that the grid pagination links generate a wrong signed url.

wrong signed url:

http:
//127.0.0.1:8001/pruebas/default/ajax_grid.load?fk=1=2&_signature=04fd4fd72bdbda072410fda2184d0ac3a94b4058

i get "ACCESS DENIED" because @auth.requires_signature()

grid generate wrong signed url in pagination when url have vars and 
requires signature.

Any way to solve the problem?

A simplified version of the code:

def prueba_grid():

# Same data
if not db(db.t_data).select():
for i in range(1, 100):
fk = i % 2
db.t_data.insert(f_data=i, f_fk=fk)

url = URL('default', 'ajax_grid.load', vars=dict(fk=1), user_signature=
True)
load_ajax_grid= LOAD(url=url, ajax=True)

return locals()

@auth.requires_signature()
def ajax_grid():
fk = request.get_vars.fk

grid = SQLFORM.grid(
db.t_data.f_fk == fk

)
return dict(grid=grid)

And de model:

db.define_table(
't_data',
Field('f_data', 'string', length=10),
Field('f_fk', 'integer'))..

view prueba_grid
{{extend 'layout.html'}}

{{=load_ajax_grid}}


-- 
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/a59f050e-0dba-41ab-9676-b9ef55d9f1fb%40googlegroups.com.


[web2py] SQLFORM.grid search with fields readable = False

2019-10-26 Thread cdbaron
Hello,

I have an SQLFROM.grid in which I render each of the lines with a special 
format using only the id field of the table (id.represent). Attached image 
with the result.

Everything works perfect except when searching records. The issue is that 
hidden fields (readable = False) are excluded from the search.

This is the code in sqlhtml.py that that blocks the search

 sfields = reduce (lambda a, b: a + b,
 [[f for f in t if f.readable and f.searchable] 
for t in tables])

Why fields are excluded with readable = False if searchable = False exists?

Any way to search across all fields of the sql query?


regards.

-- 
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/aaee99b9-f8bc-44b8-a9f2-7a2886d22a85%40googlegroups.com.


[web2py] SQLFORM.grid Add and Edit buttons incorrect links when running inside another view

2019-08-17 Thread Flavio Bovio

*Add and edit button links are created incorrectly when de grid is inside 
another view. With the smartgrid works ok.*

*Add button link*
http://localhost:8000/erp_proto/tablas_grales/index/addt/forma_pago 
   
Return None

*Should be*
http://localhost:8000/erp_proto/tablas_grales/index/forma_pago/add/forma_pago

*Edit button link*
http://localhost:8000/erp_proto/tablas_grales/index/edit/forma_pago/1   
 
Return None

*Should be*
http://localhost:8000/erp_proto/tablas_grales/index/forma_pago/edit/forma_pago/1



*CONTROLLER*
def index():

if request.args(0) == 'forma_pago':
grid = SQLFORM.grid(db.forma_pago, csv=False, user_signature=False, 
details=False, advanced_search=False)
return dict(grid=grid, enc='Formas de Pago')

if request.args(0) == 'vendedores':
grid = SQLFORM.grid(db.vendedores, csv=False, user_signature=False, 
details=False, advanced_search=False)
return dict(grid=grid, enc='Vendedores')

if request.args(0) == 'tipo_documento':
grid = SQLFORM.grid(db.tipo_documento, csv=False, 
user_signature=False, details=False, advanced_search=False)
return dict(grid=grid, enc='Tipos de Documento')

if request.args(0) == 'situacion_iva':
grid = SQLFORM.grid(db.situacion_iva, csv=False, 
user_signature=False, details=False, advanced_search=False)
return dict(grid=grid, enc='Situaciones IVA')

*VIEW*

{{extend 'layout.html'}}


TABLAS GENERALES


{{=A('FORMAS PAGO', _href=URL('tablas_grales','index', 
args='forma_pago'), _class="btn btn_secondary")}}
{{=A('VENDEDORES' , _href=URL('tablas_grales','index', 
args='vendedores'), _class="btn btn_secondary")}}
{{=A('TIPOS DOCUMENTO', _href=URL('tablas_grales','index', 
args='tipo_documento'), _class="btn btn_secondary")}}
{{=A('SITUACION IVA'  , _href=URL('tablas_grales','index', 
args='situacion_iva') , _class="btn btn_secondary")}}






{{=enc}}
{{=grid}}



-- 
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/88b800d4-ee62-4f84-a3c7-e05f8c660308%40googlegroups.com.


[web2py] SQLFORM.grid() buttons have no names? 2.17.2-stable

2018-12-30 Thread Paul Ellis
Is there a reason there are no names or ids attached to the grid buttons?
Like addBtn, deleteBtn and so on. 

There's no identifying information on the buttons to make it easy to change 
the text or colour, for example. I don't want 'Add record' I want something 
more contextual depending on the grid.

I want to change the colour of the delete button. 

The edit button is only visible to admins and only for some records. I want 
them to see it is an admin function so they are careful with it. It doesn't 
always have the same index location in the "row-buttons" div. 

I can give a dict() to the ui argument and change the colour of all of the 
buttons, but that's not ideal.

I am pretty sure the buttons used to be named.


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid search widget width

2018-10-03 Thread Θωμάς Γκλεζάκος
Could someone please help me alter the width of the default field of the 
search widget in SQLFORM.grid?

Thank you in advance for your time

Thomas.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid on page with custom request.vars

2018-07-18 Thread watr
I find SQLFORM.grid search doesn't work on a page with custom request.vars. 
Is there a way to fix the grid so it works?

Thanks,

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid Add multiple items in links

2018-06-15 Thread watr
Here is my links code:

links = [
dict(header='Balance', body=lambda row: row.po.amount - 
row.invoice_items.amount_pretax),
dict(header='Controls', body=[
lambda row: A('Invoices',_class='button btn 
btn-default',_href=URL('invoice', 'list', args=['commitment', row.po.id], 
vars=dict(source=here))),
lambda row: A('Edit',_class='button btn 
btn-default',_href=URL('edit', args=row.po.id, vars=dict(source=here))),
lambda row: A('Files',_class='button btn 
btn-default',_href=URL('attachments', 'list', 
args=['commitment',row.po.id], vars=dict(source=here))),
lambda row: A('Delete',_class='button btn 
btn-default',_href=URL('delete', args=row.po.id, vars=dict(source=here)))
 ]
]

However, I get an "attribution error" for the first dict, and a "list not 
callable" for the controls dict.

What is the correct method for adding multiple columns with one column 
having multiple links in it?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid: represent a field with IS_IN_SET validator by its label instead of its value

2018-04-15 Thread xelomac
Consider the following example.

Model:

GENDER = {"male": T("Mr.", lazy=False),
"female": T("Ms.", lazy=False)}

db.define_table('person',
Field('gender', label = T('Salutation'), requires=IS_IN_SET(GENDER)),
Field('first_name', label = T('First Name'),
Field('last_name', label = T('Last Name')),
format = '%(last_name)s')

In a SQLFORM.grid I want to represent the field gender by its translated 
label not by its value. How can I achieve this?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid buttons

2018-03-06 Thread Esprit Garonne
Hello, 
Does it a bug All buttons in SQLFORM have only text link. And I am working 
on school project for carpool, Could someone help me 
to build "etapes" like this https://www.blablacar.fr/offer-seats/1
I need only  how to add city or remove it for a "one trajet"  Could I do it 
with SQLFORM.factory with JQUERY?
Many thx
This is my model 
 
db.define_table('t_villes',
Field('dep', type='string', notnull=True,
  label=T('Département')),
Field('nom', type='string', notnull=True,
  label=T('ville')),
Field('code_postal', type='string', notnull=True,
  label=T('Code postal')),
Field('longitude_deg', type='float', notnull=True,
  label=T('Longitude')),
Field('latitude_deg', type='float', notnull=True,
  label=T('Latitude')),
format='%(nom)s %(code_postal)s'
   )


db.define_table(
't_trajets',
Field('membre_voiture_id','reference t_voitures'),
Field('lieu_depart_id','reference t_villes',requires=
IS_IN_DB(db,'t_villes.id','t_villes.nom')),
Field('lieu_arrive_id',db.t_villes),
Field('depart_le','datetime'),
Field('frequence',requires=IS_IN_SET(FREQUENCES),default=
FREQUENCES[0]),
Field('type',requires=IS_IN_SET(TYPE_TRAJETS),default=
TYPE_TRAJETS[0]),
Field('fumeur',requires=IS_IN_SET(FUMEUR),default=FUMEUR[1
]),
Field('commentaire','text'),
   
Field( 'place_offert','integer'),
   auth.signature
 

)
db.define_table('t_etapes_ville',
Field('trajet_id','reference t_trajets',requires=IS_IN_DB(db,
't_trajets.id','t_trajets.lieu_depart_id')),
Field('ville_id',db.t_villes,requires=IS_IN_DB(db,'t_villes.id',
't_villes.nom')),
Field('ordre_depart','integer'),

   )



-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid custom form on validation, oncreate not triggered

2017-11-15 Thread Yebach
Hello

I have a custom form from SQLFORM.grid. After clicking the submit button 
onvalidation or oncreate funciton are not triggered - although some fields 
are validated, but that is even before the my_processing_form function 
there is no redirect after submit and the record is not inserted/updated in 
the database. I used the same principle with some other functions and views 
and there it works fine, but I have no idea why at this one the on validate 
is not triggered.
If anyone sees  the error please let me know

Here is my function

def shifts():
user = auth.user_id
org = db(db.auth_user.id == 
user).select(db.auth_user.organization)[0]["organization"]

db.workers.w_user.default = user
db.workers.w_organization.default = org
#Naredimo še grid za šifrant turnusov
db.shifts.sh_organization.default = org

query_shifts = ((db.shifts.sh_organization == org) & (db.shifts.sh_status 
== 1))
query_inactive = db((db.shifts.sh_organization == org) & 
(db.shifts.sh_status == 100)).select().as_list()
# print query_inactive

###V kolikor uporabnik naredi turnus ki je že ampak je 
arhiviran/deaktiviran ga je potrebno na to opozorit
##Določimo da ne more bit za istga userja dvakrat isti turnus

# db.shifts.sh_code.requires=IS_NOT_IN_DB(db(db.shifts.sh_organization == 
org),'shifts.sh_code')

# najprej popravmo definicijo tabele

fields_shifts = (
db.shifts.sh_code,
db.shifts.sh_name,
db.shifts.sh_color,
db.shifts.sh_category,
db.shifts.sh_start1,
db.shifts.sh_end1,
db.shifts.sh_length1,
db.shifts.sh_start2,
db.shifts.sh_end2,
db.shifts.sh_length2,
db.shifts.sh_duration1,
# db.shifts.sh_start3,
# db.shifts.sh_end3,
# db.shifts.sh_start4,
# db.shifts.sh_end4,
# db.shifts.sh_start5,
# db.shifts.sh_end5,
db.shifts.sh_note)

db.shifts.sh_organization.readable = False
db.shifts.sh_organization.writable = False
db.shifts.sh_organization.editable = False

# db.shifts.sh_code.editable = db.shifts.sh_code.writable = False

# db.shifts.sh_duration.writable = False

db.shifts.sh_duration1.readable = db.shifts.sh_duration1.writable = False
db.shifts.sh_start3.readable = db.shifts.sh_start3.writable = False
db.shifts.sh_end3.readable = db.shifts.sh_end3.writable = False
db.shifts.sh_length3.readable = db.shifts.sh_length3.writable = False
db.shifts.sh_start4.readable = db.shifts.sh_start4.writable = False
db.shifts.sh_length4.readable = db.shifts.sh_length4.writable = False
db.shifts.sh_end4.readable = db.shifts.sh_end4.writable = False
db.shifts.sh_start5.readable = db.shifts.sh_start5.writable = False
db.shifts.sh_length5.readable = db.shifts.sh_length5.writable = False
db.shifts.sh_end5.readable = db.shifts.sh_end5.writable = False


db.shifts.sh_code.widget = SQLFORM.widgets.string.widget
db.shifts.sh_name.widget = SQLFORM.widgets.string.widget
db.shifts.sh_note.widget = SQLFORM.widgets.string.widget
db.shifts.partner_id.widget = SQLFORM.widgets.integer.widget
#db.shifts.sh_category.widget = SQLFORM.widgets.integer.widget
#db.shifts.sh_start1 = SQLFORM.widgets.time.widget
#db.shifts.sh_start1 = SQLFORM.widgets.timewidget.widget

db.shifts.sh_code.requires = [IS_NOT_IN_DB(db((db.shifts.sh_organization == 
org)&(db.shifts.sh_status != 250)), 'shifts.sh_code',
   error_message=T('Shift with this 
code already exist. Follow the link in upper right corner'))]

db.shifts.sh_name.requires = [IS_NOT_EMPTY(error_message=T('Missing shift 
name'))]
db.shifts.sh_color.requires = [IS_NOT_EMPTY(error_message=T('Missing shift 
color'))]
db.shifts.sh_start1.requires = [IS_NOT_EMPTY(error_message=T('Missing start 
time of the shift'))]
db.shifts.sh_end1.requires = [IS_NOT_EMPTY(error_message=T('Missing end 
time of the shift'))]
# db.shifts.sh_category.requires = [IS_NOT_EMPTY(error_message=T("""Missing 
shift category.1 – Morning, 11- Afternoon, 21 – Night
# 101 – All 
day,121 – All night,201 – Day split"""))]
db.shifts.partner_id.requires = 
IS_EMPTY_OR(IS_NOT_IN_DB(db((db.shifts.sh_organization == org)
& (db.shifts.sh_status != 
250)
& (db.shifts.partner_id == 
request.vars.partner_id)
& (db.shifts.partner_id >= 
0)), db.shifts.partner_id,
  error_message=T('There is a shift 
with the same partned ID.')))



links = [lambda row: A('', _class='glyphicon glyphicon 
glyphicon-remove-sign',
   callback=URL('settings', 'deactivate',

[web2py] SQLFORM.grid and custom forms behavior

2017-09-26 Thread Tiago Barrionuevo
Hi!
I'm trying to use custom forms for the actions used internally by the 
SQLFORM.grid and that are called by the grid links. 
I got all that working but now I need to do my own data manipulation after 
the grid processes and accepts the form. However if I call 
"mygrid.update_form.accepted" nothing happens and it's because the grid's 
internal do the redirect after the update_form processing!
This preclude any form post processing outside the grid.

After a lot of research I developed the follow method to work with 
SQLFORM.grid and custom forms:

controller action: facilities_list()

grid = SQLFORM.grid(query, args=request.args[:2], 
field_id=db.facility.id, formname='grid_facilities')

if 'edit' in request.args:
form = grid.update_form

if form.accepted:
### custom processing here ###
session.flash = 'Facility updated!'
redirect(URL(request.controller, 'list'))

response.view = '%s/facility_edit.%s' % (request.controller, 
request.extension)
return dict(item_name=db.facility._singular, form=form)

return dict(item_name=db.facility._singular, grid=grid)



However the code inside the block "if grid.update_form.accepted:" is never 
executed because what I explain above. 

The only solution a found was change the SQLFORM.grid code to accepts one 
more parameter "custom_form=False" (defaults to false) and in the case it's 
True (when using custom forms) it don't redirects to the referrer and 
return normally and so I can test the updated_form.accepted, do my custom 
processing and redirect by myself.

Another important behavior would be make available the referrer in the grid 
for external access like this:

if grid.update_form.accepted:
### custom processing here ###
session.flash = 'Facility updated!'
redirect(grid.referrer)

I apologize if already there is a possible solution for this!
Thanks in advance.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid selectable with multiple buttons behaves strange

2017-09-04 Thread A3
When using SQLFORM.grid  selectable with multiple button I get the 
following phenomena:

- When I click the buttons the associated action is properly performed. 
which is the download of a zip file or excel file.
- After the download the button text of the second button changed and 
becomes equal to the first one.  
- When I click the button again, no action is performed but the text 
changes back to the original.

- If there is no row selected a flash message is show to instruct the user. 
In this case the buttons remain unchanged.  

- The problem is probably related to the " raise HTTP" part of the download 
see below.

- I do not understand what happens after the raise HTTP.

Can anybody help me with this?

Thanks, A3


Here is a fragment of the code:

@auth.requires_login()
def view_report_simple():
qr = (db.reports.Customerid=="020030")
fields = (db.reports.id,db.reports.Reportdate, db.reports.Reportnr, 
db.reports.Reference,db.reports.Sample_date)
list_of_names_to_include = ['Reportdate','Reportnr','Reference']
[setattr(f, 'readable', False) for f in db.reports if f.name not in 
list_of_names_to_include]
left = None
links = [dict(header='',body=lambda row: A('Pdf', 
_class='btn',_href=(URL('default','showpdf',vars=dict(id=row.reports.id, 
Reportnr= row.reports.Reportnr))),
   user_signature=True)),
]
grid = SQLFORM.grid(qr,fields =fields,
orderby= 
~db.reports.Reportdate|~db.reports.Reportnr,
groupby = db.reports.Reportnr,
left = left,
create = False,
deletable = False,
editable = False,
showbuttontext=False,
csv=False,
maxtextlength = 64,
paginate = 10,
links_in_grid=True,
links = links,
selectable = [('Download selected PDFs as 
ZIP',lambda row : mapping_multiple(row)), 
   ('Download selected as EXCEL',lambda 
row : mapping_multiple_excel(row))
  ]
   )
heading=grid.elements('th')
if heading:
heading[0].append(INPUT(_type='checkbox', 
_id = 'check_all',

_onclick="""jQuery('input[type=checkbox][name="records"]').each(function(k)
{if 
($("#check_all").prop("checked")){

 jQuery(this).prop('checked', true);

 }else{

 jQuery(this).prop('checked', false);

  }
});"""))
details = DIV("Details",_id="details")
return dict(grid=grid, details=details, reportnr="123456")

@auth.requires_login()
def mapping_multiple_excel(ids):
#ids is equal to Reportnr because groupby = db.reports.Reportnr,
if ids<>None and ids<>'' and len(ids)<>0:
book = None
buff = None
import xlwt
import StringIO
buff = StringIO.StringIO()
# This is my excel file:
book = xlwt.Workbook()
lent = len(ids)
if len(ids) > 1:
start = ids[0]
end = ids[-1]
filename = "Reports {start}_{end}".format(start=start, end=end)
else:
start = ids[0]
filename = "Reports {start}".format(start=start)
sheet1 = book.add_sheet('Reports')
fields = customheaderlist
for col in range(len(fields)):
sheet1.write(0,col,fields[col])
r = 1  
for row in ids:
Rnr = row
q = (db.reports.Reportnr==Rnr)
s = db(q)
xlsrow = s.select(cache=(cache.ram, 1800)).first()
if xlsrow == None:
return 'Report nr %s not found' % Rnr
report=xlsrow.get('reports')
data = [ reports.field1, reports.field2,   ]
for col in range(len(data)):
sheet1.write(r,col,data[col])
r = r + 1
book.save(buff)
response.headers['Content-Type']='application/vnd.ms-excel'
response.headers['Content-Disposition'] = 'attachment; 
filename="%s.xls"' % filename
raise HTTP(200, buff.getvalue(), **response.headers)
#return
else:
session.flash = DIV("Select one or more reports")
return
return

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- 

Re: [web2py] SQLFORM.grid search type error reduce()

2017-08-15 Thread Paul Ellis
ok no more errors.

If I search for a name (John) for example in the table i get everything, Or
for his ID (11) I get everything.

I realise this is a join table (Many to Many) so it's no big deal but the
search here is not very useful.

I will need to implement special grids for these situations.

Thanks for the fix.

On Tue, Aug 1, 2017 at 10:46 AM, Paul Ellis  wrote:

> I am getting this error only when searching the auth_membership table
>
> I have put in a basic 'appadmin' in my webapp. I call it 'tooladmin' to
> differentiate from the built in stuff.
>
> I use this function to edit any database table:
> def manage_table():
> tablename = request.args(0)
> pagetitle = H4('{0} {1}'.format(T('Manage'), tablename))
> buttongroup = [_btn_index()]
> table = db[tablename]
> pagecontent = SQLFORM.grid(table, args=[request.args(0)])
>
>
> response.view = 'tooladmin_core.html'
> return dict(pagetitle=pagetitle, buttongroup=buttongroup,
> pagecontent=pagecontent)
>
> The search feature on the SQLFORM.grid is throwing this error when
> searching the auth_membership table:
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
>
> Traceback (most recent call last):
>   File "E:\web2py\gluon\restricted.py", line 227, in restricted
> exec ccode in environment
>   File "E:/web2py/applications/OfferTool/controllers/tooladmin.py" 
> , line 
> 262, in 
>   File "E:\web2py\gluon\globals.py", line 417, in 
> self._caller = lambda f: f()
>   File "E:/web2py/applications/OfferTool/controllers/tooladmin.py" 
> , line 
> 136, in manage_table
> pagecontent = SQLFORM.grid(table, args=[request.args(0)])
>   File "E:\web2py\gluon\sqlhtml.py", line 2526, in grid
> subquery = SQLFORM.build_query(sfields, keywords)
>   File "E:\web2py\gluon\sqlhtml.py", line 1827, in build_query
> ) for k in key.split()])
> TypeError: reduce() of empty sequence with no initial value
>
>
>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/UnN6AyOh2Lg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid, pagination and LOAD helper

2017-08-02 Thread Akash B
I'm relatively new to the web2py framework and I've been enjoying writing 
code because of all the features that the framework provides.

Here is the issue I've run into:

   1. I have a controller named "demo" with a function "f1" that returns an 
   SQLFORM.grid directly from a table. The pagination for the grid is set to 
   10 (example value).
   2. Everything works fine if I use a corresponding HTML view. 
   3. My actual goal is to load this grid and keep refreshing it every 10 
   seconds through XHR. For this, I created a simple view "demo/f1.load" which 
   contains {{=grid}} and the "demo/f1.html" view has the following:
   {{=LOAD('demo', 'f1.load', ajax=True, content='Loading...', times=20, 
   timeout=1, user_signature=True)}}
   4. This works as intended until I navigate to page 2 of the grid. Once I 
   do that, the next XHR trigger based on the timeout takes me back to page 1 
   (as opposed to refreshing page 2).
   5. Is there a way to maintain state for the page number in the 
   "demo/f1.html" view and then pass it to the LOAD helper so that the next 
   XHR does not take the user back to page 1 of the grid?

Thank you for your help!

Akash

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid search type error reduce()

2017-08-01 Thread Paul Ellis
I am getting this error only when searching the auth_membership table

I have put in a basic 'appadmin' in my webapp. I call it 'tooladmin' to 
differentiate from the built in stuff.

I use this function to edit any database table:
def manage_table():
tablename = request.args(0)
pagetitle = H4('{0} {1}'.format(T('Manage'), tablename))
buttongroup = [_btn_index()]
table = db[tablename]
pagecontent = SQLFORM.grid(table, args=[request.args(0)])


response.view = 'tooladmin_core.html'
return dict(pagetitle=pagetitle, buttongroup=buttongroup, 
pagecontent=pagecontent)

The search feature on the SQLFORM.grid is throwing this error when 
searching the auth_membership table:

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.

Traceback (most recent call last):
  File "E:\web2py\gluon\restricted.py", line 227, in restricted
exec ccode in environment
  File "E:/web2py/applications/OfferTool/controllers/tooladmin.py" 
, line 
262, in 
  File "E:\web2py\gluon\globals.py", line 417, in 
self._caller = lambda f: f()
  File "E:/web2py/applications/OfferTool/controllers/tooladmin.py" 
, line 
136, in manage_table
pagecontent = SQLFORM.grid(table, args=[request.args(0)])
  File "E:\web2py\gluon\sqlhtml.py", line 2526, in grid
subquery = SQLFORM.build_query(sfields, keywords)
  File "E:\web2py\gluon\sqlhtml.py", line 1827, in build_query
) for k in key.split()])
TypeError: reduce() of empty sequence with no initial value



-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid with selectable checkboxes that export CSV files on submit

2017-06-29 Thread 'Matthew J Watts' via web2py-users
Hi all

 I'm trying to modify an SQLFORM.grid so it has selectable check boxes, 
 which allow the user to download selected queries as CSV files once the 
submit button has been clicked. 

Can anyone help me with this?

Thanks in advance

Matt

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid filtering with local and external table

2017-06-12 Thread J-Michel Angers
Hi,
My app goes forward, I have plaisure to develop with web2py.
But sometimes I don't find myself the solution for very specific search.

My app works well now, I can fill a request, add/remove parts, add/remove 
attached, calculate price, send this request to collect signatures 
Now I try to display in the first "index" page (a SQLFORM.grid), only the 
requests that interest the user who is at the keybord (for the guitar it's 
someone else).
The criteria are :
 * only the requests that are not closed (and another page or another 
filter to display old closed requests)
 * only the requests that were written by this user
 *  OR the requests that this user HAS already signed OR those that this 
user HAS TO sign OR those that this user WILL HAVE to sign.
A request (table = "Demande") has to be signed by many persons and managers 
(not always the same) => table = "Workflow" (shortcut TDW).

In the first version of my app, each user see all the requests (not 
closed), and the SQLFORM.grid works well.
form = SQLFORM.grid((dbW.Demande.Statut!='Close'), ...)
In the second version, the user can see his own requests (that he has 
created) AND also those he HAS TO sign.
form = SQLFORM.grid((dbW.Demande.Statut!='Close') &
  ((dbW.Demande.CreatedBy==session.CurrentUser)
  |(dbW.Demande.NextSign==session.CurrentUser)),
But now I want to show also the requests that he HAS already signed, OR 
requests that he WILL HAVE to sign.
FIRST TRY :
form = SQLFORM.grid((dbW.Demande.Statut!='Close') &
  ((dbW.Demande.CreatedBy==session.CurrentUser)
  |(dbW.Demande.NumDA in (select NumDA from TDW 
where Responsable==session.CurrentUser)),
I already knew that this syntax doesn't work.

SECOND TRY :
liste_DA_filtre = []
for DA in dbW(dbW.TDW.Responsable==session.CurrentUser).select(dbW.TDW.
NumDA):
liste_DA_filtre.append(DA.NumDA)
form = SQLFORM.grid((dbW.Demande.Statut!='Close') &
  ((dbW.Demande.CreatedBy==session.CurrentUser)
  |(dbW.Demande.NumDA in  liste_DA_filtre)),
Is there any way to do a "in()" ?

THIRD TRY :
liste_DA_filtre = []
for DA in dbW(dbW.TDW.Responsable==session.CurrentUser).select(dbW.TDW.
NumDA):
liste_DA_filtre.append(DA.NumDA)
selection_DA = dbW(dbW.WFDA_DemAchat).select().find(
 lambda row: row.Statut!='Close' and (row.CreatedBy==session.
CurrentUser or row.NumDA in liste_DA_filtre))
form = SQLFORM.grid((selection_DA, ...)
I know that this syntax is not correct : SQLFORM.gris needs a request, not 
a set of data.
But I wrote this only to check the data that are filtered... and this is 
exactly the rows I'm looking for.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid - trying to limit search filter to queried items not entire table items

2017-05-31 Thread Peter


I have a person table and a task table, every task references some person.

Both tables have a virtual field 'display_name' that constructs a 
meaningful coded name returned 
as a string to display on screen if person is a 'client'.  
 
SQLFORM.grid is used to provide a selectable list of entries filtered from 
the task table.

*I want to use the coded display_names in the grid and to be able to search 
within the field content (as text) for filtering*.
   
Using task.display_name (virtual field) in the grid creates issues 
because... 
the field it is not available to add to any search criteria. (note: It's 
not made readable=False anywhere)
it's not sortable, 
it looks different - the title header is shown in plain black 
so not being handled in the same way as 'normal' fields 
.



Trying a work around with task.person

db.task.person.represent = lambda id, row: row.display_name

results in other issues - 

the person field is available to search 



but when trying to add any search criteria (a name) it shows the default 
 table  'format='  (i.e. not the coded names) in the drop down,
sorting works but is done on hidden id and not by visible 
name/alphabetically.
the list of available names to choose from is a complete list of all names 
in the person table i.e. not filtered to the available names in the grid 
entries 
also the choice is selectable as an id (= or !=) as opposed to searchable 
as text.

So after all that (sorry if it's long winded)...

Is it possible to get the display_name (virtual field) to appear/behave as 
a 'normal' field in the grid? 
Ideally making it available as an option in the field drop down list and 
available to search as text  with appropriate 
selectors ('starts with', 'contains'  etc  and not as an id field like the 
person field with an extended drop down list of names).


Thanks!




-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid question

2017-04-24 Thread Jim Russell
Hi all.

I'm having an issue with an SQLFORM.gird query. I have a table where one of 
the columns references another table. Here are the table definitions:

db.define_table('osrwhitelistpool',
Field('id', type='id'),
Field('pool', type='string', length=255, unique=True),
Field('wltype', type='reference osrwlpooltype'),
Field('comments', type='string', length=255),
Field('ctime', type='datetime', default=request.now))

db.define_table('osrwlpooltype',
Field('id', type='id'),
Field('wtype', type='string', length=32, unique=True))

So osrwhitelistpool field wltype references osrwlpooltype field wtype.

When I run a simple query, just requesting the whole table I get an error Query 
Not Supported: invalid literal for long() with base 10: 'ALL'

I'm not sure why it thinks that field should be a long.

Here are the table definitions directly from the DB:

osrtest=# \d osrwlpooltype
Table "osrtest.osrwlpooltype"
 Column | Type  |Modifiers
+---+--
 id | integer   | not null default 
nextval('osrwlpooltypeseqpk'::regclass)
 wtype  | character varying(32) | not null
Indexes:
"osrwlpooltype_pkey" PRIMARY KEY, btree (id)
"osrwlpooltype_wtype_key" UNIQUE CONSTRAINT, btree (wtype)
Referenced by:
TABLE "osrwhitelistpool" CONSTRAINT "osrwhitelistpool_wltype_fkey" 
FOREIGN KEY (wltype) REFERENCES osrwlpooltype(wtype)

osrtest=# \d osrwhitelistpool
Table "osrtest.osrwhitelistpool"
  Column  |Type |  Modifiers
--+-+-
 id   | integer | not null default 
nextval('osrwhitelistpoolseqpk'::regclass)
 pool | character varying(255)  | not null
 wltype   | character varying   |
 comments | character varying(255)  |
 ctime| timestamp without time zone | default now()
Indexes:
"osrwhitelistpool_pkey" PRIMARY KEY, btree (id)
"osrwhitelistpool_pool_key" UNIQUE CONSTRAINT, btree (pool)
Foreign-key constraints:
"osrwhitelistpool_wltype_fkey" FOREIGN KEY (wltype) REFERENCES 
osrwlpooltype(wtype)



I changed the table definition in db.py to 

db.define_table('osrwhitelistpool',
Field('id', type='id'),
Field('pool', type='string', length=255, unique=True),
Field('wltype', type='string'),
Field('comments', type='string', length=255),
Field('ctime', type='datetime', default=request.now))

and it worked to display it. But then when I edit a record it is just a 
free form text field instead of a dropdown with the wtype field from 
osrwlpooltype.

Any ideas what I'm doing wrong?

Thanks,
Jim

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid without advanced search

2017-04-24 Thread Gael Princivalle
Hello.

Is it possible to customize a SQLFORM.grid for having only the global 
search field?
In other words by default when the user click in the global search field 
another area is displayed that give the possibility to the user to choose 
in which field he would like to search. I would like to not display this 
area.

Thanks in advance.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] SQLFORM.GRID Change Header and labels too?

2017-04-07 Thread Javier Pepe
Hi

You can use de label atribute in Field definition, this used in all forms.


   - label is a string (or a helper or something that can be serialized to
   a string) that contains the label to be used for this field in
   auto-generated forms.

http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Field-constructor


2017-04-07 13:38 GMT-03:00 r :

> So I have changed the header for my sqlform grid:
>
> grid = SQLFORM.grid(db.adminis,headers={'adminis.Name':'Name'
> ,'adminis.Description':'Description','adminis.Rating':'Average Rating'})
>
> and when I click on view/edit I would like the same labels to be used. How
> is it possible ?
>
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.GRID Change Header and labels too?

2017-04-07 Thread r
So I have changed the header for my sqlform grid:

grid = 
SQLFORM.grid(db.adminis,headers={'adminis.Name':'Name','adminis.Description':'Description','adminis.Rating':'Average
 
Rating'})

and when I click on view/edit I would like the same labels to be used. How 
is it possible ?


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid field.represent not working with joined tables

2017-02-14 Thread Paul Ellis
I have have a grid with a left outer join. So the row objects look like 
this:


I am trying to use represent to make some of them editable. For the 
optional checkbox it is like this:
db.product_offer_item.optional.represent = lambda value, row: 
INPUT(_type='checkbox',

_checked=value,

_name='optional',

_id=row.product.id
)
and placed just before the grid is created. Now I am getting an Attribute 
Error from adding the ID to the checkbox. If I just ad the whole row as the 
ID it works and I get an ID which looks like the row object above (that's 
where I copied the details from) but when I try to access the row data to 
put the product.id as the ID it throws an error. I also can't access the 
sub object product or product_offer_item, I get the same error.

With the left outer join, the product.id is present for all rows, the 
product_offer_item details are not.

I haven't had this problem before and can't think of a way to add a row 
unique identifier any other way. 

Why am I getting an Attribute Error when I can clearly see the attributes.


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid changing the behaviour when there are no records

2017-02-13 Thread Paul Ellis
I want to display something else if the query returns empty. Like some 
instructions and buttons. 

I can't find anything in the SQLFORM.grid signature, like an on_empty 
option and haven't found anything in the book or by googling.

As the Add button doesn't fit this situation. I am getting a DIV with the 
text 'No records Found' not an empty grid.

How can I do this without checking the DB for rows before calling the grid? 
This would then be accessing the DB twice when there are rows to be 
displayed which is most of the time.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid, groupby and sum/count

2017-01-16 Thread James Booth
Hey guys,

I'm trying to create a SQLFORM.grid that will display the total number of 
entries for each 'user' in a certain time period.

Basically, my model states that a user can only be in bursary_entries table 
once per day (This equates to a user swiping their ID card). I would like 
to be able to find out how many entries are recorded for a specific user 
per week, month, year, etc. and also filter it by the 'location' column too 
if possible.

from datetime import datetime
db.define_table('bursary_entries',
Field('barcode', type='string', requires=[IS_IN_DB_UPPER(db, 
'bursary_users.barcode')]),
Field('entry_time', type='datetime', default=request.now, 
readable=False, writable=False),
Field('entry_location', type='string', readable=False, 
writable=False, requires=[IS_IN_DB(db, 'bursary_locations.bursary_location'
)]),
Field('bursary_at_time', type='string', readable=False, 
writable=False, requires=[IS_IN_DB(db, 'bursary_users.bursary')]),
format='%(barcode)s'
)


I've tried simply:

query = (db.bursary_entries.entry_time > reportsform.vars.start_date)& \
(db.bursary_entries.entry_time < reportsform.vars.end_date)

# Left outer-joins
joins = [db.bursary_users.on(db.bursary_entries.barcode==db.
bursary_users.barcode)]
grid = SQLFORM.grid(query, left=joins, groupby=db.bursary_entries.
barcode)


But obviously that groups the values but doesn't have any kind of 
count/sum. I've tried a whole host of other things, but they've all fallen 
flat - Can anyone shed any light on the possibility of this?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] sqlform.grid search numeric fields

2016-12-03 Thread Scott Hunter
When using the basic (as opposed to advanced) search function of an 
SQLFORM.grid, it only appears to look in text fields, such that if I enter 
a number, it doesn't find any matches unless that number appears in a text 
field (even if that field is not one of the ones displayed in the grid).

Is this intentional?  Short of using the advanced search, is there a way to 
search numeric fields?

- Scott

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid: using groupby disables create?

2016-12-03 Thread Scott Hunter
I have a SQLFORM.grid in which I would like to use groupby as well as be 
able to create records.  But when I supply the groupby parameter, the Add 
Record button disappears, and can be made to re-appear if the only thing I 
change is remove the groupby parameter.

Is this a bug?  If it is a feature, can someone explain the reasoning 
behind it, and how I would best work around it?

- Scott

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid and oncreate error

2016-12-02 Thread Scott Hunter
If the oncreate callback for a SQLFORM.grid sets form.errors to true, the 
record is not created; similarly, if form.errors. is set to an 
error message.

However, shouldn't the form for adding the record return, and in the latter 
case, with the specified fields showing their error messages?  In my case, 
the list comes up instead.

Here is my form & callback although there isn't much to them:

def add_handler(form):
if form.vars.f_Member_ID=='':
form.errors.f_Member_ID = "ID required"
session.flash = "ID required"
return
session.flash = "Handler added"

form=SQLFORM.grid( db.t_member.f_User==t.f_User, args=request.args[:2], 
csv=False, 
searchable=True, deletable=False, details=False, editable=False, 
oncreate=add_handler,
fields=[db.t_member.f_Member_ID, db.t_member.f_FirstName, 
db.t_member.f_LastName] )

- Scott

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.Grid - Export CSV to contain 'links' too

2016-11-29 Thread James Booth
Hey guys,

I currently have the following:

db.define_table('bursary_users',
Field('forename', type='string', requires=IS_NOT_EMPTY()),
Field('surname', type='string', requires=IS_NOT_EMPTY()),
Field('studentId', type='string', requires=IS_NOT_EMPTY(), 
unique=True),
Field('barcode', type='string', requires=IS_NOT_EMPTY(), 
unique=True),
Field('email', type='string', requires=IS_EMAIL(), unique=
True),
Field('is_testuser', 'boolean'),
format='%(studentId)s'
)


db.define_table('bursary_entries',
Field('barcode', type='string', requires=[IS_IN_DB(db, 
'bursary_users.barcode')]),
Field('entry_time', type='datetime', default=request.now, 
readable=True, writable=False),
Field('entry_location', type='string', readable=True, 
writable=False, requires=[IS_IN_DB(db, 'bursary_locations.bursary_location'
)]),
Field('bursary_at_time', type='string', readable=True, 
writable=False, requires=[IS_IN_DB(db, 'bursary_users.bursary')]),
format='%(barcode)s'
)


And in my controller...

grid = SQLFORM.grid(query,
create=False,
editable=False,
deletable=False,
details=False,
paginate=50,
fields=[
db.bursary_entries.barcode,
db.bursary_entries.entry_time,
db.bursary_entries.entry_location
  ],
links=[
dict(header='Forename', body=lambda row: 
db(db.bursary_users.barcode==row.barcode).select().first().forename),
dict(header='Surname', body=lambda row: 
db(db.bursary_users.barcode==row.barcode).select().first().surname),
dict(header='Email', body=lambda row: db
(db.bursary_users.barcode==row.barcode).select().first().email)
  ])
 

But when I try to export my query as a CSV, I only get the 'fields' (Not 
the links). Is there a way around this?

Kind regards,
James.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] sqlform.grid + virtual field = key_error

2016-09-28 Thread Pierre
Hi,

here is the situation:

TABLE:

db.define_table('amsg',
Field('ufrom'),
Field('uto', 'reference auth_user'),
Field('mailbox_to_use','list:string',requires=IS_IN_SET((
'internal','private'),multiple=True),
   default=['internal']),
Field('subject'),
Field('jatom','json',required=True),
Field('created_date',default=str(request.now.date())),
Field('created_on','datetime',required=True,default=request.
now))

db.amsg.body =  Field.Virtual('body',
lambda row: ''.join('{0}\n{1}\n\n'.format(k,'  '.join([vi.encode("utf-8") 
for vi in v])) for k,v in   row.amsg.jatom.items()))



CONTROLLER FUNCTION

def show_amsg():
q = db.amsg.id == request.args(0)
fld=[db.amsg.ufrom,db.amsg.uto,db.amsg.subject,db.amsg.created_date,db.
amsg.body]
hd = {'amsg.ufrom':'From','amsg.uto':'To','amsg.subject':'subject',
'amsg.created_date':'date','amsg.body':'message'}
form = SQLFORM.grid(q,fields=fld,headers=hd,editable=False,create=False,
paginate=12,csv=False,user_signature=False)
return dict(form=form)



Traceback (most recent call last):
  File "/opt/web2py/gluon/restricted.py", line 227, in restricted
exec ccode in environment
  File "/opt/web2py/applications/prox/controllers/default.py" 
, line 
576, in 
  File "/opt/web2py/gluon/globals.py", line 412, in 
self._caller = lambda f: f()
  File "/opt/web2py/applications/prox/controllers/default.py" 
, line 
366, in show_amsg
form = 
SQLFORM.grid(q,fields=fld,headers=hd,editable=False,create=False,paginate=12,csv=False,user_signature=False)
  File "/opt/web2py/gluon/sqlhtml.py", line 2710, in grid
value = row[str(field)]
  File "/opt/web2py/gluon/packages/dal/pydal/objects.py", line 76, in 
__getitem__
raise KeyError
KeyError


what's wrong  ??

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid w/ selectable generates multiple requests

2016-09-21 Thread Scott Hunter
Here's a simple controller using an SQLFORM.grid w/ selectable:

def open_requests():
print 'Req: %r' % request.vars
query = ...
form = SQLFORM.grid(query, csv=False, details=False, deletable=False
, editable=False, searchable=False, create=False,
selectable = lambda ids : None)
return locals()

This, as expected, puts a checkbox on each row.  If I select two rows and 
hit Submit, I get the following printed from the server:

Req: 
Req: 

The section of the online book about this says the lambda in the selectable 
should be a redirect; when it was, I still got 2 requests, but the second 
had an added var w/ the selected IDs.

Is this the correct behavior?  If so, what is the reasoning behind it, and 
did I miss the explanation in the book?  

I'm using version 2.14.6

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid problems with Oracle database tables

2016-09-06 Thread Nico de Groot
Hi Tom,
I think you need to specify the join between the two tables in the query, 
otherwise you get the full product of the two tables. Please check the Web2py 
book at 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Inner-joins
 

Please show the model files if you need more help.

Nico de Groot 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid problems with Oracle database tables

2016-09-05 Thread 'tomt' via web2py-users
Hi,

I have been using SQLFORM.grid to display some legacy Oracle tables.  While 
it works fine when the query is for a single table, as soon as the query 
involves a join between two tables the grid returns multiple duplicate 
entries.  (I'm using web2py 2.13.4-)

The result looks like this:
PointnumberPointnameReferencename
1RTU 1 Status & ControlHarris Test
1RTU 1 Status & ControlHarris Test
1RTU 1 Status & ControlHarris Test
1RTU 1 Status & ControlHarris Test
1RTU 1 Status & ControlHarris Test
2RTU 2 Status & ControlHarris Test
2RTU 2 Status & ControlHarris Test
2RTU 2 Status & ControlHarris Test
2RTU 2 Status & ControlHarris Test
2RTU 2 Status & ControlHarris Test
3RTU 3 Status & ControlHarris Test
3RTU 3 Status & ControlHarris Test
3RTU 3 Status & ControlHarris Test
3RTU 3 Status & ControlHarris Test
3RTU 3 Status & ControlHarris Test
...

The following is the controller that generated the previous results.
..
def search1():
fields = 
[db2.STATUSPOINT.POINTNUMBER,db2.STATUSPOINT.POINTNAME,db2.AOR.REFERENCENAME]

maxtextlengths = {
   'STATUSPOINT.POINTNAME': 30,
   'AOR.REFERENCENAME': 30,
   }

query = ((db2.STATUSPOINT.POINTNUMBER < 100)&\
 (db2.STATUSPOINT.POINTACCESSAREA == db2.AOR.AOR))
 
orderby = [db2.STATUSPOINT.POINTNUMBER]
grid=SQLFORM.grid(
query=query,
deletable=False,editable=False,details=False,
searchable=True,fields=fields,
paginate=5,csv=False,maxtextlengths=maxtextlengths,
orderby=orderby,
)

print "search1 grid db2._timings %s" % db2._timings
print type(grid)
print len(grid)
return dict(grid=grid)
..

- the number of duplicates(5) is the same as the value for paginate.
- paging forward shows the same values.

- the sql reported by db2._timings is
[("ALTER SESSION SET NLS_DATE_FORMAT = '-MM-DD HH24:MI:SS'", 
0.00066494941711425781), ("ALTER SESSION SET
NLS_TIMESTAMP_FORMAT = '-MM-DD HH24:MI:SS'", 0.0005130767822265625), 
('SELECT count(*) FROM AOR,STATUSPOINT WHERE
((STATUSPOINT.POINTNUMBER < 100) AND (STATUSPOINT.POINTACCESSAREA = 
AOR.AOR))', 0.0013380050659179688), ('SELECT 
STATUSPOINT.POINTNUMBER, STATUSPOINT.POINTNAME, AOR.REFERENCENAME, AOR.AOR 
FROM (SELECT w_tmp.*, ROWNUM w_row FROM
(SELECT STATUSPOINT.POINTNUMBER, STATUSPOINT.POINTNAME, AOR.REFERENCENAME, 
AOR.AOR FROM AOR, STATUSPOINT WHERE
((STATUSPOINT.POINTNUMBER < 100) AND (STATUSPOINT.POINTACCESSAREA = 
AOR.AOR)) ORDER BY STATUSPOINT.POINTNUMBER) w_tmp
WHERE ROWNUM<=25) AOR, STATUSPOINT  WHERE ((STATUSPOINT.POINTNUMBER < 100) 
AND (STATUSPOINT.POINTACCESSAREA =
AOR.AOR)) AND w_row > 20  ORDER BY STATUSPOINT.POINTNUMBER', 
0.014330863952636719)]

- when I execute this sql from the command line using sqlplus, I see the 
same results with all the duplicates

- I believe there is flaw with the sql statements generated by web2py

- I wrote some sql that return more appropriate results but I'm not 
familiar enough with the inner workings of web2py to be able to implement 
it.
- If anyone has suggestions about where to start, what modules to change 
and best coding practices, I'd appreciate the pointers.

SELECT c1 "STATUSPOINT.POINTNUMBER", c2 "STATUSPOINT.POINTNAME", c3 
"AOR.REFERENCENAME"
FROM (
  SELECT w_tmp.c1, w_tmp.c2, w_tmp.c3, ROWNUM rn
  FROM (
SELECT STATUSPOINT.POINTNUMBER c1, STATUSPOINT.POINTNAME c2, 
AOR.REFERENCENAME c3
FROM AOR, STATUSPOINT
WHERE STATUSPOINT.POINTACCESSAREA = AOR.AOR
ORDER BY STATUSPOINT.POINTNUMBER
  ) w_tmp
  WHERE ROWNUM <= 30
)
WHERE rn > 20;

- Tom


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLForm.grid csv export

2016-07-28 Thread Ryan Hood


Hello,

 

I'm pretty new to Web2py.  I need some help with the SQLForm.grid export 
CSV functionality.I have the following basic structure:

 

*db.py*

db.define_table('test',

Field('name', 'string', length=50, notnull=True),

Field('email', 'string', notnull=True),

format="%(name)s")

*default.py*

def index():

query=(db.test.id>0)

fields=[db.test.id,db.test.name,db.test.email]

forms=SQLFORM.grid(query=query, csv=True)

return dict(forms=forms)

 

For some reason only the JSON and XML exports work but the CSV and TSV 
exports won't work.  For CSV, I keep getting the following error:

 

**

 

NOTE: my argument list looks like this: 

*Function argument list*

(self=, k='_extra')

 

NOTE: I have tried a couple different versions of Web2py on both CentOS and 
Windows and same error.

 

I'm sure I'm missing something small, but haven't been able to track it 
down.  Any help would be appreciated.

 

Thank you,

ryan

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid input fields size in auto generated Edit/New forms

2016-07-25 Thread icodk
How can I change the input field size (what is visible to the user) of 
SQLFORM.grid auto generated Edit/New forms.
Tried with length=50 but the fields are still about 20 chars long.
Also:  IS_LENGTH(minsize=5,maxsize=50) had no visible effect. None of the 
settings limits the number of chars user can type in. Only when submitting 
the form you get an error message. But this might be the intended  design.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid and fields: suppress columns in the grid

2016-05-24 Thread Martin Weissenboeck
Let's say I have table with two integer fields and one virtual field:

db.define_table('t1',
Field('aa','integer'),
Field('bb','integer'),
Field.Virtual('ab', lambda row: row.t1.aa+row.t1.bb),
)


The SQLFORM.grid works fine:

def ab():
grid=SQLFORM.grid(db.t1,
   fields=(db.t1.aa, db.t1.bb, db.t1.ab),
   user_signature=False,
 )
return locals()


​But I do not want to show the column bb and I tried:

​def ab():
grid=SQLFORM.grid(db.t1,
   fields=(db.t1.aa, db.t1.ab),
   user_signature=False,
 )
return locals()


and - of course - now I get a "key error", because the virtual field cannot
access db.t1.bb.

I understand, that the fields parameter decides, which columns should be
displayed AND which columns could be used in expressions, e.g. in a
lambda-function. But these columns could be different.

My question:
How can I use both columns in a function, but without displaying both
columns in the grid?

Or simple: is it possible to suppress a column in the grid which has been
selected in the fields parameter?

Regards Martin

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid links not working

2016-05-08 Thread Simon Carr
I have an SQLFORM.grid in a view to display a list of supplier contacts

When I click "Add Record", I get the error below.

Traceback

1.
2.
3.
4.
5.
6.

Traceback (most recent call last):
  File "E:\web2py\gluon\restricted.py", line 227, in restricted
exec ccode in environment
  File "E:\web2py\applications\srm\views\supplier/view.html", line 75, in 

AttributeError: 'NoneType' object has no attribute 'company_name'



I don't understand why  'company_name' is causing an error because it is 
not a field in my supplier_contacts table, it is in my supplier table.


-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] SQLFORM.grid change form vars

2016-03-19 Thread Vinyl Darkscratch-Kazotetsu
Ah, I see what my problem is — the default was defined after the SQLFORM.grid() 
in the controller, not before it.  Works like a charm, no errors or issues.

As for onvalidation, I’ll give it a whirl and see how it goes.  Thank you.

> On Mar 15, 2016, at 22:42, Anthony  wrote:
> 
> On Wednesday, March 16, 2016 at 1:32:26 AM UTC-4, Vinyl Darkscratch-Kazotetsu 
> wrote:
> I see it now — I had assumed that you could set the default in the controller 
> function, but it seems that it has to be in the model file.  Thank you for 
> your help on this issue.
> 
> No, default can be set after the model declaration, including in the 
> controller (but before the grid is created, as the grid method handles the 
> form processing and database insert, so any model attributes must be set 
> before calling the grid).
>  
> Still, though…I would like to know how to edit the variables submitted by the 
> form, and still unsure how to do that.  For example, if a staff member were 
> to post their Inkbunny link, I would want to force that link’s explicit field 
> to true, but by default they provide the choice of marking it as explicit 
> content or not.  Any good suggestions there?
> 
> Not exactly clear what you want to do, but maybe an onvalidation function 
> would work (it takes the form object, so you can access and manipulate 
> form.vars).
> 
> Anthony
> 
> -- 
> 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 a topic in the Google 
> Groups "web2py-users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/web2py/I9Xg4BI5SA8/unsubscribe 
> .
> To unsubscribe from this group and all its topics, send an email to 
> web2py+unsubscr...@googlegroups.com 
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] SQLFORM.grid change form vars

2016-03-15 Thread Anthony
On Wednesday, March 16, 2016 at 1:32:26 AM UTC-4, Vinyl 
Darkscratch-Kazotetsu wrote:
>
> I see it now — I had assumed that you could set the default in the 
> controller function, but it seems that it has to be in the model file. 
>  Thank you for your help on this issue.
>

No, default can be set after the model declaration, including in the 
controller (but before the grid is created, as the grid method handles the 
form processing and database insert, so any model attributes must be set 
before calling the grid).
 

> Still, though…I would like to know how to edit the variables submitted by 
> the form, and still unsure how to do that.  For example, if a staff member 
> were to post their Inkbunny link, I would want to force that link’s 
> *explicit* field to true, but by default they provide the choice of 
> marking it as explicit content or not.  Any good suggestions there?
>

Not exactly clear what you want to do, but maybe an onvalidation function 
would work (it takes the form object, so you can access and manipulate 
form.vars).

Anthony

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] SQLFORM.grid change form vars

2016-03-15 Thread Vinyl Darkscratch-Kazotetsu
I see it now — I had assumed that you could set the default in the controller 
function, but it seems that it has to be in the model file.  Thank you for your 
help on this issue.

Still, though…I would like to know how to edit the variables submitted by the 
form, and still unsure how to do that.  For example, if a staff member were to 
post their Inkbunny link, I would want to force that link’s explicit field to 
true, but by default they provide the choice of marking it as explicit content 
or not.  Any good suggestions there?

> On Mar 15, 2016, at 21:24, Anthony  wrote:
> 
> On Tuesday, March 15, 2016 at 9:18:00 PM UTC-4, Vinyl Darkscratch-Kazotetsu 
> wrote:
> The user_id field is both non-readable and non-writable already, which is 
> what's causing that error.  It's not receiving any data for the field from 
> anywhere.  As for the various argument passing parameters, I am unsure of how 
> to implement it into the website to set form.vars.user_id to auth.user.id 
> , would you please elaborate?
> 
> Note, the error you are seeing is unrelated to the issue of how to hide 
> particular fields from your users in the forms. If you've already set user_id 
> to be non-writable, there is no need for the "fields" argument to SQLFORM. 
> The problem you are having is due to the fact that the field is required but 
> you have excluded it from the form without specifying a default. So, if the 
> default should be auth.user_id, just do:
> 
> Field('user_id', 'reference auth_user', default=auth.user_id)
> 
> Anthony
> 
> -- 
> 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 a topic in the Google 
> Groups "web2py-users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/web2py/I9Xg4BI5SA8/unsubscribe 
> .
> To unsubscribe from this group and all its topics, send an email to 
> web2py+unsubscr...@googlegroups.com 
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid change form vars

2016-03-14 Thread Vinyl Darkscratch-Kazotetsu
It doesn't seem like anyone else has run into this particular issue before. 
 I have an SQLFORM grid that is allowing my staff members on our website to 
add links to their profile upon the crew page.  An example is mine 
at https://www.nightwave.me/crew?member=VinylDarkscratch
However, I found out that SQLFORM.grid does not take a *fields* parameter 
like normal SQLFORM does, and as such staff members have access to edit 
fields they should not be able to, such as the user ID.  So, I attempted to 
set a default for the fields, in the controller function, to be the value 
that I'd like it to be, however I had gotten the following error:

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.

Traceback (most recent call last):
  File "/home/vinyldarkscratch/nightwave/gluon/restricted.py", line 227, in 
restricted
exec ccode in environment
  File 
"/home/vinyldarkscratch/nightwave/applications/nightwave/controllers/default.py"
 , line 
294, in 
  File "/home/vinyldarkscratch/nightwave/gluon/globals.py", line 412, in 

self._caller = lambda f: f()
  File "/home/vinyldarkscratch/nightwave/gluon/tools.py", line 3774, in f
return action(*a, **b)
  File 
"/home/vinyldarkscratch/nightwave/applications/nightwave/controllers/default.py"
 , line 
68, in submit_bio_links
linkform = SQLFORM.grid((db.user_links.user_id == auth.user.id))
  File "/home/vinyldarkscratch/nightwave/gluon/sqlhtml.py", line 2264, in grid
onsuccess=oncreate)
  File "/home/vinyldarkscratch/nightwave/gluon/html.py", line 2301, in process
self.validate(**kwargs)
  File "/home/vinyldarkscratch/nightwave/gluon/html.py", line 2238, in validate
if self.accepts(**kwargs):
  File "/home/vinyldarkscratch/nightwave/gluon/sqlhtml.py", line 1711, in 
accepts
self.vars.id = self.table.insert(**fields)
  File "/home/vinyldarkscratch/nightwave/gluon/packages/dal/pydal/objects.py", 
line 712, in insert
ret = self._db._adapter.insert(self, self._listify(fields))
  File "/home/vinyldarkscratch/nightwave/gluon/packages/dal/pydal/objects.py", 
line 658, in _listify
'Table: missing required field: %s' % name)
RuntimeError: Table: missing required field: user_id


Any suggestions on how to set a field's value in an SQLFORM.grid after 
submission?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid() control detect_record_change

2016-02-26 Thread domezzzz


Ante todo, un saludo al Sr. Massimo Di Pierro y toda la colectividad que lo 
secunda, por este excelente framework, que no deja de sorprenderme.

 

Contexto del problema:

   Versión de web2py: 2.13.4 para windows (EXE) (siempre voy al día ;-))

   Sistema operativo: windows XP SP3.

   Db: postgresql 9.4

 

Estoy usando como mecanismo general de tratamiento CRUD y funcionalidad 
asociada a los reg.de una tabla, el método SQLFORM(grid).

Pero me tope con un problema no menor: dos (o más) usuarios que acceden al 
mismo registro en un mismo lapso de tiempo -están mirando la misma 
información obviamente-, uno de ellos denominado “primero”, actualiza los 
datos -nada que objetar-, pero luego, un “segundo usuario”, que tiene 
todavía una "vista de datos viejos", al dar confirmar para actualizar los 
suyos, termina realizando cambios sobre datos no previamente refrescados  como 
correspondería, si no que, además, campos que “segundo” no actualizó y 
están con valores “de la vista vieja”…..¡¡ se terminan restaurando ¡!!, 
anulando los valores que  “primero” realizó…..

 

 No encontré un mecanismo para detectar este hecho, y proceder a advertir a 
los usuarios, que deben refrescar los datos para proceder nuevamente a 
realizar cambios si corresponde, similar al que si poseen los formularios 
individuales con SQLFORM(form), como es, la acción DETECT_RECORD_CHANGE 
para el evento PROCESS().

 

Aclaro que no me estoy refiriendo al mecanismo transaccional de web2py y la 
DB -uso POSTGRESQL-, que funciona correctamente.


La solución que busco -si alguien ya la descubrió- , sería un mecanismo 
general para SQLFORM(grid), no para uno en particular. Quiero evitar el 
crear y asignar FORMs individuales para SQLFORM(grid) dado que, obviamente, 
se dispararían los tiempos de desarrollo, incrementando innecesariamente, 
la cantidad de objetos de la aplicación.

Previamente, intenté solucionar esto en el evento ONVALIDATION, consultando 
el objeto form que recibe como parámetro, en sus atributos (record, latest, 
detect_changed, detect_record_change). Pero no obtuve resultados.

La idea, es que esto debiera ser un chequeo normal del GRID y cualquier 
otro tipo de  FORM. Inclusive, debiera estar siempre activado y poder 
devolver un error específico y/o realizar una acción a sus efectos.


Gracias de antemano desde Montevideo/Uruguay.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid Search None value on a field

2016-01-22 Thread piero crisci
Hi 
I am using SQLFORM.grid of last version of web2py with MYSQL.
I would like to see all row of a table with a None value in a "Date" field.
SQLFORM.grid set the query in this format *db.t_tablename.f_datefield = ""* 
.
The query is converted in this MYSQL where condition:

   - AND t_tablename.f_datefield = NULL

Instead of :

   - AND t_tablename.f_datefield is  NULL

How can i solve this problem?
Thank for help

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid and jQuery-bootgrid help

2016-01-17 Thread piero crisci
Hi
I am new using jQuery and not very skilled in general with Javascript.
I am using the Basic Jquery Bootgrid example 
on a SQLFORM.grid and it worked 
fine, except for one thing.
One of the TD column contains a "Server Generated link" with 
user_signature. 
Using Bootgrid the TD column html is converted into string.
I recreated the link with the javascript as showed in the examples but I 
would like to use the link created from server side. 
Anyone using the bootgrid knows if there is a property that i can use to 
let Jquery Bootgrid not modify the link rendered by the server?

Here is an example of what I did (3rd TD tag)



ID
Sender
Received




10238
x...@pingpong.com 
http://www.google.com/>?book=Pippo=32hih327dsa*">Book



I would like to keep the red link is it possible?

Thanks for help
Kind Regards
Piero

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid(): help requested

2016-01-11 Thread Wolf-Dieter Klotz
I was struggling quite some time with web2py, but finally solved a lot of 
misunderstood problems myself. However I never succeeded in the following. 
In my controller I create a grid with form=SQLFORM.grid(...). form is not 
an object it is a member of SQLFORM. I want to add custom buttons to the 
grid, but can't use form.add_button(). To make it short, I never succeeded 
to add my custom buttons to the grid - only in the view with a  
html tag. Is there an example how to add custom buttons to SQLFORM.grid() 
directly?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid custom buttons text

2015-12-09 Thread Анатолий Стешенко
Good day. How i can change text of buttons of the SQLFORM.grid?
For example i want to change "Add Record" to "Add new item","View" to "Show 
details".

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid with joined tables - choose which table to view/edit by default

2015-11-24 Thread Thomas Sitter
Hello,

I have two tables that I'd like to join in a SQLFORM.grid. When viewing or 
editing an entry in the grid I'd like to edit the cheque table, but by 
default the customer table is selected. How can I change this? I've 
recreated the relevant code below.

#db.py

db.define_table('customer',
 Field('firstname', label = "First Name"),
 Field('lastname', label = "Last Name"),
)


db.define_table('cheque',
 Field('customer_id', 'reference customer'),
 Field('cheque_sent', 'boolean'),
 Field('cheque_value', 'double'),
)


#default.py

def test_view():
  query = (
(db.cheque.customer_id == db.customer.id) &
(db.cheque.cheque_sent == True)
)

  fields = [
  db.customer.lastname, 
  db.cheque.cheque_sent,
  ]

  cheques = SQLFORM.grid(query=query, fields=fields)

  return dict(cheques=cheques)


How do I change the behaviour of the grid to bring up a form for the 
cheques table rather than customer?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py SQLFORM.grid with executesql

2015-11-14 Thread Anthony

>
> I stumbled on this:
>
> https://groups.google.com/forum/#!topic/web2py/b5UMpF-3REI
>
>
> but i didn't really get the solution.
>

The solution mentioned there is the same as this one 
 on Stack Overflow, which 
involves creating a view or table in the database that represents the union 
of the two tables. Then create a DAL model for the view and pass that model 
to the grid. The grid does not take a Rows object or arbitrary SQL.

Anthony 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Web2py SQLFORM.grid with executesql

2015-11-14 Thread TYRANISTAR


Hello,


I am making a web2py application and I have my two mysql tables defined in 
my models db.py file:


db.define_table('table1', Field('id','integer'), Field('name','string'), 
migrate=False) db.define_table('table2', Field('id','integer'), 
Field('name','string'), migrate=False)

I want my application to return a union of these tables:


data=db.executesql('SELECT * FROM table1 union select * from table2;')

in a SQLFORM.grid but apparently


form=SQLFORM.grid(data, create=False, deletable=False, editable=False, 
maxtextlength=100, paginate=10)

is not the way to go.


Can somebody help me please?


I stumbled on this:

https://groups.google.com/forum/#!topic/web2py/b5UMpF-3REI


but i didn't really get the solution.


Can someone give me an example?


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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid export and user_signature issue

2015-11-12 Thread Carlos Kitu
There seems to be an issue with export (any class of export: csv, tsv, ...) 
in SQLFORM.grid when using user_signature and the corresponding decorator.
Pressing any export button in that context generates a:

Not authorized. Insufficient privileges - Error

Here is a minimal example of the code:

*db_00.py*
db.define_table('table01',
Field('field01', 'string', length=50, notnull=True, unique=False, label=
'field01', comment='field01'))



*default.py*
def first():
redirect(URL('second', user_signature=True))


@auth.requires_signature()
@auth.requires_login()
def second():
grid=SQLFORM.grid(db.table01, 
  csv=True,
  user_signature=True)
return grid



Once logged in, I'm calling default/first, just to get a signed url to 
default/second, where the grid is shown. Then I press the export button, 
getting the aforementioned error.

Removing the @auth.requires_signature() decorator makes everything work 
fine.

Web2py version used:
2.12.3-stable+timestamp.2015.08.19.00.18.03
(Ejecutando en Rocket 1.2.6, Python 2.7.6)

Any help will be greatly appreciated.
Best regards.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] sqlform.grid csv export set delimiter

2015-11-10 Thread Yebach
Hello

Is it possible to set the delimiter (tab delimited) for csv export from 
SQLform.grid?

also if I want to export some rows but do not want to show them in grid, 
what is the syntax to use (I want to hide a column db.workers.id, but i 
want to export it)?

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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid: search in a list:reference field does not work

2015-11-08 Thread Martin Weissenboeck
I have a table like

db.define_table("mytable",
Field("reffield", "list:reference anothertable"),
)

The search widget of SQLFORM.grid("mytable", ...) does not show the reffield
.

In gloun/sqlhtml.py I have found

if fields[0]._db._adapter.dbengine == 'google:datastore':
   search_options['string'] = ['=', '!=', '<', '>', '<=', '>=']
   search_options['text'] = ['=', '!=', '<', '>', '<=', '>=']
   search_options['list:string'] = ['contains']
   search_options['list:integer'] = ['contains']
   search_options['list:reference'] = ['contains']

Therefore a list:reference field will only be recognized if the table is
stored in a google:datastore.
Is this an intended behaviour?

Regards, Martin

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] [SQLFORM.grid] fields order in view / request.args(0)

2015-11-07 Thread Mamisoa Andriantafika
[SQLFORM.grid] fields order in view / request.args(0)

Hi,

I have 2 questions relative to this controller:

def p_list():
# i = request.args(0) or 7 // not working, invalid literal base 10 on 
edit/profile
i = 7
grid = SQLFORM.grid(db.auth_membership.group_id==i,
fields = { db.auth_user.first_name, db.auth_user.
last_name, db.auth_membership.group_id},
left=db.auth_user.on(db.auth_user.id==db.
auth_membership.user_id),
user_signature=False)
return locals()



1) Using the commented line, the view is working but if I edit/profile, I 
get a ticket error with: ValueError: invalid literal for long() with base 
10: 'edit'
with or without the args. I cannot find why.

2) when I use this code, I have the group_id field that show in the middle 
column, between last and first name, and then if I edit the row and get 
back 
group_id get back in the first column ? How do I control the column order 
behaviour?

Mike

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] [SQLFORM.grid] fields order in view / request.args(0)

2015-11-07 Thread Vinicius Assef
I didn't understand your 1st question.

To solve your 2nd problem, pass the `fields` argument as a list.

--
Vinicius Assef




On 7 November 2015 at 21:53, Mamisoa Andriantafika  wrote:
> [SQLFORM.grid] fields order in view / request.args(0)
>
> Hi,
>
> I have 2 questions relative to this controller:
>
> def p_list():
> # i = request.args(0) or 7 // not working, invalid literal base 10 on
> edit/profile
> i = 7
> grid = SQLFORM.grid(db.auth_membership.group_id==i,
> fields = { db.auth_user.first_name,
> db.auth_user.last_name, db.auth_membership.group_id},
>
> left=db.auth_user.on(db.auth_user.id==db.auth_membership.user_id),
> user_signature=False)
> return locals()
>
>
>
> 1) Using the commented line, the view is working but if I edit/profile, I
> get a ticket error with: ValueError: invalid literal for long() with base
> 10: 'edit'
> with or without the args. I cannot find why.
>
> 2) when I use this code, I have the group_id field that show in the middle
> column, between last and first name, and then if I edit the row and get back
> group_id get back in the first column ? How do I control the column order
> behaviour?
>
> Mike
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] sqlform.grid

2015-10-29 Thread Laurent Lc
Hi,

i'd like a very simple example please (i begin) : 
could you tell me how to do for updating a field when i use sqlform.grid.
Example:
my db :
db.define_table('message',
   Field('firstname',requires=IS_NOT_EMPTY()),
   Field('lastname',requires=IS_NOT_EMPTY()),
   Field('team',requires=IS_NOT_EMPTY()),
   Field('mail',requires=IS_EMAIL()),
   Field('title', requires=IS_IN_SET(['Mission', 'RH', 'IT']), default='RH' 
),
   Field('your_message','text',default=VALUE),
   Field('timestamp', default=str(datetime.datetime.now(

now in my controller i return records as :
  records = 
SQLFORM.grid(db.message,user_signature=True,maxtextlength=100,orderby=~
db.message.id,deletable=False,editable=True,create=False, \
  fields=[db.message.lastname,db.message.team, 
db.message.mail]
  ) 

The goal is to edit one record and update automatically the field timestamp 
with the date of day . 

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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid: trigger edit when clicking anywhere on the row itself

2015-10-24 Thread Julian Sanchez
Is there an easy way to trigger the same URL you get when pressing the 
built-in 'edit' button of the SQLFORM.grid without having to show that 
button?  I have a few grids that would show cleaner if users could go 
directly to the edit page by clicking on the row itself (no need to view 
details).  I can do some jQuery stuff for that but I lose the '_signature' 
argument.  I could disable it but I would rather keep it for added security.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid + count

2015-10-01 Thread Bruno Oliveira


I'm trying to create a SQLFORM.grid in web2py that group 2 fields and count 
them up, but I couldn't figure it out how to do it.


*Model*

db.define_table('invocados',
Field('modulo_servico', 'string', label='Módulo (Serviço)', 
default=IS_LENGTH(2)),
Field('servico', 'string', default=IS_LENGTH(8)),
   )


*Controller*

fields=(db.invocados.modulo_servico, 
db.invocados.servico)Invocados=SQLFORM.grid(db.invocados.modulo_servico != 
db.invocados.modulo_consumidor, details=False, fields=fields, 
groupby=(db.invocados.modulo_servico | db.invocados.servico) , paginate=15)


I'm trying to count all records grouped by modulo_servico and servico. I've 
tried:

fields=(db.invocados.modulo_servico, db.invocados.servico, db.invocados.count())

but it doesn't work.


Can somebody help?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid links bug

2015-09-21 Thread zenzeromod
Hi All,

I was customizing a SQLFORM.grid startig from the code:

model:
db.define_table('aziende', 
 
Field('ragione_sociale', requires=[IS_NOT_EMPTY(
error_message=err_mess),
   IS_NOT_IN_DB(db, 
'aziende.ragione_sociale')],
  ),   
 
Field('iva_cf', requires=IS_NOT_EMPTY(error_message=err_mess
)), 
Field('indirizzo', 'string', label=('indirizzo'), requires=
IS_NOT_EMPTY(error_message=err_mess)),
Field('citta', 'string', label=T('Città'), requires=
IS_NOT_EMPTY(error_message=err_mess)),
Field('cap', 'string', label=T('C. A. P.'), requires=
IS_NOT_EMPTY(error_message=err_mess)),
Field('iscrizione', label=T('N° Albo Fornitori')), 
 
Field('descrizione', 'text', requires=IS_NOT_EMPTY(
error_message=err_mess)),
Field('logo', 'upload', label=T('Logo Aziendale'), 
autodelete=True,
  requires=[IS_NOT_EMPTY(error_message=T(err_mess)),   
 
IS_IMAGE(extensions=('jpeg', 'png'))   
 
]   

  ),   
 
Field('brochure', 'upload', label=T('brochure Aziendale'), 
autodelete=True,
  requires=[IS_NOT_EMPTY(error_message=T(err_mess)),   
 
IS_UPLOAD_FILENAME(extension='pdf') 

]   

  ),   
 
auth.signature, 

)   



controller:

def aziende(): 
 
serv = [dict(header=STRONG(XML('' * 2), XML('Galleria Foto')),   
 
 body=lambda row: (A(SPAN(_class='icon magnifier 
icon-zoom-in glyphicon glyphicon-arrow-zoom-in'),
 SPAN(XML('Aggiungi/rimuovi'), 
_class='buttontext 
button', _title='Gestisci'),
 _class='button btn btn-default', _href=
URL('gestione', 'aziende_gall', args=[row.id])),
   ))] 
 
form = SQLFORM.smartgrid(db.aziende,   
 
 create=True,   

 editable=True, 

 deletable=True,   
 
 details=True, 
 
 csv=False, 

 paginate=30,   

 showbuttontext=False, 
 
 maxtextlength=43, 
 
 links=serv,   
 
 orderby=db.aziende.ragione_sociale,   
 
 sortable=True, 

 searchable=True,   

 user_signature=False, 
 
 ) 
 
if 'edit' in request.args: 
 
response.view = 'gestione/aziende_edit.html'   
 
if 'new' in request.args:   

response.view = 'gestione/aziende_new.html' 

return dict(form=form)

view:


{{extend 'layout_gestione.html'}}   

   

Gestione Aziende   

   

  
{{=form}} 


into the "view" and into the "edit" view of the grid header  you can see 
the "the links" buttons bad rendered as shown from the image attached.

Into the file: web2py/gluon/sqlhtml.py, class SQLFORM(FORM), method 
buttons()
I changed the line (about 2234)

buttons.append(link['body'](record)) with
buttons.append(link['body'](record)[0]) and this resove my bug.


[web2py] SQLFORM.grid and ractive

2015-09-17 Thread weheh
Anybody ever try to get an SQLFORM.grid(...) to render within a ractive 
template? I'm having trouble getting it to work. SQLTABLE works OK, but 
grid seems to bundle a script, which causes ractive to choke.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid shows ids instead of names only in Linux

2015-08-21 Thread Antonio Salazar
My application shows integer ids instead of names for any table I update 
using SQLFORM.grid().
It's running a source installation on Apache2 on Linux.
The database is PostgreSQL on Windows.

Using the same application on the integrated web server in Windows shows 
the names correctly.
I'm using PostgreSQL on the same Windows server.

My databases are declared like this:

db = DAL('postgres:psycopg2://user:password@server/database', pool_size=10)
dblog = DAL('postgres:psycopg2://user:password@server/database_log', 
pool_size=10)


This is perplexing me.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid different classes for add and edit forms

2015-08-10 Thread Najtsirk
Hello,

is it possible to assign different classes for add and edit forms in 
SQLFORM.grid?

A this point there is no difference between them so I cannot use proper CSS 
selectors for JS.

Best,
Najtsirk

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid and buttons in custom update_form

2015-07-17 Thread Massimiliano
Hi,

I'm trying to customize the grid in edit mode.

Something like:

{{if 'grid' in globals():}}
{{if grid.update_form:}}
{{form = grid.update_form}}
{{=form.custom.begin}}

{{=form.custom.submit}}
{{=form.custom.end}}
{{else:}}
{{=grid}}
{{pass}}
{{pass}}

The only problem that I found is that buttons (back, view etc) are gone.

Is there a way to recreate or recover grid buttons?

thank you

-- 
Massimiliano

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Web2py SQLFORM.grid maxtextlengths etc

2015-06-12 Thread jackson . read
I can only get my  grid field the width the width I want them in  a 
SQLFORM.grid by padding the headers w/non blank chars. I have tried 
 using maxtextlengths dictionary  maxtextlength to set all. Neither seems 
to have any effect. I also removed my layout but the fields widths stayed 
the same. I am stuck and would appreciate any help anybody can give me on 
this.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] sqlform.grid maxtextlengths shoots blanks

2015-06-11 Thread jackson . read
I get the same truncated display for the log message text no matter what I 
set maxtextlengths...This app is rock+1 on the IQ simplicity scale and yet 
it does not work...BTW: I removed all layouts stuff so its not some css 
problem. The truncated fields are what the grid wants to display. Its like 
the grid is on autopilot, any suggestions???

MODEL:

db2 = DAL('sqlite://autoflowLog.sqlite')
db2.define_table('log_messages',
Field('time_stamp', length=30),
Field('log_message_text', length = 256))
db2.log_messages.id.readable = False

VIEW:

pAutoFlow Log/p
h2Log Messages:/h2
{{=form}}


CONTROLLER:

def display_log():
grid = SQLFORM.grid(db2.log_messages, editable = False, searchable = 
False,formstyle = 'divs',maxtextlengths={'log_messages.log_message_text' : 
80})
return dict(form=grid)

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] SQLFORM.grid created from request.vars - search, pagination etc breaks

2015-06-05 Thread Alex Glaros
vars passed to controller doing grid search disappear

seem that updating w2p to keep the vars after grid search would be a good 
improvement

thanks!

Alex Glaros

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] SQLFORM.grid multiple left joins and where clause

2015-05-11 Thread Johann Spies
On 10 May 2015 at 04:26, A36_Marty ma...@mccaslandcorp.com wrote:


 fields = db.auth_user.first_name, db.auth_group.role


Make that

fields = [db.auth_user.first_name, db.auth_group.role]

fields should be a list.


query = (db.auth_user)(db.auth_group.id == PARENT_GROUP_ID)  #get query
not supported error by the grid

You did have the variable 'query' defined two times. Is the second one
supposed to replace the first one.


And you did not show where you get PARENT_GROUP_ID from.

*2) How to custom-format a column based on field values?*

 In the above grid example, if an auth_group.role of Parent is returned,
 how can show something like a check mark (or any like boolean yes/no flag)
 and nothing for anything other auth_group.role values?


You can write a function to use with field.represent and use that.

Here is an example of what I have used in the past.

def get_url(url, record):
if url:
address = A('click here to see pdf', _target = _blank,
_href = some_prefix'%s' % url)
else:
address = ''
return address


And in the model:

Field(url, represent = lambda x, record:
get_url(x,record)),

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] SQLFORM.grid multiple left joins and where clause

2015-05-11 Thread A36_Marty
Thanks for your response.

I changed the fields to a list and that works fine.  Ditto for the 
field.represent feature.  Thanks!

I am still having problems getting the WHERE clause correctly inserted in 
the query.   (The 2-3 different query assignments I originally posted were 
variations I had tried with no luck.)

I would like the query string for a SQLGrid that accomplishes the same as 
the following DAL:

query = db(db.auth_group.id == PARENT_GROUP_ID).select(
db.auth_user.last_name, db.auth_user.first_name, db.auth_group.role,
left = db.auth_user.on(db.auth_user.id==db.auth_membership.user_id
  
 ).db.auth_membership.on(db.auth_membership.group_id == db.auth_group.id))

The above DAL works fine if I am simply outputting it as HTML.  However, if 
I supply it as a the query parameter to SQLFORM.grid, I get an error from 
the grid.

Ideally I would like to create a SQLFORM.grid that matches the following 
SQL:
Select auth_user.first_name, auth_user.last_name, auth_group.role FROM 
auth_user
LEFT OUTER JOIN auth_membership ON auth_user.id = auth_membership.user_id
LEFT OUTER JOIN auth_group ON auth_membership.group_id = auth_group.id
WHERE auth_group.id = 64; 
 
Any help in pointing out how to get that WHERE clause correctly supplied to 
the SQLFORM.grid is appreciated.  


On Monday, May 11, 2015 at 4:49:17 AM UTC-5, Johann Spies wrote:

 On 10 May 2015 at 04:26, A36_Marty ma...@mccaslandcorp.com javascript: 
 wrote:


 fields = db.auth_user.first_name, db.auth_group.role


 Make that 

 fields = [db.auth_user.first_name, db.auth_group.role]

 fields should be a list.


 query = (db.auth_user)(db.auth_group.id == PARENT_GROUP_ID)  #get query 
 not supported error by the grid

 You did have the variable 'query' defined two times. Is the second one 
 supposed to replace the first one.


 And you did not show where you get PARENT_GROUP_ID from.

 *2) How to custom-format a column based on field values?*

 In the above grid example, if an auth_group.role of Parent is returned, 
 how can show something like a check mark (or any like boolean yes/no flag) 
 and nothing for anything other auth_group.role values?


 You can write a function to use with field.represent and use that.

 Here is an example of what I have used in the past.

 def get_url(url, record):
 if url:
 address = A('click here to see pdf', _target = _blank,
 _href = some_prefix'%s' % url)
 else:
 address = ''
 return address


 And in the model:

 Field(url, represent = lambda x, record: 
 get_url(x,record)),

 Regards
 Johann
 -- 
 Because experiencing your loyal love is better than life itself, 
 my lips will praise you.  (Psalm 63:3)
  

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid multiple left joins and where clause

2015-05-09 Thread A36_Marty
A few novice questions while learning the SQLFORM.grid on a throw-away app. 
  My apologies for the basic questions

*1) How to show all users (auth_user) and related group roles 
(auth_group.role) only for certain auth_groups?*

I can display *all* groups with the following code, but can't seem to 
figure out how to get the WHERE clause to SQLFORM.grid.

query = db.auth_user

fields = db.auth_user.first_name, db.auth_group.role

left = db.auth_user.on(
db.auth_user.id == 
db.auth_membership.user_id).db.auth_membership.on(
db.auth_membership.group_id == db.auth_group.id)

grid = SQLFORM.grid(query = query, left=left, fields=fields)

My failed attempts to get the WHERE clause inserted:

query = (db.auth_group.id == PARENT_GROUP_ID)  #No auth_user fields shown

query = (db.auth_user)(db.auth_group.id == PARENT_GROUP_ID)  #get query 
not supported error by the grid


*2) How to custom-format a column based on field values?*

In the above grid example, if an auth_group.role of Parent is returned, 
how can show something like a check mark (or any like boolean yes/no flag) 
and nothing for anything other auth_group.role values?


Thanks in advance.   A little nudge getting me through some the syntax 
learning curve is much appreciated.


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid order of fields on create or edit form

2015-04-21 Thread Kyle Flanagan
I know you can specify the order of fields for the main view of an 
SQLFORM.grid using the optional fields parameter, however, whenever you 
choose to add a new record, the order seems to be dictated by the order in 
which the fields were created in the table definition. Is there a way to 
explicitly specify the order in which the fields are displayed on the 
create/edit form?

E.g. 

db.define_table('ATable',
Field('a', 'string'),
Field('b', 'string'),
Field('c', 'string'))

grid = SQLFORM.grid(db.ATable)


Will produce a grid that will produce a form for adding/editing a record 
with the order a, b, c. However, I need the order to be b, a, c.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid search with multiple terms

2015-03-09 Thread Ian Holser
The search function on SQLFORM grid works fine for single terms, but when 
typing multiple terms, it doesn't seem to work.

For example:
If I have a field value of 'example example1', it will find it with a 
search for 'example' or 'example1'.  A search for 'example example1' comes 
up with the whole list (no search performed)

What is causing this behavior and can it be fixed?

Thanks,
Ian Holser

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] sqlform.grid populated with an AJAX call, grid search doesn't work correctly

2015-03-04 Thread drmbded
I have a relatively simple page which has a drop down selection and an 
empty DIV. When a user selects an item from the drop down an ajax call back 
to web2py creates an sqlform.grid with a left join query and populates the 
empty DIV with the grid. This works great.

Now if I use the search capability of the grid: after filling in the search 
criteria and clicking on the Search button, the submit sends me to a page 
which just says Nothing to show.

I suspect that the grid isn't quite configured correctly to cause the 
Search/Submit to populate the DIV with the results. Or is the issue that 
the grid was created with a left join it can't reconcile the left join with 
the search criteria?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid without database IO

2015-02-23 Thread Martin Weissenboeck
There is a paragraph in the book called SQLFORM without database IO. Is
it possible to do the same with a grid?

Regards, Martin

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid check if record in db

2015-01-27 Thread Yebach
Hello

I have a SQLFORM.grid page

Values for one filed (code) in add or edit view is filed with js code from 
values of two other fields.

User can deactivate this record - it can not be deleted only status is 
set to e.g. 100

If user creates a new record that creates the same values for code field 
(two users can have the same values in code field, since it is not based on 
id) I would like to remind the user that record with this value already 
exist in the db and if he wants to activate the record and not create a new 
one.

I hope the question is clear enough

Also if creating value for field sh_code is possible with python I would 
rather use it but user has to see the values of sc_code field before db 
insert

Thank you

my controler code

def turnusi():
user = auth.user_id
org = db(db.auth_user.id == 
user).select(db.auth_user.organization)[0][organization]
 db.worker.w_user.default = user
db.worker.w_organisation.default = org
#Naredimo še grid za šifrant turnusov
db.shift.sh_organisation.default = org
 query_shifts = ((db.shift.sh_organisation == org)  (db.shift.sh_status == 
1))
query_inactive = db((db.shift.sh_organisation == org)  (db.shift.sh_status 
== 100)).select().as_list()
#print query_inactive
 fields_shifts =(
db.shift.sh_code,
db.shift.sh_name,
db.shift.sh_color,
db.shift.sh_start1,
db.shift.sh_end1,
db.shift.sh_length1,
db.shift.sh_start2,
db.shift.sh_end2,
db.shift.sh_length2,
db.shift.sh_duration1,
# db.shift.sh_start3,
# db.shift.sh_end3,
# db.shift.sh_start4,
# db.shift.sh_end4,
# db.shift.sh_start5,
# db.shift.sh_end5,
db.shift.sh_note)
 db.shift.sh_organisation.readable = False
db.shift.sh_organisation.writable = False
db.shift.sh_organisation.editable = False
 #db.shift.sh_code.editable = db.shift.sh_code.writable = False
 
#db.shift.sh_duration.writable = False
 db.shift.sh_duration1.readable = db.shift.sh_duration1.writable = False
#db.shift.sh_length1.writable = False
 #db.shift.sh_start2.readable = db.shift.sh_start2.writable = False
#db.shift.sh_start2.writable = False
 #db.shift.sh_end2.readable = db.shift.sh_end2.writable = False
#db.shift.sh_end2.writable = False
#db.shift.sh_length2.readable = db.shift.sh_length2.writable = False
 db.shift.sh_start3.readable = db.shift.sh_start3.writable = False
#db.shift.sh_start3.writable = False
 db.shift.sh_end3.readable = db.shift.sh_end3.writable = False
#db.shift.sh_end3.writable = False
db.shift.sh_length3.readable = db.shift.sh_length3.writable = False
 db.shift.sh_start4.readable = db.shift.sh_start4.writable = False
#db.shift.sh_start4.writable = False
db.shift.sh_length4.readable = db.shift.sh_length4.writable = False
 db.shift.sh_end4.readable = db.shift.sh_end4.writable = False
#db.shift.sh_end4.writable = False
 db.shift.sh_start5.readable = db.shift.sh_start5.writable = False
#db.shift.sh_start5.writable = False
 db.shift.sh_length5.readable = db.shift.sh_length5.writable = False
db.shift.sh_end5.readable = db.shift.sh_end5.writable = False
#db.shift.sh_end5.writable = False#

 db.shift.sh_code.widget = SQLFORM.widgets.string.widget
db.shift.sh_name.widget = SQLFORM.widgets.string.widget
db.shift.sh_note.widget = SQLFORM.widgets.string.widget
 grid_shifts = SQLFORM.grid(query=query_shifts, 
fields=fields_shifts,  searchable=False,create=True,
deletable=False, editable=True, paginate=25, buttons_placement = 'right',
showbuttontext = False,formname = 'shiftTable',
formargs=dict(message_onsuccess=T('New record inserted'),
message_onfailure=T('Form has errors')),
#oncreate=myfunction,
ui = dict(widget='',
  header='',
  content='',
  default='',
  cornerall='',
  cornertop='',
  cornerbottom='',
  button='button btn btn-default',
  buttontext='buttontext button',
  buttonadd='icon plus icon-plus glyphicon glyphicon-plus',
  buttonback='icon leftarrow icon-arrow-left glyphicon 
glyphicon-arrow-left',
  buttonexport='icon downarrow icon-download glyphicon 
glyphicon-download',
  buttondelete='icon trash icon-trash glyphicon glyphicon-trash',
  buttonedit='icon pen icon-pencil glyphicon glyphicon-pencil',
  buttontable='icon rightarrow icon-arrow-right glyphicon 
glyphicon-arrow-right',
  buttonview='icon magnifier icon-zoom-in glyphicon 
glyphicon-eye-open',
  buttonvidov = 'icon glyphicon glyphicon-euro' 
  ),
exportclasses  = dict(csv_with_hidden_cols=False, html = False, tsv = 
False, tsv_with_hidden_cols=False, json = False))
# for input in grid_shifts.elements('input', _class='string'):
# input['_class'] = 'testniKlass'
 if request.args and request.args[0] in ['edit', 'new']:
 #dolocamo sirino polj
grid_shifts.element('input[name=sh_color]')['_style']='width:30%'
grid_shifts.element('[title=Back]').parent['_href'] = 
URL('settings','turnusi')
 return dict(grid_shifts=grid_shifts,query_inactive=query_inactive)



my js code in view to get 

[web2py] Re: web2py sqlform.grid join problem

2015-01-04 Thread Tim Richardson
Do you know how to use web2py's DAL to make a query which joins tables? 

http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Inner-joins

Once you do, give that query to SQLFORM.grid 
Note that you need to understand what exactly a DAL query is. The term is 
subtly different from what you may expect if you are thinking of SQL 
queries. 
A DAL query on its own does not return rows: a DAL query defines what is to 
be selected (such as what the join is) but on its own is simply an 
expression, not a set of data.

I found this a little confusing at the beginning: 'query' is a DAL formal 
term which does not by itself include returned data. The DAL uses the term 
set when the query is put in the context of a database. 
http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Query--Set--Rows

The grid needs only a DAL query, not a set of rows.

http://www.web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-grid
The first argument of SQLFORM.grid can be a table or a query. The grid 
object will provide access to records matching the query.



On Sunday, 4 January 2015 06:12:41 UTC+11, Roman Rakus wrote:

 Hi, I have folloving tables.
 db.define_table('tbl1', Field('code', 'string'))
 db.define_table('tbl2', Field('field1', 'integer', 'reference tbl1'), 
 Field('field2', 'integer', 'reference tbl1'))

 Now I need render values from tbl2 in sqlform.grid. How I can join 
 tbl2.field1 and tbl2.field2 on tbl1?


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] web2py sqlform.grid join problem

2015-01-03 Thread Roman Rakus
Hi, I have folloving tables.
db.define_table('tbl1', Field('code', 'string'))
db.define_table('tbl2', Field('field1', 'integer', 'reference tbl1'), 
Field('field2', 'integer', 'reference tbl1'))

Now I need render values from tbl2 in sqlform.grid. How I can join 
tbl2.field1 and tbl2.field2 on tbl1?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] sqlform.grid with double join

2015-01-03 Thread Roman Rakus
Hi, I have folloving tables.
db.define_table('tbl1', Field('code', 'string'))
db.define_table('tbl2', Field('field1', 'integer', 'reference tbl1'), 
Field('field2', 'integer', 'reference tbl1'))

Now I need render values from tbl2 in sqlform.grid. How I can join 
tbl2.field1 and tbl2.field2 on tbl1 table?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid stylize

2014-12-04 Thread Yebach
Hello

What is the best way to stylize my SQLFORM.grid form

E.g.: my dropdown field is smaller the others also the edit form is as wide 
as the page I would like to reduce the size, etc.

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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid extra button

2014-12-02 Thread Yebach
Hello

I have a SQLFORM.grid and beside the default buttons  (edit,view, 
delete,...) I would like to add a new one to change a status in my database 
table.

Any suggestions?

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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid field is not empty if another field is full

2014-12-01 Thread Yebach
Hello

I have a SQLFORM.grid and I have to raise error for user if he inserts 
value into one field and not another. 

Example

start 1 10:00
end 1  12:00 - has to show error if field is empty - 

start 2 16:00 - not necessary to be inserted
end 2 20:00 - has to show error if start 2 is not empty

What would be the best solution?

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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] SQLFORM.grid custom search where is the error?

2014-11-18 Thread Prasad Muley

This problem still exist in web2py 2.9.6.

I've tried to use custom grid search But It is showing me invalid query 
near grid.


On Thursday, February 21, 2013 10:09:33 PM UTC+5:30, Mandar Vaze wrote:

 I'm using Version 2.3.2 (2012-12-17 15:03:30) stable and the problem 
 still persists. i.e. I'm still getting Invalid Query error.

 I'm using Alex's workaround which seems to be working. Thanks Alex.

 -Mandar

 On Friday, September 28, 2012 6:07:13 PM UTC+5:30, Massimo Di Pierro wrote:

 Clearly something is wrong I will try this today. Before I do, could you 
 check the latest trunk?

 On Friday, 28 September 2012 04:36:26 UTC-5, alex wrote:

 Thank you Johann, of course I did already,

 The query itself gets translated correctly. 
 I think that something very subtle is happening when I pass 
 search_widget=search_form, and I cannot catch it

 I uploaded here 
 https://www.dropbox.com/s/d5t13fejdqlr7r4/web2py.app.test.w2p the 
 packed version maybe it is easier to understand what happens.
 Thank you anyway.
 Alex


 On Friday, September 28, 2012 3:45:25 PM UTC+9, Johann Spies wrote:

 On 28 September 2012 07:15, alex a22...@gmail.com wrote:


 What am I doing wrong?


 A good way to learn this query syntax is to build the query from the 
 dropdownbox which you get when you click in the search box.   

 Regards
 Johann

 -- 
 Because experiencing your loyal love is better than life itself, 
 my lips will praise you.  (Psalm 63:3)



-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid edit only selects the first record and updates all records.

2014-11-18 Thread Stephen McCamy
Hello,

I am having an issue with SQLFORM.grid where when there are more than one 
records returned the edit button only shows data for the first record.  If 
I do update it then updates all the records with the new values.  I can't 
seem to figure out why.

Here is my db definition:

db.define_table('Correlation',Field('IncidentID','id',label='Event 
ID'),Field('Type',represent=lambda r, row: 
db.CorrelationType[r].CorrelationType),Field('Value'),Field('Context',represent=lambda
 
r, row:A('View',_href=(r),_target='new') if row.Type==4 else r))
db.define_table('CorrelationType',Field('P_Id','id'),Field('CorrelationType'))

Here is the SQLFORM.grid:

corq=db.Correlation.id==(request.args(0))

cor=SQLFORM.grid(query=corq,fields=[db.Correlation.Type,db.Correlation.Value,db.Correlation.Context],links=urllinks,searchable=True,maxtextlength=100,details=True,
 
editable=True,deletable=False,user_signature=False,create=True,links_in_grid=True,args=[request.args[0]],csv=True,exportclasses=dict(
csv_with_hidden_cols=False,
xml=False,
html=False,
json=False,
tsv_with_hidden_cols=False,
tsv=False))

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid want no initial values

2014-11-03 Thread Wayne Tooley
Hi Everyone;
I'm new to web2py and love it. I have a simple question that I can't seem 
to find a simple answer to. 
I want to use SQLFORM.gid but not to load any values unless searched for. 
Maybe I'm using the wrong thing but is there a simple way to do this?

my code is this:

def search_person():
db.person.id.readable = False
query = (db.tenant)
fields = (db.person.name)
headers = {'db.person.name': 'Name'}
grid =False #does not work
form = SQLFORM.grid(query = query, headers = headers, create=False, 
deletable=False, editable=False, maxtextlength=64, paginate=4)
 return dict(form=form)

any help or examples would be appreciated.

Regards,

Wayne

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] SQLFORM.grid created from request.vars - search, pagination etc breaks

2014-10-27 Thread Mandar Vaze
Current code looks like this : 
https://github.com/web2py/web2py/blob/master/gluon/sqlhtml.py#L2031
See if it helps

-Mandar

P.S. : I posted original query (2 yrs ago) but as mentioned earlier in the 
thread - I ended up using session variable though.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] SQLFORM.grid created from request.vars - search, pagination etc breaks

2014-10-27 Thread Alen Cerovic
Hi Mandar,

as you pointed me to source it seems there is still just args parameter.

I tried with session.vars but somehow I was loosing those vars and it just 
did not feel right to me.

I ended up switching to args and pass those request.args to grid as args 
parameter.
It works now but I like it more with vars because it is easily readable

thnx
Alen

Dana ponedjeljak, 27. listopada 2014. 11:00:15 UTC+1, korisnik Mandar Vaze 
napisao je:

 Current code looks like this : 
 https://github.com/web2py/web2py/blob/master/gluon/sqlhtml.py#L2031
 See if it helps

 -Mandar

 P.S. : I posted original query (2 yrs ago) but as mentioned earlier in the 
 thread - I ended up using session variable though.


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid search: how to show only a subset of available search fields?

2014-10-26 Thread Jack Kuan
Answering my own question: my solution is to massage the returned grid object, 
removing duplicate options and other unwanted html elements.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] SQLFORM.grid created from request.vars - search, pagination etc breaks

2014-10-25 Thread Alen Cerovic
two years later I am struggling with same problem, is grid vars parameter 
now included in web2py?

Dana srijeda, 24. listopada 2012. 11:56:21 UTC+2, korisnik Niphlod napisao 
je:

 isn't this a little silly ? we have an args parameter to the grid but not 
 a vars one

 Could you try to test a little mod to the source. 

 - open gluon/sqlhtml.py and scroll until def grid(
 - add a vars={} default parameter
 - a few line below, there's def url(**b)
 - change with this
 
 def url(**b):
 b['args'] = args + b.get('args', [])
 vars.update(b.get('vars', {}))
 b['vars'] = vars
 b['hash_vars'] = False
 b['user_signature'] = user_signature
 return URL(**b)


 Create a grid with
 grid = SQLFORM.grid(table, vars=dict(mycustomvar='mycustomvalue'))

 In theory, the 'mycustomvar' parameter should be passed along with 
 navigation into the grid without causing problems.

 Disclaimer: use customized vars, not the ones the grid uses (like order, 
 keywords, search,page, etcetc). Should be safe though, in case of collision 
 the grid wins over the vars you passed on instantiation.

 On Wednesday, October 24, 2012 8:40:57 AM UTC+2, lyn2py wrote:

 When/where should I clean these variables from session ?
 In case user directly accesses second URL (without going thru first URL 
 to select the search criteria) they might see incorrect results - since 
 controller function will use old values 


 I suggest to ensure that URLs must be followed. Not possible to clear the 
 session vars especially if search result has more than one page. Use 
 user_signature=True for your SQLFORM.grid 



-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid search: how to show only a subset of available search fields?

2014-10-22 Thread Jack Kuan
Hi,

I'm using left=[...] when creating a searchable SQLFORM.grid. 
My problem is that the drop-down menu for choosing which fields to build 
the search query contains ALL the fields in the search result.
Is there a way to limit it to only a subset of the fields like what the 
'fields' argument of SQLFORM.grid() does for restricting the grid columns 
shown?

Thanks

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid in LOAD() search error

2014-09-10 Thread Ariya Owam-aram
Dear all,

There is an error when use SQLFORM.grid in LOAD function.
This are steps to reproduce the problem?

*Step 0*
# in models/db.py
db.define_table('product',
Field('code', length = '50', notnull = True, unique = True),
Field('name',  notnull = True),
)

*Step 1*
#in controller/default.py
def test_sqlform():
return dict()

def sqlform_grid():
sqlform_grid=SQLFORM.grid(db.product)
return dict(sqlform_grid=sqlform_grid)

# in view = /views/default/ test_sqlform.html
{{extend 'layout.html'}}
{{=LOAD('default', 'sqlform_grid', ajax=True)}}

*Step 2*
2.0 open = 127.0.0.1/welcome/test_sqlform
2.1 try to search some product let say = 'glass' 
2.2 go to 2nd page and search again = 'dish'
2.3 in the search box you will see ['glass', 'dish']

2.4 clear and search again does not help
2.5 just press button search you will see ['glass', ['glass', 'dish'[] 
(something like this)

I using web2py version is 2.9.5 - 2.8.9

Any recommend, what I do wrong? 
Thank you in advance.

Ariya

https://lh4.googleusercontent.com/-fyCI57DuZbo/VA_PBpE-gPI/ALM/HhCVFSY4cj8/s1600/Screen%2BShot%2B2557-09-10%2Bat%2B11.09.07%2BAM.png

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] sqlform.grid default search value

2014-09-04 Thread Douglas Campbell
Is it possible to have a default search value in an sqlform.grid? I do not 
see the option in the docs and have not figured out a work around.

What I truly want to do is have the page JUST load the search bar and not 
the database results. Then once a search term is entered it shows the 
results in the sqlform.grid. I was going to just have a default search 
value when the page loads like Enter_your_search_term_here that would 
return no results from the database.

Thanks, 


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid links and inner join

2014-08-28 Thread Louis Amon

I have a simple one-to-many relation like so:

db.define_table('person', Field('job'))
db.define_table('thing', Field('owner_id', 'reference person'))

And I built a grid using SQLFORM.grid like so:
grid = SQLFORM.grid((db.person.id == db.thing.owner_id),
fields=[db.thing.owner_id, db.person.job],
links=[dict(header='Details for thing',
body=thing_link)
  ],
)

With the function thing_link defined like this:
def thing_link(row):
print row
return A('controller', 'function', args=[row.thing.uuid])


I get a ticket when loading the grid, and as far as I can tell looking at 
the print in thing_link, the row passed in the body of the link does not 
contain both tables of the inner join : it only contains whichever comes 
first (so row.person in this case, in terms or alphabetical order).

Is there a way around this ?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] sqlform.grid edit view back button

2014-08-19 Thread Yebach
Hello

I have to create multiple sqlform.grids in my page

i used bootstrap tabs to load different htmls with different controller 
functions (each for every grid)

It works ok and does the trick except when I edit record I and click the 
back button the link is not back to the page it was so I cannot see tabs 
anymore

My main html has address http://127.0.0.1:8080/iRazpored/settings/sifranti
but after clicking my back button I am send 
to http://127.0.0.1:8080/iRazpored/settings/turnusi 

I hope I am clear enough.
Also when I am on edit view tabs are not shown since the url 
is http://127.0.0.1:8080/iRazpored/settings/turnusi/edit/shifts
Is is possible to set the back button address or is there any other way 
around it?

Thank you

this is my html

my main view

{{ extend 'layout.html' }}
{{include 'web2py_ajax.html'}}
script
$(document).ready(function() {
$('#worker_w_note').width(200).height(75);
//glyphicon glyphicon-edit
$('#workers').load('workers.html');
$('#turnusi').load('turnusi.html');
});
/script

style
.affix {
top: 60px;
}
.input-group {
width: 100%;
}
.row {
margin-bottom: 10px;
}
.sectionHeader {
margin-bottom: 0;
}
/style

div class=tabbable style=margin-bottom: 18px;
  ul class=nav nav-tabs
li class=activea href=#workers 
data-toggle=tabZaposleni/a/li
li class=a href=#turnusi 
data-toggle=tabTurnusi/a/li
  /ul
div class=col-md-12
  div class=tab-content style=padding-bottom: 9px; 
border-bottom: 1px solid #ddd;
div class=tab-pane active id=workers
/div
div class=tab-pane id=turnusi
/div
  /div
/div
/div​



And the two htmls for my sqlform.grid

{{extend 'layout.html'}}
{{include 'web2py_ajax.html'}}
style
.affix {
top: 60px;
}
.input-group {
width: 100%;
}
.row {
margin-bottom: 10px;
}
.sectionHeader {
margin-bottom: 0;
}
/style
body
div class=col-md-12
{{=grid_shifts}}

/div
/body


{{extend 'layout.html'}}
{{'web2py_ajax.html'}}

script
/script

style
.affix {
top: 60px;
}
.input-group {
width: 100%;
}
.row {
margin-bottom: 10px;
}
.sectionHeader {
margin-bottom: 0;
}
/style
body
div class=col-md-12
{{=grid_workers}}

/div
/body

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] SQLFORM.grid: sorting

2014-07-18 Thread Jacinto Parga
Hi, 

I solved it putting the foreing key format in the controller, before the 
grid:

def familia_manage():
*db.auth_user._format = '%(last_name)s %(first_name)s'*
fields=[db.t_familiares.f_nombre, 
db.t_familiares.f_apellidos,db.t_familiares.f_titular]
form = SQLFORM.grid(db.t_familiares, fields=fields )
return locals()

Where, in the table declaration:

db.t_familiares.f_titular.requires= 
(IS_IN_DB(db,'auth_user.id','%(last_name)s ''%(first_name)s'))

When I press the header I get it order by last_name instead of id.


El lunes, 21 de mayo de 2012 22:24:23 UTC+2, backseat escribió:

 Thanks Jim, I somehow missed the 'orderby' parameter to SQLFORM.grid 

 On Mon, 21 May 2012 13:11:31 -0700 (PDT), massimo@gmail.com 
 javascript: said: 

  foreign key. You can do a join. 

 Thanks Massimo; however, that's a little cryptic. Could you explain how a 
 join can be used to determine the sort order when I click on a 
 SQLFORM.grid header? 

 Thanks, 
 Keith 
 -- 
 You can have everything in life you want if you help enough other people 
 get what they want - Zig Ziglar. 

 Who did you help today? 


-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] SQLFORM.grid: sorting

2014-07-18 Thread Massimo Di Pierro
You cannot a have an inner join in smartgrid. That's the biggest difference 
in this case. You can have orderby.





On Monday, 21 May 2012 15:47:53 UTC-5, Jim S wrote:

  Massimo - Is there a way to do it with a .smartgrid.  I know the question 
 wasn't on .smartgrid, but I'm using that extensively and too would like 
 some sort of solution.

 -Jim

 On 5/21/2012 3:11 PM, Massimo Di Pierro wrote: 

 foreign key. You can do a join.

 On Monday, 21 May 2012 14:49:06 UTC-5, Jim S wrote: 

 You can specify the sort order using the orderby parameter.  But, I 
 don't know how you get it to sort by the displayed value of a foreign 
 key column. 

 Ex: 

 orderby = [~db.asset.acquiredOn, db.asset.assetTag, db.asset.description] 

 ~ orders descending. 

  -Jim 

 On 5/21/2012 2:23 PM, Keith Edmunds wrote: 
  Two questions re SQLFORM.grid sorting. 
  
  1. Is it possible to specify the initial sort order? 
  
  2. I'm displaying a table that includes a foreign field. When I click 
 on 
  the header to sort by that field, it sorts by the field id rather than 
 by 
  the (displayed) foreign field. Can I sort by the displayed field? 
  
  Thanks, 
  Keith 

  

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLform.Grid problems with lookout and url

2014-07-14 Thread Yebach
If anyone can hellp me with this

I have a page with embeded htmls. One of them should have a SQLForm.grid to 
manage table of workers

I am having difficulties because SQLForm.grid is in edit function. Besides 
the fact that it looks awful it also does not work properly 

I asked a question on stackoverflow so here is a link together with python 
code for controller

http://stackoverflow.com/questions/24648604/web2py-sqlform-grid-url


any suggestions

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid detect_record_change

2014-07-09 Thread Otto Domínguez
Is it possible to use detect_record_change while submitting an edit with 
SQLFORM.grid. I'm talking the remotely possible but still possible case 
where two users choose to edit the same record simultaneously. Just the 
first one to submit her/his change should be successful. The second one 
should fail because the record has changed between record retrieval to 
populate edit form and the submission of changes. The Book gives code 
snippet to use SQLFORM (not .grid) but I do not know how to put a flash 
message where it says # do something HERE FROM INSIDE A SQLFORM.grid? 
because this code is managed by SQLFORM.grid, not by me as the case the 
Book shows.

def edit_dog():
dog = db.dog(request.args(0)) or redirect(URL('error'))
form=SQLFORM(db.dog,dog)
form.process(detect_record_change=True)
if form.record_changed:
# do something HERE FROM INSIDE A SQLFORM.grid?
elif form.accepted:
# do something else
else:
# do nothing
return dict(form=form)


-- 
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.
For more options, visit https://groups.google.com/d/optout.


  1   2   3   4   >