On Saturday, March 23, 2019 at 6:38:32 AM UTC-7, Maurice Waka wrote:
>
> I would like to have a way of coding for subscription timelines such as 1
> month duration, three months duration with expiry dates notification and
> cancellation after expiry dates.
>
>
I'm not sure why you'd want that in the transaction forms. It sounds like
it belongs in the table of subscriptions:
db.define_table("subscriptions",
[...]
Field("subscription","date"))
> That when a user clicks on 'buy' button, the next page comes with the
> selected item with an automatic price tag set not a text area for amount to
> be pain as in this app.
>
In your redirect, add a var for the select product (e.g., length of
subscription),
and then the controller for the target page looks up the price, sets that
as the default for the field, and makes writable=False.
>
> Below is my initial code that works so far.
>
>
>
>
>
> Pending = db.define_table('pending_transaction',
> Field('user_id', 'reference auth_user'),
> Field('token_class','integer',requires=IS_IN_SET
> ((["One Month Subscription", "Three months Subsription", "Six Months
> Subscription", "One Time Full year Subscription"]))),
> Field('amount','double'),
> #Field('start_date', 'date',
> default=subscription_row.start_date),
> #Field('renew_date', 'date',
> default=subscription_row.renew_date),
> Field('payment_system',requires=IS_IN_SET(([
> 'paypal','mollie','m-pesa',])),default='None'),
> Field('confirmed', 'boolean', default=False),
> auth.signature
> )
>
>
> Confirmed = db.define_table('confirmed_transaction',
> Field('user_id', 'reference auth_user'),
> Field('token_class','integer',requires=IS_IN_SET((["A",
> "B", "C"]))),
> Field('amount','double'),
> Field('payment_systems',requires=IS_IN_SET((['paypal',
> 'mollie','m-pesa',])),default='None'),
> Field('pending_id', 'reference pending_transaction'),
> Field('payment_system_code'),
> Field('confirmation_time', 'datetime'),
> Field('tokens', 'integer'),
> auth.signature
> )
> controller:
>
> def buy_credits():
> #Change visbility of form field
> Pending.user_id.default = auth.user_id
> Pending.user_id.writable = Pending.user_id.readable = False
> Pending.confirmed.writable = Pending.confirmed.readable = False
>
> #Html widgets from dropdown to radio boxes
> horizontal_radio = lambda field, value: SQLFORM.widgets.radio.widget(
> field, value, style="ul", _class="horizontal-radio")
> Pending.token_class.widget = horizontal_radio
> Pending.payment_system.widget = horizontal_radio
>
> #Form and processing
> form = SQLFORM(Pending, formstyle="divs", submit_button='Buy')
> if form.process().accepted:
> #record inserted into pending table, redirect user to payment
> process
> session.pending = form.vars
> redirect(URL('default', form.vars.payment_system))
> return dict(form=form)
> view:
>
>
> {{extend 'layout.html'}}
>
>
> <style type="text/css">
> .horizontal-radio ul {
> list-style:none;
> }
> .horizontal-radio ul{
> float:auto;
> }
> </style>
>
>
> {{=form}}
>
>
>
.Good luck!
/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 [email protected].
For more options, visit https://groups.google.com/d/optout.