Login form does not present error msg

21 views
Skip to first unread message

Yebach

unread,
Mar 25, 2016, 8:30:14 AM3/25/16
to web...@googlegroups.com
UPDATE:

As a matter of fact if e-mail is not correct I get an ajax message invalid e-mail, only when pass is incorrect the page is just reloaded


------------------------------

Hello

I am having a problem with my login form

I have a login form on my index page.

If a user enters wrong pass there is no error msg only page is reloaded

Any suggestion? Thank you

My controller:

   
def index():


# If user is not logged in
if not auth.is_logged_in():
auth.settings.formstyle='bootstrap'
db.auth_user.email.widget = lambda f,v: SQLFORM.widgets.string.widget(f, v, _placeholder='Enter your email address')
db.auth_user.password.widget = lambda f,v: SQLFORM.widgets.password.widget(f, v, _placeholder='Enter your password')
return dict(formLogin = auth(), loggedIn = False)



"brez sc_menu_data ker ga ne rabmo"
scripts = db((db.auth_user.id == auth.user_id) & (db.scripts.sc_organization == db.auth_user.organization)
).select(db.scripts.id, db.scripts.sc_status, db.scripts.sc_cal_start, db.scripts.sc_cal_end, db.scripts.sc_name, db.scripts.sc_modified,
db.scripts.sc_verification_date, orderby = db.scripts.id).as_list()


for script in scripts:
sa_start = db(db.script_activity.sa_id_script == script['id']).select(db.script_activity.sa_start, orderby = ~db.script_activity.sa_start, limitby = (0, 1)).as_list()
script['sa_start'] = sa_start[0]['sa_start'] if sa_start else None

##pogledamo še kakšen je status userja (free user itd)
user = auth.user_id
#userRegDate = db(db.auth_user.id == user).select(db.auth_user.regdate).first()["regdate"]
userFreeEndDate = db(db.accounting.ac_organization == user).select(db.accounting.ac_end_date).first()["ac_end_date"]
email = db(db.auth_user.id == user).select(db.auth_user.email).first()["email"]
org = db(db.auth_user.id == user).select(db.auth_user.organization).first()["organization"]

userStatus = db(db.accounting.ac_organization == org).select(db.accounting.ac_customer,db.accounting.ac_run_status).first()
userType = userStatus.ac_customer
runStatus = userStatus.ac_run_status
today = datetime.datetime.now()


""""če je trenutni datum manjši od datuma registracije + 30 dni pol je user free user
Drugače se prestavi runStatus na 1 in user ne more več računat, ac_end_date se pa poveča za 7 dni"""
"userFreeEndDate je datum registracije + 30 dni, ki se ga prebere iz baze"

"newUserRegEndDate je datum registracije + 30 dni, ki se zračuna že na začetku + 7 dni, samo se računa iz datuma registracije"


note = db(db.accounting.ac_organization == user).select(db.accounting.ac_note).first()["ac_note"]
"""Če je danes večji od konca free user acounta in v polju ac_note ni nič, kar pomeni da se mu mail še ni poslal, se runstatus spremeni v 1
in pošlje se mail, ter new user date se skreira ki je 7 dni kasnej da lahko še en teden gleda ne more pa računat"""

if ((today.date() > userFreeEndDate) and (not note or note is None)):
"runStatus gre v 1 in in ac_end_Date se poveča za 7 dni, uporabnik ne more več dat računat"
newUserRegEndDate = userFreeEndDate + datetime.timedelta(days=7)
db(db.accounting.ac_organization == user).update(ac_run_status = 1, ac_end_date = newUserRegEndDate)
runStatus = 1
#TO-DO
#Pošlji mail obema, in to se zapiše v ac_note da se ne pošilja vsakič ko kdo klikne F5
message_content = T('Your Free user account expired. If you are satisfied with Woshi and would like to use it more, please contact xxx to extend \
your subscription. Thank you')
mail.send(to=[email],
subject='Woshi Free user account expired',
message=message_content,
)


mail.send(to = 'xx',
subject= 'User account expired',
message = 'User with e-mail address ' + email + ' has expired his subscription. Better call him !'
)
db(db.accounting.ac_organization == user).update(ac_note = 'Free user expiration mail sent.')

"Če je danes po tem ko ma user konc accounta - tega se ročno nastavla"
elif ((today.date() > userFreeEndDate) and (runStatus == 1)):

"User ne more računat zato gre ac_run_status v 0 in user ne more ni več, tud ne vid več svojih skript itd."
db(db.accounting.ac_organization == user).update(ac_run_status = 0)
runStatus = 0
#TO-DO
#Pošlji mail obema
message_content = T('Your user account expired. Please contact to extend your subscription and continue using Woshi.')
mail.send(to=[email],
subject='Woshi User account expired',
message=message_content,
)


mail.send(to = 'xxxx',
subject= 'User account expired',
message = 'User with e-mail address ' + email + ' has expired his subscription. Better call him !')
db(db.accounting.ac_organization == user).update(ac_note = 'User cannot use Woshi anymore. His subscription expired.')


return dict(loggedIn = True, scripts = scripts, message=T("Hello World"),userType = userType, runStatus = runStatus)



my View (index.hmtl):


{{ if not loggedIn: }}

<div class="row" style="height: calc(100% - 20px); margin-top: 20px;">
<div class="col-md-4 box-login" >
<div class="box-shadow margin-bottom-10">
<h1>{{=T('Log in')}}</h1>
<div class='bStrapForm'>
{{=formLogin}}
</div>
<div class="row padding-10">
<div class="col-sm-6"><a class="btn btn-success" style="width:100%;" href="{{=URL('default', 'user', args='register')}}">{{=T('Sign up')}}</a></div>
<div class="col-sm-6"><a class="btn btn-warning" style="width:100%;" href="{{=URL('default', 'user', args='request_reset_password')}}">{{=T('Forgot password?')}}</a></div>
</div>
</div>
<!-- <div class="box-shadow margin-bottom-10"> -->
<!-- <h1>References</h1> -->
<!-- <div class='padding-10'> -->
<!-- Mercator, Tuš, SIJ, ... -->
<!-- </div> -->
<!-- </div> -->
<div class="jumbotron jumbotron-mini margin-top-10 margin-bottom-10">
<h2>{{=T('Free for 30 days!')}}</h2>
<p>
<!-- {{=T('We offer automated worker shift generation for up to 3 workers free of charge. You will pay when you will grow!')}} -->
<p>
<p><a class="btn btn-info btn-lg" target="_blank" href="{{=T('http://www.workerscheduling.com/pricing/')}}">{{=T('More about prices')}}</a></p>
</div>
<!--<div class="margin-bottom-60">-->
<!--<h1>{{=T('How does it work?')}}</h1>-->
<!--<div class='padding-10'>-->
<!--<iframe style="width: 100%; height: 215px;" src="//www.youtube.com/embed/PqKNCzQMTAQ" frameborder="0" allowfullscreen></iframe>-->
<!--</div>-->
<!--</div>-->
</div>
<div class="col-md-8">
<div id='fPage_show'>
<h1>{{=T('Automize your work schedule!')}}</h1>
<a href="{{=URL('user/register')}}" class="btn btn-success btn-lg">{{=T('Try now for free')}}</a>
</div>
<hr/>
<div class="row" id="fPage_content">
<div class="col-md-4">
<div class='thumbnail' id="pWorkers">
<h2><span>{{=T('Wo')}}</span>{{=T('rkers')}}</h2>
<p>
{{=T('Set the number of employees for a time periods for each day of week and WoShi will schedules your employees into shifts.')}}
</p>
</div>
</div>
<div class="col-md-4">
<div class="thumbnail" id="pShifts">
<h2><span>{{=T('Shi')}}</span>{{=T('ft')}}</h2>
<p>
{{=T('Set the shifts to all workers for all days of the week and holidays and WoShi will automatically schedule your employees instead of you.')}}
</p>
</div>
</div>
<div class="col-md-4">
<div class="thumbnail" id="pAuto">
<h2>{{=T('Save Money')}}</h2>
<p>
{{=T('You will save time and money using WoShi by reducing the number of overtime hours with the same number of employees.')}}
</p>
</div>
</div>
</div>
</div>
</div>
{{ else: }}
...
....
.....
 



Reply all
Reply to author
Forward
0 new messages