[web2py] Custom validator broken in 2.18.4, working in 2.17.2

2019-04-04 Thread David Manns
The table in question has a field:

Field('Paiddate', 'date', requires = [IS_EMPTY_OR(IS_DATE()), 
IS_EMPTY_OR(IS_MEMBERSHIP_YEAR_END())]),

The custom validator is:

class IS_MEMBERSHIP_YEAR_END(object):
def __init__(self, error_message='Not a membership year end'):
self.error_message = error_message
def __call__(self, value):
yearend = datetime.date(2018,9,30)
if value.month==yearend.month and value.day==yearend.day:
return (value, None)
return (value, self.error_message)

This works in 2.17.2

I updated my test environment to 2.18.4 and it fails.

On the console I see:

web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2019
Version 2.18.4-stable+timestamp.2019.03.13.05.27.54
Database drivers available: sqlite3, imaplib, pyodbc, pymysql
please visit:
('\t', 'http://127.0.0.1:8000/')
starting browser...
Traceback (most recent call last):
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.1\gluon\html.py", line 1890, in _validate
(value, errors) = validator(value)
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.1\gluon\packages\dal\pydal\validators.py", line 144, in 
__call__
return self.validate(value), None
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.1\gluon\packages\dal\pydal\validators.py", line 2754, in 
validate
return self.other.validate(value)
AttributeError: 'IS_MEMBERSHIP_YEAR_END' object has no attribute 'validate'

The ticket shows:

Error ticket for "init" Ticket ID 

127.0.0.1.2019-04-04.16-41-08.0dce185d-d8d2-4d36-9e47-8c82bc1d54f5
 Validation error, field:Paiddate 
 Version 
web2py™ Version 2.18.4-stable+timestamp.2019.03.13.05.27.54 
Python Python 2.7.14: C:\Python27\python.exe (prefix: C:\Python27) Traceback 

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

Traceback (most recent call last):
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.1\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.1\applications\init\controllers/default.py", line 1747, in 

  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.1\gluon\globals.py", line 421, in 
self._caller = lambda f: f()
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.1\applications\init\models\db.py", line 109, in wrapped_f
return f(*args)
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.1\applications\init\controllers/default.py", line 214, in 
memberform
deletable = dltbl, onvalidation=setmodified, onaccept=modmember, 
ondelete=delmember)
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.1\gluon\tools.py", line 4322, in update
detect_record_change=self.settings.detect_record_change):
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.1\gluon\sqlhtml.py", line 1758, in accepts
**kwargs
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.1\gluon\html.py", line 2149, in accepts
status = self._traverse(status, hideerror)
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
newstatus = c._traverse(status, hideerror) and newstatus
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
newstatus = c._traverse(status, hideerror) and newstatus
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
newstatus = c._traverse(status, hideerror) and newstatus
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.1\gluon\html.py", line 910, in _traverse
newstatus = c._traverse(status, hideerror) and newstatus
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.1\gluon\html.py", line 917, in _traverse
newstatus = self._validate()
  File "C:\Users\David\Google Drive\Oxcamne Archive\Web 
Site\OxCamNE.2.1\gluon\html.py", line 1895, in _validate
raise Exception(msg)
Exception: Validation error, field:Paiddate 

-- 
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: New International Telegram Support Group

2019-04-04 Thread Ari Lion BR Sp
Hey, Carlos, thanks for having created this group. Now I can solve my 
questions Live 

:-)



Em segunda-feira, 25 de março de 2019 18:44:01 UTC-3, Ari Lion BR Sp 
escreveu:
>
> That's great
>
> Good live discussions at the Group.
>
> Em segunda-feira, 25 de março de 2019 09:20:29 UTC-3, Vlad escreveu:
>>
>> Joined!
>> Very nice & interactive - 
>> There is some beauty in messenger group interaction vs. traditionally 
>> organized groups...
>>
>> On Tuesday, March 19, 2019 at 2:49:34 PM UTC-4, Ari Lion BR Sp wrote:
>>>
>>> Oh, Great 
>>>
>>> Now I see a new link to this group:
>>> https://t.me/web2py_world
>>>
>>>
>>> Great I joined.
>>> That's great that Leonel Camara also joined the group!
>>> Now we can be sure that no doubt we have will be unanswered :-)
>>>
>>>
>>> Thanks!
>>>
>>>
>>> Em terça-feira, 19 de março de 2019 12:26:09 UTC-3, Carlos Costa 
>>> escreveu:

 we noticied this group has no administrator, so we are moving to a new 
 one, here is the link https://t.me/joinchat/DYZrfBT-bIsVhwLZc1hG8Q

 Em terça-feira, 19 de março de 2019 12:14:17 UTC-3, Carlos Costa 
 escreveu:
>
> We have had a good experience with the brazilian telegram group 
> dedicated to to support web2py users.
>
> But the english speaking group is not used at.
>
> Here is the link to join it: https://t.me/web2py_en
>
> Also, here is the link to the Brazilian group (portuguese speaking and 
> some portunhol allowed too :D ): https://t.me/web2pybrasil
>


-- 
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] Validation messages of extra fields in auth_user don't comply with available translations

2019-04-04 Thread João Matos


When creating extra fields for auth_user, the validation messages for those 
fields are always in English. They don't comply with the translations 
available.

This does not happen on the default fields.


I added this to db.py


auth.settings.extra_fields['auth_user'] = [Field('pagination', 'integer', 
default=9, label=T('Pagination'), notnull=True, required=True, requires=
IS_INT_IN_RANGE(5, 51))] 


When inserting an invalid value, the returned message is always

Enter an integer between 5 and 50
>
even when the web2py language is not English and the languages files have 
the correct translation available.


web2py 2.18.4
Python 3.7.1 x86
Firefox 66.0.2 x64
Windows 7 Pro x64 SP1+all updates

-- 
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] Improve the images load

2019-04-04 Thread Christian Varas
Hi, I would like to ask for recommendations to serve images with web2py.
I have a site (*https://climbersoul.cl *), this
site is a kind of Wikipedia for spots climbing in Chile. This site will
have a lot of images, and I would like to know how to optimize the load of
the images.
By now the images are served in the classic way like 
using the download function like in the book.
I was thinking in load the images as base64 but I don't sure if is this
will be more faster...
Another idea is moving the images to /app/static/images/ to avoid using
download function and avoid an extra processing of the server, but I'm not
sure is this will really improve the load.

I'm running web2py with Apache and modsecurity.

Any recommendations would be appreciated.

Cheers.
Chris.

-- 
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: Error Ticket Includes Sensitive Information

2019-04-04 Thread Anthony
On Thursday, April 4, 2019 at 10:47:10 AM UTC-4, Kevin Keller wrote:
>
> Can errror messags and tickets in production not be restricted to server 
> log files and disabled to be displayed for users or at least the ticket 
> itself made inaccessbile to normal users?
>

Normal users can never see error tickets. The problem is writing sensitive 
information to the server storage.

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] Re: Error Ticket Includes Sensitive Information

2019-04-04 Thread Kevin Keller
Can errror messags and tickets in production not be restricted to server
log files and disabled to be displayed for users or at least the ticket
itself made inaccessbile to normal users?

On Thu, Apr 4, 2019 at 4:38 PM zm  wrote:

> For what it's worth, I did post to the developer list, however it never
> appeared.  I assume it requires moderator approval or was rejected.
>
> On Tuesday, March 26, 2019 at 9:32:39 PM UTC-5, Anthony wrote:
>>
>> I don't think it's possible, but feel free to get a discussion going on
>> the developers' list
>> .
>> I'm sure a pull request would be welcome once an approach is decided.
>>
>> Anthony
>>
>> On Monday, March 25, 2019 at 1:57:00 PM UTC-4, zm wrote:
>>>
>>> The error tickets created by the framework are great for debugging,
>>> however depending on where a failure can include, they can include very
>>> sensitive information like user ID + password combinations.
>>>
>>> Is it possible to filter certain fields out of the tickets such as user
>>> name / password?  It seems like snapshot could be updated to include
>>> some sort of filter.
>>>
>> --
> 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] Re: Error Ticket Includes Sensitive Information

2019-04-04 Thread zm
For what it's worth, I did post to the developer list, however it never 
appeared.  I assume it requires moderator approval or was rejected.

On Tuesday, March 26, 2019 at 9:32:39 PM UTC-5, Anthony wrote:
>
> I don't think it's possible, but feel free to get a discussion going on 
> the developers' list 
> . 
> I'm sure a pull request would be welcome once an approach is decided.
>
> Anthony
>
> On Monday, March 25, 2019 at 1:57:00 PM UTC-4, zm wrote:
>>
>> The error tickets created by the framework are great for debugging, 
>> however depending on where a failure can include, they can include very 
>> sensitive information like user ID + password combinations.
>>
>> Is it possible to filter certain fields out of the tickets such as user 
>> name / password?  It seems like snapshot could be updated to include 
>> some sort of filter.   
>>
>

-- 
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] pyDAL "adapter" for Pandas syntax (phylosophical)

2019-04-04 Thread Jurgis Pralgauskis
I found my idea implementation for Django :)
https://github.com/coady/django-model-values

On Sun, May 6, 2018 at 6:14 AM Massimo Di Pierro 
wrote:

> I would very muck have a db().select_as_pandas() that avoids parsing
> the database response a puts the tuples representing the rows directly in
> DB. If nobody beats me on the time, I may get it done next week.
>
> Massimo
>
> On Friday, 4 May 2018 08:26:35 UTC-5, Richard wrote:
>>
>> By include in pandas I mean add support to pydal in pandas so you can do
>> something like :
>>
>> df = pd.DataFrame.from_pydal(db(...).select(...))
>>
>> Richard
>>
>> On Fri, May 4, 2018 at 1:10 AM, Jurgis Pralgauskis <
>> jurgis.pralgaus...@gmail.com> wrote:
>>
>>> I'd like not to include sth into Pandas, but to adapt Pandas syntax for
>>> DAL (SELECT part mostly, in my case) :)
>>>
>>> --
>>> Jurgis Pralgauskis
>>> tel: 8-616 77613
>>>
>>> 2018-05-03 04:05 popiet "Richard Vézina" 
>>> rašė:
>>>
>>> I use this to merge join dal query :
>>>
>>> # merge_dicts is from here :
>>> #
>>> http://stackoverflow.com/questions/38987/how-can-i-merge-two-python-dictionaries-in-a-single-expression
>>> def merge_dicts(*dict_args):
>>> """
>>> Given any number of dicts, shallow copy and merge into a new dict,
>>> precedence goes to key value pairs in latter dicts.
>>> """
>>> result = {}
>>> for dictionary in dict_args:
>>> result.update(dictionary)
>>> return result
>>>
>>> db(db.table_1.id == something).select(db.table_1.ALL, db.table_2.ALL,
>>> db.table_3.ALL, db.table_4.ALL, join or left=[...]).as_list()
>>>
>>> df = pd.DataFrame([merge_dicts(r['table_1'],
>>>r['table_2'],
>>>r['table_3'],
>>>r[table_4]) for r in
>>> rows.as_list()])
>>>
>>> What you want would have to be include in pandas.
>>>
>>> Richard
>>>
>>> On Thu, May 3, 2018 at 2:49 AM, Jurgis Pralgauskis <
>>> jurgis.pralgaus...@gmail.com> wrote:
>>>
 Bt if I want select cols/filter rows/aggregate/ join tables
  - with Pandas syntax directly from DB (for it to work as DAL, not with
 another DAL syntax) ?

 --
 Jurgis Pralgauskis
 tel: 8-616 77613

 2018-05-02, tr 22:22, Richard Vézina 
 rašė:

> I am not sure I understand what you want...
>
> It a nice thing if Pandas use RAM it means that it use the fastest
> component of you computer... It should make Pandas fast...
>
> I am not sure what would involve overloading operators to use pyDAL...
> Pandas is used to transform data... If what you do on your dataframe has 
> to
> be apply to your data would be really risky on the persistence stand
> point...
>
> To populate dataframe from web2py table :
>
> import pandas as pd
> rows = db(db.auth_user.id > 0).select(db.auth_user.ALL).as_list()
> df = pd.DataFrame(rows)
> df.columns  # Should be your fields names
>
> Richard
>
> On Tue, May 1, 2018 at 11:31 PM, Jurgis Pralgauskis <
> jurgis.pralgaus...@gmail.com> wrote:
>
>> Hi,
>>
>> Pandas syntax seems very nice (short), and popular ...
>> But Pandas eat RAM..., and well, most of data is in DB...
>>
>> so I wonder, how hard would it be to overload operators to use pyDAL
>> (or other DAL/ORM)?
>>
>> what are the main challanges?
>>
>> --
>> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/DIeQ5U-pr6Q/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 

Re: [web2py] Re: how to add users to existing programmatically using an if statement

2019-04-04 Thread micah jatta
thanks a lot Leonel!!


[image: Mailtrack]

Sender
notified by
Mailtrack

04/04/19,
2:10:37 PM

On Sun, Mar 31, 2019 at 3:01 PM Leonel Câmara 
wrote:

> register_bare returns the user record, so you can get user_id in user.id
>
> You can get the group id by doing
>
> # Assuming you create a group with role = 'Manager' and another with role
> = 'Assistante'
> group_id_manager = auth.id_group('Manager')
> group_id_assistant = auth.id_group('Assistant')
>
> Alternatively you can also get the id of the logged in user in auth.user_id
>
> --
> 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] Re: compile_application() not including symlinked views (while it includes symlinked controllers)

2019-04-04 Thread Lisandro
I don't think so, because the symlink has the same permissions (also owner) 
of the other symlinks that are compiled properly. Anyway, I tried to set 
777 permissions but it didn't work.

I forgot to mention that *symlinked views are compiled properly when the 
symlink points directly to a file*, for example:
views/test.html --> *symlink to external file*

... is properly compiled to this:
compiled/views.test.html.pyc


*It appears that the problem is when the symlink points to a folder *which 
contains the html files.

I've taken a look at the source code of compile_views() 

 
but I'm not that much experienced so I couldn't say why it doesn't follow 
symlinked folders :/


El jueves, 4 de abril de 2019, 7:59:49 (UTC-3), Leonel Câmara escribió:
>
> Could it be a permissions problem?
>

-- 
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: compile_application() not including symlinked views (while it includes symlinked controllers)

2019-04-04 Thread Leonel Câmara
Could it be a permissions problem?

-- 
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] Updating Values with the Ajax Callback funtion

2019-04-04 Thread mostwanted
I am customizing the OnlinePOS system to meet my task but i don't 
understand the Ajax Callback function, I can see it is very beneficial in 
updating values without a page refresh.

In the highlighted part in the view below, when i click the *plus *& *minus 
*links the quantity value gets updated without page refresh, 
What i want to achieve is that
*1. When the quantity gets updated i want the total figure to also update 
with quantity automatically *because presently i ma using a jQuery page 
reload function which is not ideal*,*

*2. *There is also a  with an input field where i enter the paying 
amount, *what i want is that when i click submit button there shouldnt be a 
page refresh but just have the paying amount displayed and the calculations 
done without the page reloading*, currently I get a page refresh!

How can i achieve these??


Below is my code:

*VIEW:*
{{extend 'layout.html'}}

$(document).ready(function(){
$('#reload2').click(function()
{
location.reload();
});
});


{{=A('CLEAR BASKET', _href=URL('start'), _id="basket")}}

Your Shopping Cart





PRODUCT
PRICE
QUANTITY
SUB-TOTAL
ADD/SUBTRACT

  {{for id, qty in cart.items():}}{{p=db.product(id)}}
  
{{=p.name}}
P {{=p.price}}
  {{=qty}}
  
  P {{=qty*p.price}}
  
  
##
*  
{{=A('+',callback=URL('cart_callback',vars=dict(id=p.id,action='add')),target='item%s'%p.id,_class='button
 
pill', _style='increase')}}*
*  
{{=A('-',callback=URL('cart_callback',vars=dict(id=p.id,action='sub')),target='item%s'%p.id,_class='button
 
pill', _style='increase')}}*
  
  

  {{pass}}


TenderP 
{{=text}}


Total P 
{{=total}} PRICE RELOAD<
/a> *#jQuery PAGE RELOAD FUNCTION*


Change: P 
{{=change}}




Authorised By: 
{{=auth.user.first_name}} {{=auth.user.last_name}}


Date & Time: 
{{=request.now}}







#INPUT FIELD FOR ENTERING THE PAYING AMOUNT







MOVE TO CHECKOUT



*CONTROLLER1*
@auth.requires_login()
def cart():
if not session.cart:
session.flash = 'Add something to shopping cart'
redirect(URL('index'))
total = sum(db.product(id).price*qty for id,qty in session.cart.items())
text=request.vars.name
if text:
change=int(text)-total
else:
change=int(0)
return dict(cart=session.cart, total=total, text=text, change=change)



*CONTROLLER2*
@auth.requires_login()
def buy():
if not session.cart:
session.flash = 'Add something to shopping cart'
redirect(URL('index'))
import uuid
from gluon.contrib.AuthorizeNet import process
invoice = str(uuid.uuid4())
total = sum(db.product(id).price*qty for id,qty in session.cart.items())
for key, value in session.cart.items():
db.sale.insert(invoice=invoice,buyer=auth.user.id,product = 
key,quantity 
= value,price = db.product(key).price)
session.cart.clear()
session.flash = 'Purchase Complete'
redirect(URL('invoice',args=invoice))
return dict(cart=session.cart,form=form,total=total)

Mostwanted


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