# Path: action/base_manager.py
# class BaseManager:
#     COOKIE_PATH = '/'
#     def delete_cookie(self, name):
#     def get_cookie(self, name):
#     def get_form(self, name, strip_value=True):
#     def set_cookie(self, name, value, httponly=True, expires=None):
# 
# Path: entity/user.py
# class User:
#     def __init__(self, id=None, name=None, pw_hash=None, salt=None, session=None):
#     def __str__(self):
#     def count_all(db):
#     def delete(self, db):
#     def find_all(db):
#     def find_name(db, name):
#     def find_pk(db, id):
#     def from_row(db, row):
#     def is_new(self):
#     def save(self, db):
#     def __generic_find(db, query, params):
# 
# Path: helper/hint.py
# class Hint:
#     def __init__(self, text):
# 
# Path: helper/translator.py
# class TranslatorNotInitializedError(Exception):
# class Translator:
#     def current_language(default_language):
#     def init(language, path):
#     def instance(language):
# 
# Path: helper/url.py
# class Url:
#     def from_category(category, absolute=None):
#     def from_css(css_file, absolute=None):
#     def from_img(img_file, absolute=None):
#     def from_js(js_file, absolute=None):
#     def from_path(path_parts, absolute=None, filter_chars=False):
#     def from_recipe(recipe, absolute=None):
#     def search(search_text, absolute=None):
#     def slugify(text):


import datetime
import hashlib
import random
import uuid
from action import base_manager
from bottle import redirect
from entity import user as user_entity
from helper import hint
from helper import translator
from helper import url
                hint_text = _('Both passwords are not the same.')
                self.hints.append(hint.Hint(hint_text))
            elif user_entity.User.find_name(self.db, user_name):
                hint_text = _('User name is already taken.')
                self.hints.append(hint.Hint(hint_text))
            else:
                user = user_entity.User(name=user_name)
                user.salt = self.__generate_salt()
                user.pw_hash = self.__generate_pw_hash(password, user.salt,
                                                  pw_hash_iterations)
                user.save(self.db)
                hint_text = _('User "{}" has been created.').format(user_name)
                self.hints.append(hint.Hint(hint_text))

        elif action == 'edit':
            id = self.get_form('id')
            user = user_entity.User.find_pk(self.db, id)
            is_delete = self.get_form('delete') is not None
            if is_delete:
                hint_text = _('User "{}" has been deleted.').format(user.name)
                user.delete(self.db)
                self.hints.append(hint.Hint(hint_text))
            else:
                password = self.get_form('password', False)
                password_confirm = self.get_form('password-confirm', False)
                if not password:
                    hint_text = _('Please provide the password.')
                    self.hints.append(hint.Hint(hint_text))
                elif password != password_confirm:
                    hint_text = _('Both passwords are not the same.')

# Path: action/base_manager.py
# class BaseManager:
#     COOKIE_PATH = '/'
#     def delete_cookie(self, name):
#     def get_cookie(self, name):
#     def get_form(self, name, strip_value=True):
#     def set_cookie(self, name, value, httponly=True, expires=None):
# 
# Path: entity/user.py
# class User:
#     def __init__(self, id=None, name=None, pw_hash=None, salt=None, session=None):
#     def __str__(self):
#     def count_all(db):
#     def delete(self, db):
#     def find_all(db):
#     def find_name(db, name):
#     def find_pk(db, id):
#     def from_row(db, row):
#     def is_new(self):
#     def save(self, db):
#     def __generic_find(db, query, params):
# 
# Path: helper/hint.py
# class Hint:
#     def __init__(self, text):
# 
# Path: helper/translator.py
# class TranslatorNotInitializedError(Exception):
# class Translator:
#     def current_language(default_language):
#     def init(language, path):
#     def instance(language):
# 
# Path: helper/url.py
# class Url:
#     def from_category(category, absolute=None):
#     def from_css(css_file, absolute=None):
#     def from_img(img_file, absolute=None):
#     def from_js(js_file, absolute=None):
#     def from_path(path_parts, absolute=None, filter_chars=False):
#     def from_recipe(recipe, absolute=None):
#     def search(search_text, absolute=None):
#     def slugify(text):


# Path: action/user_manager.py
import datetime
import hashlib
import random
import uuid
from action import base_manager
from bottle import redirect
from entity import user as user_entity
from helper import hint
from helper import translator
from helper import url

                hint_text = _('Both passwords are not the same.')
                self.hints.append(hint.Hint(hint_text))
            elif user_entity.User.find_name(self.db, user_name):
                hint_text = _('User name is already taken.')
                self.hints.append(hint.Hint(hint_text))
            else:
                user = user_entity.User(name=user_name)
                user.salt = self.__generate_salt()
                user.pw_hash = self.__generate_pw_hash(password, user.salt,
                                                  pw_hash_iterations)
                user.save(self.db)
                hint_text = _('User "{}" has been created.').format(user_name)
                self.hints.append(hint.Hint(hint_text))

        elif action == 'edit':
            id = self.get_form('id')
            user = user_entity.User.find_pk(self.db, id)
            is_delete = self.get_form('delete') is not None
            if is_delete:
                hint_text = _('User "{}" has been deleted.').format(user.name)
                user.delete(self.db)
                self.hints.append(hint.Hint(hint_text))
            else:
                password = self.get_form('password', False)
                password_confirm = self.get_form('password-confirm', False)
                if not password:
                    hint_text = _('Please provide the password.')
                    self.hints.append(hint.Hint(hint_text))
                elif password != password_confirm:
                    hint_text = _('Both passwords are not the same.')

                    self.hints.append(hint.Hint(hint_text))