I have a login form on my first index page. Could that be the problem. No matter what I cannot get the session.flash message to be presented.
2016-02-04 9:20 GMT+01:00 Vid Ogris <vid.og...@gmail.com>: > DO you suggest I change my controller completely ? > > where do I set auth.settings_register_onaccept? in db.py? > > 2016-02-03 17:16 GMT+01:00 Anthony <abasta...@gmail.com>: > >> If you do: >> >> form = auth() >> >> then you cannot call form.process(), as auth() automatically calls >> .process() itself. Also, the auth.register() method automatically redirects >> after processing, so the rest of your code will not be reached anyway. If >> you want to do something after registration, specify a callback via >> auth.settings.register_onaccept. >> >> Anthony >> >> >> On Wednesday, February 3, 2016 at 10:59:52 AM UTC-5, Yebach wrote: >>> >>> Hello >>> >>> I cannot retrieve the session.flash message after user successfully >>> registers >>> >>> my controler (default.py ) is the following >>> >>> def user(): >>> >>> if request.args(0)=='profile': >>> #uporabnikov Id >>> uid = auth.user_id >>> #preberem podatke za tega userja iz obeh tabel >>> record = db((db.auth_user.organization==db.organizations.id) & ( >>> db.auth_user.id == uid)).select().as_list()[0] >>> recordd = db((db.auth_user.organization==db.organizations.id) & >>> (db.auth_user.id == uid)).select().first() >>> >>> #Skrijem nepotrebna polja >>> fields_to_hide_org = ['id', 'o_usern', 'o_useru', >>> 'o_daten','o_dateu', 'o_status', 'o_code', 'o_faxnumber',\ >>> 'o_rootid', 'o_parentid', 'o_levelid', >>> 'o_positionx','o_positiony' ] >>> >>> for fieldname in fields_to_hide_org: >>> field = db.organizations[fieldname] >>> field.readable = field.writable = False >>> >>> fields_to_hide_user = ['email', 'password', 'organization'] >>> >>> for fieldname in fields_to_hide_user: >>> field = db.auth_user[fieldname] >>> field.readable = field.writable = False >>> >>> #org_name = db(db.organization.id == >>> record["organization"]).select(db.organization.o_name).as_list()[0]["o_name"] >>> >>> >>> #nastavim vrednsoti polj, ki so ze v bazi >>> authfields = [field for field in db.auth_user if field.name != >>> 'id'] >>> >>> #print record >>> for field in authfields: >>> #print field >>> field.default = recordd.auth_user[field.name] >>> >>> orgfields = [field for field in db.organizations if field.name >>> != 'id'] >>> for field in orgfields: >>> field.default = recordd.organizations[field.name] >>> >>> >>> # db.auth_user.first_name.default = >>> record["auth_user"]["first_name"] >>> # db.auth_user.last_name.default = >>> record["auth_user"]["last_name"] >>> # db.organization.o_name.default = >>> record["organization"]["o_name"] >>> >>> form=SQLFORM.factory(db.auth_user,db.organizations, keepvalues = >>> True) >>> >>> orgid = record["organizations"]['id'] >>> #print orgid >>> >>> if form.process().accepted: >>> #Updatam polja v bazi >>> org_forma = db.organizations._filter_fields(form.vars) >>> for key, value in org_forma.iteritems(): >>> #print key, value >>> db(db.organizations._id==orgid).update(**{key:value}) >>> #db(db.organization.id==orgid).update(key = value) >>> >>> user_forma = db.auth_user._filter_fields(form.vars) >>> for key, value in user_forma.iteritems(): >>> db(db.auth_user._id==orgid).update(**{key:value}) >>> >>> >>> response.flash=T('Thanks for filling the form') >>> redirect(URL('index')) >>> >>> return dict(form=form) >>> >>> >>> form = auth() >>> >>> """ >>> Tole je sedaj tukaj ker ni delal foreing kej na >>> auth_user.organization >>> """ >>> if request.args(0) == 'register': >>> >>> if form.process().accepted: >>> database = str(db).rpartition('/')[-1].replace('">', '') >>> host = request.http_host >>> port = request.http_port >>> app = request.application >>> if host: >>> name = '%s/%s' % (host, app) >>> else: >>> name = app >>> >>> userid = form.vars.id >>> email = form.vars.email >>> add_organization(form, userid) >>> formFile = os.path.join(request.folder, 'private', >>> 'formular_woshi_2016-02-01.rtf') >>> regKey = db(db.auth_user.id == >>> userid).select(db.auth_user.registration_key).first() >>> key = regKey.registration_key >>> message_content = T('Click on the link ') + ' >>> http://shift.workerscheduling.com' + >>> URL(r=request,c='default',f='user',args=['verify_email']) + '/%s ' % (key) >>> + T('to verify your email') >>> mail.send(to=[email], >>> subject='Woshi confirm registration', >>> message=message_content, >>> attachments = mail.Attachment(formFile, >>> content_id='file') >>> ) >>> >>> >>> mail.send(to = dddd', >>> subject= 'New user registered in WoShi', >>> message = 'A new user with e-mail address ' + >>> email + ' has registered to Woshi with url address ' + name + ' in database >>> ' + database >>> ) >>> >>> session.flash= "Please check your e-mail to confirm >>> registration" >>> redirect(URL('index')) >>> >>> >>> return dict(form = form) >>> >>> >>> You can see the default/index.html page on >>> http://shift.workerscheduling.com >>> >>> Any suggestions? >>> >>> -- >> 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/NwljExPCKAA/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. >> > > > > -- > Lep pozdrav > > Vid Ogris > > > -- Lep pozdrav Vid Ogris -- 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.