On Sunday, August 28, 2022 at 7:50:27 PM UTC-7 silvia...@gmail.com wrote:

> Actually I have 3 endpoints tier 1 tier 2 and tier 3 so example if 
> choosing Germany it should redirect to www.website/tier1.com if choosing 
> for example Viertnam it should redirect to www.website/tier3.com that is 
> what I try to achieve but one thing is I have all my countries in arrays 
> sorted from tier 1 to tier 3. 
>
>
If those arrays are globally defined (as in db.py), then you just do 
       if country in tier1_array:  redirect(URL("tier1.com", ...))"
which is pretty much the same as Jim's suggestion.  If you need to look 
into the database which tier the country is in,  you probably would look 
that up using one of the shortcuts shown in the DAL chapter of the book.

/dps

 

> Jim S schrieb am Freitag, 26. August 2022 um 19:36:30 UTC+7:
>
>> It is doing to depend on how your URLs are structured for each country 
>> page.  I'm guessing you'll have a different endpoint for each country in 
>> your set of countries.
>>
>> Likewise for Companies.  You said 'if I select company I want to redirect 
>> to company'.  Based on the code you posted I'm not sure what that means.  
>> You don't have a 'company' field, just an entity type called country.  What 
>> is the endpoint that you want it to redirect to?
>>
>> -Jim
>>
>>
>> On Thursday, August 25, 2022 at 10:37:51 PM UTC-5 silvia...@gmail.com 
>> wrote:
>>
>>> Sure thanks in advance that is my DB so for example if I select company 
>>> I want it to redirect to company and if I select a certrain country lets 
>>> say germany or so I want it to redirect to the german page of company would 
>>> that be possible ?
>>>
>>> db.define_table('partner',
>>> Field('name'),
>>> Field('address'),
>>> Field('country',requires=IS_IN_SET(countries)),
>>> Field('postalcode'),
>>> Field('entity_type',requires=IS_IN_SET(['Company','Person'])),
>>> Field('partner_manager', 'reference auth_user', requires = IS_IN_DB(db, 
>>> 'auth_user.id','%(last_name)s')),
>>> Field('email'),
>>> Field('web'))
>>>
>>> that is my controller:
>>>
>>> def partner():
>>>     form = SQLFORM(db.partner, _name='form_partner')
>>>     if form.process().accepted:
>>>         session.flash = 'Partner added !'
>>>         redirect(URL('partnerlist'))
>>>     else: 
>>>         session.flash = 'Please try again !'
>>>     return dict(form=form)
>>> Jim S schrieb am Donnerstag, 25. August 2022 um 22:30:56 UTC+7:
>>>
>>>> Can you share the code you have so far?
>>>>
>>>> I'd probably do something like:
>>>>
>>>> form = SQLFORM.factory(...your form definition here...)
>>>>
>>>> if form.process().accepted:
>>>>     if form.vars.field_1 == 'some test case you want to redirect on':
>>>>         redirect(URL('my_redirect_url', vars=dict(my vars to pass to 
>>>> the redirect))
>>>>     elif form.vars.field_2 == 'another test case you want to redirect 
>>>> on':
>>>>         redirect(URL('my other redirect url')
>>>>
>>>> -Jim
>>>>
>>>> On Thursday, August 25, 2022 at 12:48:05 AM UTC-5 silvia...@gmail.com 
>>>> wrote:
>>>>
>>>>> I have a form with a few selections but I want to redirect it to a 
>>>>> other page depends on the selection does someone know how to do that ?
>>>>
>>>>

-- 
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/7fc4aff7-cfc4-4c00-88fb-c87817ddc527n%40googlegroups.com.

Reply via email to