def test_index(self): self.log_user() response = self.app.get(url(controller='home', action='index')) #if global permission is set response.mustcontain('Add repository') # html in javascript variable: response.mustcontain("""var data = {"totalRecords": %s""" % len(Repository.getAll())) response.mustcontain(r'href=\"/%s\"' % HG_REPO) response.mustcontain( r"""<img class=\"icon\" title=\"Mercurial repository\" """ r"""alt=\"Mercurial repository\" src=\"/images/icons/hg""" r"""icon.png\"/>""") response.mustcontain( r"""<img class=\"icon\" title=\"Public repository\" """ r"""alt=\"Public repository\" src=\"/images/icons/public_""" r"""repo.png\"/>""") response.mustcontain( """fixes issue with having custom format for git-log""") response.mustcontain( """/%s/changeset/5f2c6ee195929b0be80749243c18121c9864a3b3""" % GIT_REPO) response.mustcontain( """disable security checks on hg clone for travis""") response.mustcontain( """/%s/changeset/96507bd11ecc815ebc6270fdf6db110928c09c1e""" % HG_REPO)
def get_locks(self, apiuser, userid=Optional(OAttr('apiuser'))): """ Get all locks for given userid, if this command is runned by non-admin account userid is set to user who is calling this method, thus returning locks for himself :param apiuser: :param userid: """ if not HasPermissionAnyApi('hg.admin')(user=apiuser): #make sure normal user does not pass someone else userid, #he is not allowed to do that if not isinstance(userid, Optional) and userid != apiuser.user_id: raise JSONRPCError('userid is not the same as your user') ret = [] if isinstance(userid, Optional): user = None else: user = get_user_or_error(userid) #show all locks for r in Repository.getAll(): userid, time_ = r.locked if time_: _api_data = r.get_api_data() # if we use userfilter just show the locks for this user if user: if safe_int(userid) == user.user_id: ret.append(_api_data) else: ret.append(_api_data) return ret
def test_index_with_lightweight_dashboard(self): self.log_user() self._set_l_dash(True) try: response = self.app.get(url(controller='home', action='index')) response.mustcontain("""var data = {"totalRecords": %s""" % len(Repository.getAll())) finally: self._set_l_dash(False)
def get_user_locks(request, apiuser, userid=Optional(OAttr('apiuser'))): """ Displays all repositories locked by the specified user. * If this command is run by a non-admin user, it returns a list of |repos| locked by that user. This command takes the following options: :param apiuser: This is filled automatically from the |authtoken|. :type apiuser: AuthUser :param userid: Sets the userid whose list of locked |repos| will be displayed. :type userid: Optional(str or int) Example output: .. code-block:: bash id : <id_given_in_input> result : { [repo_object, repo_object,...] } error : null """ include_secrets = False if not has_superadmin_permission(apiuser): # make sure normal user does not pass someone else userid, # he is not allowed to do that if not isinstance(userid, Optional) and userid != apiuser.user_id: raise JSONRPCError('userid is not the same as your user') else: include_secrets = True userid = Optional.extract(userid, evaluate_locals=locals()) userid = getattr(userid, 'user_id', userid) user = get_user_or_error(userid) ret = [] # show all locks for r in Repository.getAll(): _user_id, _time, _reason = r.locked if _user_id and _time: _api_data = r.get_api_data(include_secrets=include_secrets) # if we use user filter just show the locks for this user if safe_int(_user_id) == user.user_id: ret.append(_api_data) return ret
def test_index_with_lightweight_dashboard(self): self.log_user() def set_l_dash(set_to): self.app.post(url('admin_setting', setting_id='visual'), params=dict(_method='put', rhodecode_lightweight_dashboard=set_to,)) set_l_dash(True) try: response = self.app.get(url(controller='home', action='index')) response.mustcontain("""var data = {"totalRecords": %s""" % len(Repository.getAll())) finally: set_l_dash(False)
def get_repos(self, apiuser): """" Get all repositories :param apiuser """ result = [] for repository in Repository.getAll(): result.append( dict( id=repository.repo_id, name=repository.repo_name, type=repository.repo_type, description=repository.description ) ) return result
def get_repos(self, apiuser): """" Get all repositories :param apiuser: """ result = [] for repository in Repository.getAll(): result.append( dict( id=repository.repo_id, repo_name=repository.repo_name, type=repository.repo_type, description=repository.description ) ) return result
def command(self): # get SqlAlchemy session self._init_session() repo_update_list = ( map(string.strip, self.options.repo_update_list.split(",")) if self.options.repo_update_list else None ) if repo_update_list: repo_list = Repository.query().filter(Repository.repo_name.in_(repo_update_list)) else: repo_list = Repository.getAll() RepoModel.update_repoinfo(repositories=repo_list) Session().commit() if self.options.invalidate_cache: for r in repo_list: r.set_invalidate() log.info("Updated cache for %s repositories" % (len(repo_list)))
def command(self): logging.config.fileConfig(self.path_to_ini_file) from pylons import config #get to remove repos !! add_cache(config) engine = engine_from_config(config, 'sqlalchemy.db1.') init_model(engine) repo_update_list = map(string.strip, self.options.repo_update_list.split(',')) \ if self.options.repo_update_list else None if repo_update_list: repo_list = Repository.query().filter(Repository.repo_name.in_(repo_update_list)) else: repo_list = Repository.getAll() for repo in repo_list: last_change = repo.scm_instance.last_change repo.update_last_change(last_change)
def command(self): #get SqlAlchemy session self._init_session() repo_update_list = map(string.strip, self.options.repo_update_list.split(',')) \ if self.options.repo_update_list else None if repo_update_list: repo_list = Repository.query()\ .filter(Repository.repo_name.in_(repo_update_list)) else: repo_list = Repository.getAll() RepoModel.update_repoinfo(repositories=repo_list) Session().commit() if self.options.invalidate_cache: for r in repo_list: r.set_invalidate() log.info('Updated cache for %s repositories' % (len(repo_list)))
def test_index(self): self.log_user() response = self.app.get(url(controller='home', action='index')) #if global permission is set response.mustcontain('Add repository') # html in javascript variable: response.mustcontain("""var data = {"totalRecords": %s""" % len(Repository.getAll())) response.mustcontain(r'href=\"/%s\"' % HG_REPO) response.mustcontain(r"""<img class=\"icon\" title=\"Mercurial repository\" """ r"""alt=\"Mercurial repository\" src=\"/images/icons/hg""" r"""icon.png\"/>""") response.mustcontain(r"""<img class=\"icon\" title=\"Public repository\" """ r"""alt=\"Public repository\" src=\"/images/icons/public_""" r"""repo.png\"/>""") response.mustcontain("""fixes issue with having custom format for git-log""") response.mustcontain("""/%s/changeset/5f2c6ee195929b0be80749243c18121c9864a3b3""" % GIT_REPO) response.mustcontain("""disable security checks on hg clone for travis""") response.mustcontain("""/%s/changeset/96507bd11ecc815ebc6270fdf6db110928c09c1e""" % HG_REPO)
def get_locks(self, apiuser, userid=Optional(OAttr('apiuser'))): """ Get all locks for given userid, if this command is runned by non-admin account userid is set to user who is calling this method, thus returning locks for himself :param apiuser: :param userid: """ if HasPermissionAnyApi('hg.admin')(user=apiuser): pass else: #make sure normal user does not pass someone else userid, #he is not allowed to do that if not isinstance(userid, Optional) and userid != apiuser.user_id: raise JSONRPCError( 'userid is not the same as your user' ) ret = [] if isinstance(userid, Optional): user = None else: user = get_user_or_error(userid) #show all locks for r in Repository.getAll(): userid, time_ = r.locked if time_: _api_data = r.get_api_data() # if we use userfilter just show the locks for this user if user: if safe_int(userid) == user.user_id: ret.append(_api_data) else: ret.append(_api_data) return ret
def update_repoinfo(cls, repositories=None): if not repositories: repositories = Repository.getAll() for repo in repositories: repo.update_changeset_cache()