def _handle_update_repos(self): """ Called to refresh the user repos. """ rdw_spider_repos.find_repos_for_user(self.app.currentuser.username, self.app.userdb) return {'success': _("Repositories successfully updated.")}
def _users_handle_action(self, action, username, email, password, user_root, is_admin): success = "" # We need to change values. Change them, then give back that main # page again, with a message if username == self.app.currentuser.username: # Don't allow the user to changes it's "admin" state. is_admin = self.app.currentuser.is_admin is_admin = str(is_admin).lower() in ['true', '1'] # Fork the behaviour according to the action. if action == "edit": user = self.app.userdb.get_user(username) logger.info("updating user [%s] info", user) if password: self.app.userdb.set_password(username, password, old_password=None) user.user_root = user_root user.is_admin = is_admin # Avoid updating the email fields is it didn'T changed. see pdsl/minarca#187 if email != user.email: user.email = email success = _("User information modified successfully.") # Check and update user directory self._check_user_root_dir(user_root) rdw_spider_repos.find_repos_for_user(user) elif action == "add": if username == "": raise RdiffWarning(_("The username is invalid.")) logger.info("adding user [%s]", username) user = self.app.userdb.add_user(username, password) user.user_root = user_root user.is_admin = is_admin user.email = email # Check and update user directory self._check_user_root_dir(user_root) rdw_spider_repos.find_repos_for_user(user) success = _("User added successfully.") if action == "delete": user = self.app.userdb.get_user(username) if username == self.app.currentuser.username: raise RdiffWarning(_("You cannot remove your own account!.")) logger.info("deleting user [%s]", username) self.app.userdb.delete_user(user) success = _("User account removed.") # Return messages return {'success': success}
def deamon_run(self): """ Refresh the user repository """ try: user_db = self.app.userdb if not user_db.supports('set_repos'): return users = user_db.list() for user in users: find_repos_for_user(user, user_db) except: _logger.exception("fail to update user repos")
def deamon_run(self): """ Refresh the user repository """ try: user_db = self.app.userdb if not user_db.supports('set_repos'): return users = user_db.list() for user in users: find_repos_for_user(user) except: _logger.exception("fail to update user repos")