[web2py] Re: calculating sums of a table field when the values are inherited from another table

2022-04-11 Thread mostwanted
Thank you Jim, works

On Monday, April 11, 2022 at 2:07:06 PM UTC+2 Jim S wrote:

> How about this?
>
> *{{total = 0}}*
>
>
> *{{for c in children:}}*
>
>
>
>
> *{{=c.parent.full_names}}{{=c.childs_names}}
> {{=c.policy_cover.policy_name}}
> {{=c.policy_cover.premium}}*
>
>
> *{{total +=c.policy_cover.premium}}{{pass}}*
> **
> **
> *TOTAL PREMIUM: {{=total}}*
> **
> **
>
>
> On Monday, April 11, 2022 at 4:56:37 AM UTC-5 mostwanted wrote:
>
>> I have a problem that i'm failing to fix, i want to calculate the sum of 
>> all premiums for all tables in a client's account. A client is paying  
>> insurance for his kids & his parents, i want to display this information in 
>> the view in an html table and be able to calculate his total premium for 
>> both his kids and his parents, the problem is when i try to add them up it 
>> picks up only 1 value from the children's table which is the value last 
>> entered and 1 value in the parents table.
>>
>> When i try *sum_values=db.children.policy_cover.premium.sum() *i get an 
>> error that:
>> * 'Field' object has no attribute 'premium'*
>>
>> *TABLES*
>>
>>
>>
>>
>>
>>
>>
>> *db.define_table('children_policy',Field('policy_name'),  
>>   Field('premium', 'double'),
>> format='%(policy_name)s')db.define_table('client',
>> Field('full_names'),format='%(full_names)s')*
>>
>>
>>
>>
>>
>> *db.define_table('children',Field('parent', 'reference 
>> client'),Field('childs_names'),
>> Field('policy_cover', 'reference children_policy')*
>>
>> *CONTROLLERS*
>>
>>
>>
>>
>> *def index():clients=db(db.client).select()
>> children=db(db.children).select(db.children.ALL)
>> parent=db(db.parent).select(db.parent.ALL)return locals()*
>>
>>
>> *VIEW*
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *POLICY OWNERCHILDPOLICY
>> PREMIUM{{for c in children:}}
>> {{=c.parent.full_names}}{{=c.childs_names}}
>> {{=c.policy_cover.policy_name}}
>> {{=c.policy_cover.premium}}
>> {{total=sum(c.policy_cover.premium)}}{{pass}}{{pass}}  
>>   TOTAL PREMIUM:{{=total}}{{pass}}*
>>
>

-- 
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/abfe61bb-df5c-41fb-a64e-72631545fc81n%40googlegroups.com.


[web2py] Re: calculating sums of a table field when the values are inherited from another table

2022-04-11 Thread Jim S
How about this?

*{{total = 0}}*








*{{for c in children:}}{{=c.parent.full_names}}
{{=c.childs_names}}{{=c.policy_cover.policy_name}}
{{=c.policy_cover.premium}}{{total 
+=c.policy_cover.premium}}{{pass}}*
**
**
*TOTAL PREMIUM: {{=total}}*
**
**


On Monday, April 11, 2022 at 4:56:37 AM UTC-5 mostwanted wrote:

> I have a problem that i'm failing to fix, i want to calculate the sum of 
> all premiums for all tables in a client's account. A client is paying  
> insurance for his kids & his parents, i want to display this information in 
> the view in an html table and be able to calculate his total premium for 
> both his kids and his parents, the problem is when i try to add them up it 
> picks up only 1 value from the children's table which is the value last 
> entered and 1 value in the parents table.
>
> When i try *sum_values=db.children.policy_cover.premium.sum() *i get an 
> error that:
> * 'Field' object has no attribute 'premium'*
>
> *TABLES*
>
>
>
>
>
>
>
> *db.define_table('children_policy',Field('policy_name'),  
>   Field('premium', 'double'),
> format='%(policy_name)s')db.define_table('client',
> Field('full_names'),format='%(full_names)s')*
>
>
>
>
>
> *db.define_table('children',Field('parent', 'reference 
> client'),Field('childs_names'),
> Field('policy_cover', 'reference children_policy')*
>
> *CONTROLLERS*
>
>
>
>
> *def index():clients=db(db.client).select()
> children=db(db.children).select(db.children.ALL)
> parent=db(db.parent).select(db.parent.ALL)return locals()*
>
>
> *VIEW*
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *POLICY OWNERCHILDPOLICY
> PREMIUM{{for c in children:}}
> {{=c.parent.full_names}}{{=c.childs_names}}
> {{=c.policy_cover.policy_name}}
> {{=c.policy_cover.premium}}
> {{total=sum(c.policy_cover.premium)}}{{pass}}{{pass}}  
>   TOTAL PREMIUM:{{=total}}{{pass}}*
>

-- 
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/3f2edd34-5aeb-4a0b-b4f9-938bd34306ddn%40googlegroups.com.


[web2py] calculating sums of a table field when the values are inherited from another table

2022-04-11 Thread mostwanted
I have a problem that i'm failing to fix, i want to calculate the sum of 
all premiums for all tables in a client's account. A client is paying  
insurance for his kids & his parents, i want to display this information in 
the view in an html table and be able to calculate his total premium for 
both his kids and his parents, the problem is when i try to add them up it 
picks up only 1 value from the children's table which is the value last 
entered and 1 value in the parents table.

When i try *sum_values=db.children.policy_cover.premium.sum() *i get an 
error that:
* 'Field' object has no attribute 'premium'*

*TABLES*







*db.define_table('children_policy',Field('policy_name'),
Field('premium', 'double'),
format='%(policy_name)s')db.define_table('client',
Field('full_names'),format='%(full_names)s')*





*db.define_table('children',Field('parent', 'reference 
client'),Field('childs_names'),
Field('policy_cover', 'reference children_policy')*

*CONTROLLERS*




*def index():clients=db(db.client).select()
children=db(db.children).select(db.children.ALL)
parent=db(db.parent).select(db.parent.ALL)return locals()*


*VIEW*


















*POLICY OWNERCHILDPOLICY
PREMIUM{{for c in children:}}
{{=c.parent.full_names}}{{=c.childs_names}}
{{=c.policy_cover.policy_name}}
{{=c.policy_cover.premium}}
{{total=sum(c.policy_cover.premium)}}{{pass}}{{pass}}  
  TOTAL PREMIUM:{{=total}}{{pass}}*

-- 
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/23dce829-6096-4e43-b883-0f200da2571dn%40googlegroups.com.


[web2py] Re: Best way to have form submit disabled until file selected

2022-04-11 Thread Dave S
On Sunday, April 10, 2022 at 3:10:27 PM UTC-7 Ramos wrote:

> Hello i have a form with a file to upload.
> What is the best web2py way to have the submit button disabled until the 
> user selects a file  to upload?
> Regards
> António
>

I'd say javascript, since the "required" validator only works after the 
form is submitted.

/dps
 

-- 
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/c408410a-efe6-4468-9153-1943e6644935n%40googlegroups.com.