[web2py] Re: multiple conditional fields

2018-06-09 Thread 黄祥
perhaps you can use show_if for conditional field or jquery()
ref:
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Conditional-fields
http://web2py.com/books/default/chapter/29/11/jquery-and-ajax#Conditional-fields-in-forms

best regards,
stifan

-- 
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: trigger implementation

2018-06-09 Thread 黄祥
perhaps you can use callback (before_update or after_update)
ref:
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#callbacks-on-record-insert--delete-and-update

best regards,
stifan

-- 
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] trigger implementation

2018-06-09 Thread Diego Tostes
Hi,

is there a way to implement a trigger on web2py?

i need a way to persist informations in a table every time a specific
column in a specific table changes the value.

rgsd

Diego

-- 
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: Menu links with target attribute

2018-06-09 Thread Rakesh Singh
I have tried to find the cause of this issue, and believe it occurs due to 
the fact that A is a subclass of DIV.
The ```isinstance(link, DIV)``` test then evaluates to True when ```link``` 
is an object of type A.
I could not find an option to change the behaviour of ```isinstance()``` 
and resorted to changing the following lines in html.py


diff --git a/gluon/html.py b/gluon/html.py
index 4adf287c..180f39a4 100644
--- a/gluon/html.py
+++ b/gluon/html.py
@@ -2526,14 +2526,16 @@ class MENU(DIV):
 ul.append(item)
 else:
 (name, active, link) = item[:3]
-if isinstance(link, DIV):
+if isinstance(link, DIV) and not isinstance(link, A):
 li = LI(link)
 elif 'no_link_url' in self.attributes and 
self['no_link_url'] == link:
 li = LI(DIV(name))
 elif isinstance(link, dict):
 li = LI(A(name, **link))
-elif link:
+elif link and not isinstance(link, A):
 li = LI(A(name, _href=link))
+elif link and isinstance(link, A):
+li = LI(name, link)
 elif not link and isinstance(name, A):
 li = LI(name)
 else:
(END)






On Thursday, 7 June 2018 11:55:05 UTC+2, Rakesh Singh wrote:
>
> Hello,
>
> I have been trying to add external links to the menu system, but they 
> result in malformed or invalid URL's when setting the target attribute.
> There are some old posts in the group regarding this, but none of the 
> suggestions have worked.
>
> Web2py version : 2.16.1-stable
>
> Example:
> response.menu += [
> ('External Links', False, '#', [
> ('Icinga', False, URL('icinga'), []),
> # Works
> # SRC:  href="/Rakesh_Singh/default/icinga">Icinga
> ('Google', False, google, []),
> # Works
> # SRC: https://www.google.com
> ">Google
>
> # Change target...
> ('', False, A('Icinga', _href=URL('icinga'), _target="_blank"), 
> []),
> # Does not work; Menu item displays "Icinga\n>"
> # SRC: Icinga">  
>   
> ]
> )
> ]
>
>
> I have added a 'dirty' workaround in my layout.html that changes the 
> target to '_blank' if the URL contains the string 'http'
>
> 
>   {{for _subitem in _item[3]:}}
>   {{if _subitem[2].__contains__('http'):}}
> {{_target = '_blank'}}
> {{_rel = 'noopener'}}
>   {{else:}}
> {{_target = '_self'}}
> {{_rel = 'preconnect '}}
>   {{pass}}
>target="{{=_target}}" rel="{{=_rel}}">{{=_subitem[0]}}
>
>
> Is there something incorrect in my code when specifying the target?
>
> 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] multiple conditional fields

2018-06-09 Thread Andrea Fae'
I have this table

db.define_table('evento',
Field('titolo', requires=[IS_NOT_EMPTY()]),
Field('verifica', type='boolean', default=False),
Field('inizio', type='datetime', 
requires=IS_DATETIME(format=T('%d/%m/%Y %H:%M'),error_message='deve essere 
DD/MM/ HH:MM!')),
Field('fine', type='datetime', 
requires=IS_DATETIME(format=T('%d/%m/%Y %H:%M'),error_message='deve essere 
DD/MM/ HH:MM!')),
Field('uniqueid', type='string'),
Field('ricorrenza', requires = IS_IN_SET(['0', '1', '2', 
'3', '4', '5', '6', '7', '8', '9', '10'], error_message='deve essere un 
numero da 0 a 10'), default= '0'),
Field.Virtual('giorno_inizio', lambda 
row:calendar.day_name[row.evento.inizio.weekday()]),
Field('risorsa', 'reference risorsa'),
Field('docente', 'reference auth_user'),
Field('materia', 'reference materia'),
Field('studenti', 'list:reference auth_user'),
Field('colore', default = '#8080ff'),
Field('controllato', type='boolean', default=False),
Field('note'),

auth.signature,singular="Evento",plural="Eventi",migrate='evento.table',
format='%(titolo)s')
db.evento.giorno_inizio.represent = lambda giorno_inizio, row: 
T(giorno_inizio)

When I create the form I need these requirements to these fields:


db.evento.docente.requires=IS_IN_DB(db(query_docente),'auth_user.id','%(last_name)s'
 
' ' '%(first_name)s', zero=T('Scegli il docente/referente...'))

and 

db.evento.docente.widget = wdg_select
db.evento.materia.widget = wdg_select_change

the field "materia" depends on the field "docente" and it's filled with a 
script like:

   url_materia = URL("dropdown.html")
script = SCRIPT("""
  var url_materia = "%s";
  $('#evento_docente').on('change',function(e){
 var v = $(this).val();
 //alert('Docente cambiato: ' + v);
 $.web2py.component(url_materia + '?docente=' + v, 
'evento_materia','no','no',$('#evento_materia'));
 })
""" % url_materia)
 
To  explain better "docente" is the teacher, and "materia" is the subject. 
Every docente has 1 or subject (materia) to teach so when I choose a 
"docente" the other field has to be filled only with the subjects teached 
by this teacher


If the field "verifica" is true, I'd like to hidden the fields (BOTH) 
"docente" and "materia" and, so, I don't want the requirements. about these 
fields...
With a conditional field I can hidden only the "docente" field but if it's 
hidden...after submit the form told me that is not correctly filled like 
required.

I cannot hidden both field and not consider the requirements if the fields 
will be hidden..

Is it possible? Any suggestion?
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] Re: Classes: Iteration of Row Objects & Updating

2018-06-09 Thread Mark Billion
Anthony -- I havent met you, but I certainly owe you a beer.  Thank you for
all of your help.

On Fri, Jun 8, 2018 at 10:47 PM, Anthony  wrote:

> On Friday, June 8, 2018 at 5:49:07 PM UTC-4, Mark Billion wrote:
>>
>> Ive checked the docs and am sure I am missing it, but can someone please
>> confirm or deny: If I iterate a row class attribute via another class
>> method, updates applied by that method will will update the underlying row
>> attribute?
>>
>> For example:
>>
>> __init__:
>>  self.dbobj = db(db.foo.bar>0).select()
>>
>> def abc:
>>  for x in self.dbobj:
>>  x.attribute = "a"
>>
>> My question is whether the self.dbobj attribute characteristic is now set
>> to "a" for all records until the object is either destroyed or reupdated.
>>
>
> Yes.
>
> --
> 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/RpxqxmK4bCU/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.
>



-- 
Mark M. Billion
1904 N. Lincoln
Wilmington, DE 19806
302.416.2199

-- 
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.