action =='edit':
user_data = self._validate(exclude=('password',))
service = UserService(g.db, current_user.id)
lang = request.form.get('lang')
if self.validation_errors:
[flash(_(j), 'danger') for i in self.validation_errors.values() for j in i]
response = redirect(url_for('.users', action='edit', uid=current_user.id))
else:
if user_data.get('password') == '':
response = make_response(redirect(url_for('.users', action='show', uid=current_user.id)))
if lang:
response.set_cookie('lang', lang)
service.update({'lang': lang})
flash(_('Data updated successfully'), 'info')
else:
if service.update(user_data):
response = make_response(redirect(url_for('.users', action='show', uid=current_user.id)))
response.set_cookie('lang', lang)
flash(_('Data updated successfully'), 'info')
else:
response = redirect(url_for('.users', action='edit', uid=current_user.id))
return response
flash не использую, куки напрямую не ставлю, action вообще нигде не тащу. Как я живу?
Обсуждают сегодня