def _prepare_get_all_query(self, repo_name, source=False, statuses=None, opened_by=None, order_by=None, order_dir='desc'): repo = self._get_repo(repo_name) q = PullRequest.query() # source or target if source: q = q.filter(PullRequest.source_repo == repo) else: q = q.filter(PullRequest.target_repo == repo) # closed,opened if statuses: q = q.filter(PullRequest.status.in_(statuses)) # opened by filter if opened_by: q = q.filter(PullRequest.user_id.in_(opened_by)) if order_by: order_map = { 'name_raw': PullRequest.pull_request_id, 'title': PullRequest.title, 'updated_on_raw': PullRequest.updated_on } if order_dir == 'asc': q = q.order_by(order_map[order_by].asc()) else: q = q.order_by(order_map[order_by].desc()) return q
def my_account_my_pullrequests(self): c.my_pull_requests = PullRequest.query()\ .filter(PullRequest.user_id== self.rhodecode_user.user_id)\ .all() c.participate_in_pull_requests = \ [x.pull_request for x in PullRequestReviewers.query()\ .filter(PullRequestReviewers.user_id== self.rhodecode_user.user_id)\ .all()] return render('admin/users/user_edit_my_account_pullrequests.html')
def get_all(self, repo_name, from_=False, closed=False): """Get all PRs for repo. Default is all PRs to the repo, PRs from the repo if from_. Closed PRs are only included if closed is true.""" repo = self._get_repo(repo_name) q = PullRequest.query() if from_: q = q.filter(PullRequest.org_repo == repo) else: q = q.filter(PullRequest.other_repo == repo) if not closed: q = q.filter(PullRequest.status != PullRequest.STATUS_CLOSED) return q.order_by(PullRequest.created_on.desc()).all()
def my_account_my_pullrequests(self): c.show_closed = request.GET.get('pr_show_closed') def _filter(pr): s = sorted(pr, key=lambda o: o.created_on, reverse=True) if not c.show_closed: s = filter(lambda p: p.status != PullRequest.STATUS_CLOSED, s) return s c.my_pull_requests = _filter(PullRequest.query()\ .filter(PullRequest.user_id == self.rhodecode_user.user_id)\ .all()) c.participate_in_pull_requests = _filter([ x.pull_request for x in PullRequestReviewers.query()\ .filter(PullRequestReviewers.user_id == self.rhodecode_user.user_id).all()]) return render('admin/users/user_edit_my_account_pullrequests.html')
def my_account_pullrequests(self): c.active = 'pullrequests' self.__load_data() c.show_closed = request.GET.get('pr_show_closed') def _filter(pr): s = sorted(pr, key=lambda o: o.created_on, reverse=True) if not c.show_closed: s = filter(lambda p: p.status != PullRequest.STATUS_CLOSED, s) return s c.my_pull_requests = _filter(PullRequest.query().filter( PullRequest.user_id == c.rhodecode_user.user_id).all()) my_prs = [ x.pull_request for x in PullRequestReviewers.query().filter( PullRequestReviewers.user_id == c.rhodecode_user.user_id).all() ] c.participate_in_pull_requests = _filter(my_prs) return render('admin/my_account/my_account.html')
def get_all(self, repo): repo = self._get_repo(repo) return PullRequest.query()\ .filter(PullRequest.other_repo == repo)\ .order_by(PullRequest.created_on.desc())\ .all()
def get_all(self, repo): repo = self._get_repo(repo) return PullRequest.query().filter(PullRequest.other_repo == repo).all()