Show More
@@ -35,7 +35,7 b' from rhodecode.lib import hooks_base' | |||||
35 | from rhodecode.lib.utils2 import safe_int, str2bool, aslist |
|
35 | from rhodecode.lib.utils2 import safe_int, str2bool, aslist | |
36 | from rhodecode.lib.statsd_client import StatsdClient |
|
36 | from rhodecode.lib.statsd_client import StatsdClient | |
37 | from rhodecode.model.db import ( |
|
37 | from rhodecode.model.db import ( | |
38 |
Session, IntegrityError |
|
38 | true, null, Session, IntegrityError, Repository, RepoGroup, User) | |
39 | from rhodecode.model.permission import PermissionModel |
|
39 | from rhodecode.model.permission import PermissionModel | |
40 |
|
40 | |||
41 |
|
41 | |||
@@ -393,7 +393,7 b' def sync_last_update_for_objects(*args, ' | |||||
393 | skip_groups = kwargs.get('skip_groups') |
|
393 | skip_groups = kwargs.get('skip_groups') | |
394 | if not skip_groups: |
|
394 | if not skip_groups: | |
395 | repo_groups = RepoGroup.query() \ |
|
395 | repo_groups = RepoGroup.query() \ | |
396 |
.filter(RepoGroup.group_parent_id == |
|
396 | .filter(RepoGroup.group_parent_id == null()) | |
397 |
|
397 | |||
398 | for root_gr in repo_groups: |
|
398 | for root_gr in repo_groups: | |
399 | for repo_gr in reversed(root_gr.recursive_groups()): |
|
399 | for repo_gr in reversed(root_gr.recursive_groups()): |
@@ -23,7 +23,7 b' import collections' | |||||
23 |
|
23 | |||
24 | from rhodecode.model import BaseModel |
|
24 | from rhodecode.model import BaseModel | |
25 | from rhodecode.model.db import ( |
|
25 | from rhodecode.model.db import ( | |
26 | ChangesetStatus, ChangesetComment, PullRequest, PullRequestReviewers, Session) |
|
26 | null, ChangesetStatus, ChangesetComment, PullRequest, PullRequestReviewers, Session) | |
27 | from rhodecode.lib.exceptions import StatusChangeOnClosedPullRequestError |
|
27 | from rhodecode.lib.exceptions import StatusChangeOnClosedPullRequestError | |
28 | from rhodecode.lib.markup_renderer import ( |
|
28 | from rhodecode.lib.markup_renderer import ( | |
29 | DEFAULT_COMMENTS_RENDERER, RstTemplateRenderer) |
|
29 | DEFAULT_COMMENTS_RENDERER, RstTemplateRenderer) | |
@@ -60,7 +60,7 b' class ChangesetStatusModel(BaseModel):' | |||||
60 | # the pull_request_version_id. |
|
60 | # the pull_request_version_id. | |
61 | q = q.join(ChangesetComment).filter( |
|
61 | q = q.join(ChangesetComment).filter( | |
62 | ChangesetStatus.pull_request == pull_request, |
|
62 | ChangesetStatus.pull_request == pull_request, | |
63 |
ChangesetComment.pull_request_version_id == |
|
63 | ChangesetComment.pull_request_version_id == null()) | |
64 | else: |
|
64 | else: | |
65 | raise Exception('Please specify revision or pull_request') |
|
65 | raise Exception('Please specify revision or pull_request') | |
66 | q = q.order_by(ChangesetStatus.version.asc()) |
|
66 | q = q.order_by(ChangesetStatus.version.asc()) |
@@ -151,7 +151,7 b' class CommentsModel(BaseModel):' | |||||
151 | def get_repository_unresolved_todos(self, repo): |
|
151 | def get_repository_unresolved_todos(self, repo): | |
152 | todos = Session().query(ChangesetComment) \ |
|
152 | todos = Session().query(ChangesetComment) \ | |
153 | .filter(ChangesetComment.repo == repo) \ |
|
153 | .filter(ChangesetComment.repo == repo) \ | |
154 |
.filter(ChangesetComment.resolved_by == |
|
154 | .filter(ChangesetComment.resolved_by == null()) \ | |
155 | .filter(ChangesetComment.comment_type |
|
155 | .filter(ChangesetComment.comment_type | |
156 | == ChangesetComment.COMMENT_TYPE_TODO) |
|
156 | == ChangesetComment.COMMENT_TYPE_TODO) | |
157 | todos = todos.all() |
|
157 | todos = todos.all() | |
@@ -162,7 +162,7 b' class CommentsModel(BaseModel):' | |||||
162 |
|
162 | |||
163 | todos = Session().query(ChangesetComment) \ |
|
163 | todos = Session().query(ChangesetComment) \ | |
164 | .filter(ChangesetComment.pull_request == pull_request) \ |
|
164 | .filter(ChangesetComment.pull_request == pull_request) \ | |
165 |
.filter(ChangesetComment.resolved_by == |
|
165 | .filter(ChangesetComment.resolved_by == null()) \ | |
166 | .filter(ChangesetComment.comment_type |
|
166 | .filter(ChangesetComment.comment_type | |
167 | == ChangesetComment.COMMENT_TYPE_TODO) |
|
167 | == ChangesetComment.COMMENT_TYPE_TODO) | |
168 |
|
168 | |||
@@ -209,7 +209,7 b' class CommentsModel(BaseModel):' | |||||
209 |
|
209 | |||
210 | todos = Session().query(ChangesetComment) \ |
|
210 | todos = Session().query(ChangesetComment) \ | |
211 | .filter(ChangesetComment.revision == commit_id) \ |
|
211 | .filter(ChangesetComment.revision == commit_id) \ | |
212 |
.filter(ChangesetComment.resolved_by == |
|
212 | .filter(ChangesetComment.resolved_by == null()) \ | |
213 | .filter(ChangesetComment.comment_type |
|
213 | .filter(ChangesetComment.comment_type | |
214 | == ChangesetComment.COMMENT_TYPE_TODO) |
|
214 | == ChangesetComment.COMMENT_TYPE_TODO) | |
215 |
|
215 | |||
@@ -635,8 +635,8 b' class CommentsModel(BaseModel):' | |||||
635 |
|
635 | |||
636 | q = ChangesetComment.query()\ |
|
636 | q = ChangesetComment.query()\ | |
637 | .filter(ChangesetComment.repo_id == repo_id)\ |
|
637 | .filter(ChangesetComment.repo_id == repo_id)\ | |
638 |
.filter(ChangesetComment.line_no == |
|
638 | .filter(ChangesetComment.line_no == null())\ | |
639 |
.filter(ChangesetComment.f_path == |
|
639 | .filter(ChangesetComment.f_path == null()) | |
640 | if revision: |
|
640 | if revision: | |
641 | q = q.filter(ChangesetComment.revision == revision) |
|
641 | q = q.filter(ChangesetComment.revision == revision) | |
642 | elif pull_request: |
|
642 | elif pull_request: | |
@@ -780,15 +780,15 b' class CommentsModel(BaseModel):' | |||||
780 |
|
780 | |||
781 | def _all_inline_comments_of_pull_request(self, pull_request): |
|
781 | def _all_inline_comments_of_pull_request(self, pull_request): | |
782 | comments = Session().query(ChangesetComment)\ |
|
782 | comments = Session().query(ChangesetComment)\ | |
783 |
.filter(ChangesetComment.line_no != |
|
783 | .filter(ChangesetComment.line_no != null())\ | |
784 |
.filter(ChangesetComment.f_path != |
|
784 | .filter(ChangesetComment.f_path != null())\ | |
785 | .filter(ChangesetComment.pull_request == pull_request) |
|
785 | .filter(ChangesetComment.pull_request == pull_request) | |
786 | return comments |
|
786 | return comments | |
787 |
|
787 | |||
788 | def _all_general_comments_of_pull_request(self, pull_request): |
|
788 | def _all_general_comments_of_pull_request(self, pull_request): | |
789 | comments = Session().query(ChangesetComment)\ |
|
789 | comments = Session().query(ChangesetComment)\ | |
790 |
.filter(ChangesetComment.line_no == |
|
790 | .filter(ChangesetComment.line_no == null())\ | |
791 |
.filter(ChangesetComment.f_path == |
|
791 | .filter(ChangesetComment.f_path == null())\ | |
792 | .filter(ChangesetComment.pull_request == pull_request) |
|
792 | .filter(ChangesetComment.pull_request == pull_request) | |
793 |
|
793 | |||
794 | return comments |
|
794 | return comments |
@@ -122,12 +122,12 b' class IntegrationModel(BaseModel):' | |||||
122 | elif scope == 'global': |
|
122 | elif scope == 'global': | |
123 | # global integrations |
|
123 | # global integrations | |
124 | query = self.sa.query(Integration).filter( |
|
124 | query = self.sa.query(Integration).filter( | |
125 |
and_(Integration.repo_id == |
|
125 | and_(Integration.repo_id == null(), Integration.repo_group_id == null()) | |
126 | ) |
|
126 | ) | |
127 | elif scope == 'root-repos': |
|
127 | elif scope == 'root-repos': | |
128 | query = self.sa.query(Integration).filter( |
|
128 | query = self.sa.query(Integration).filter( | |
129 |
and_(Integration.repo_id == |
|
129 | and_(Integration.repo_id == null(), | |
130 |
Integration.repo_group_id == |
|
130 | Integration.repo_group_id == null(), | |
131 | Integration.child_repos_only == true()) |
|
131 | Integration.child_repos_only == true()) | |
132 | ) |
|
132 | ) | |
133 | elif scope == 'all': |
|
133 | elif scope == 'all': |
@@ -1316,7 +1316,7 b' class PullRequestModel(BaseModel):' | |||||
1316 | # to either the source repo, the target repo or no repo at all. |
|
1316 | # to either the source repo, the target repo or no repo at all. | |
1317 | ChangesetComment.repo_id == pull_request.target_repo.repo_id, |
|
1317 | ChangesetComment.repo_id == pull_request.target_repo.repo_id, | |
1318 | ChangesetComment.pull_request == pull_request, |
|
1318 | ChangesetComment.pull_request == pull_request, | |
1319 |
ChangesetComment.pull_request_version == |
|
1319 | ChangesetComment.pull_request_version == null())\ | |
1320 | .order_by(ChangesetComment.comment_id.asc()) |
|
1320 | .order_by(ChangesetComment.comment_id.asc()) | |
1321 |
|
1321 | |||
1322 | # TODO: johbo: Find out why this breaks if it is done in a bulk |
|
1322 | # TODO: johbo: Find out why this breaks if it is done in a bulk |
@@ -46,7 +46,7 b' from rhodecode.lib.str_utils import safe' | |||||
46 | from rhodecode.lib.system_info import get_system_info |
|
46 | from rhodecode.lib.system_info import get_system_info | |
47 | from rhodecode.model import BaseModel |
|
47 | from rhodecode.model import BaseModel | |
48 | from rhodecode.model.db import ( |
|
48 | from rhodecode.model.db import ( | |
49 | or_, false, |
|
49 | or_, false, null, | |
50 | Repository, CacheKey, UserFollowing, UserLog, User, RepoGroup, |
|
50 | Repository, CacheKey, UserFollowing, UserLog, User, RepoGroup, | |
51 | PullRequest, FileStore) |
|
51 | PullRequest, FileStore) | |
52 | from rhodecode.model.settings import VcsSettingsModel |
|
52 | from rhodecode.model.settings import VcsSettingsModel | |
@@ -249,7 +249,7 b' class ScmModel(BaseModel):' | |||||
249 | """ |
|
249 | """ | |
250 | if all_repos is None: |
|
250 | if all_repos is None: | |
251 | all_repos = self.sa.query(Repository)\ |
|
251 | all_repos = self.sa.query(Repository)\ | |
252 |
.filter(Repository.group_id == |
|
252 | .filter(Repository.group_id == null())\ | |
253 | .order_by(func.lower(Repository.repo_name)).all() |
|
253 | .order_by(func.lower(Repository.repo_name)).all() | |
254 | repo_iter = SimpleCachedRepoList( |
|
254 | repo_iter = SimpleCachedRepoList( | |
255 | all_repos, repos_path=self.repos_path, order_by=sort_key) |
|
255 | all_repos, repos_path=self.repos_path, order_by=sort_key) | |
@@ -258,7 +258,7 b' class ScmModel(BaseModel):' | |||||
258 | def get_repo_groups(self, all_groups=None): |
|
258 | def get_repo_groups(self, all_groups=None): | |
259 | if all_groups is None: |
|
259 | if all_groups is None: | |
260 | all_groups = RepoGroup.query()\ |
|
260 | all_groups = RepoGroup.query()\ | |
261 |
.filter(RepoGroup.group_parent_id == |
|
261 | .filter(RepoGroup.group_parent_id == null()).all() | |
262 | return [x for x in RepoGroupList(all_groups)] |
|
262 | return [x for x in RepoGroupList(all_groups)] | |
263 |
|
263 | |||
264 | def mark_for_invalidation(self, repo_name, delete=False): |
|
264 | def mark_for_invalidation(self, repo_name, delete=False): | |
@@ -371,7 +371,7 b' class ScmModel(BaseModel):' | |||||
371 | repo = self._get_repo(repo) |
|
371 | repo = self._get_repo(repo) | |
372 | return self.sa.query(FileStore)\ |
|
372 | return self.sa.query(FileStore)\ | |
373 | .filter(FileStore.repo == repo)\ |
|
373 | .filter(FileStore.repo == repo)\ | |
374 |
.filter(or_(FileStore.hidden == |
|
374 | .filter(or_(FileStore.hidden == null(), FileStore.hidden == false())).count() | |
375 |
|
375 | |||
376 | def mark_as_fork(self, repo, fork, user): |
|
376 | def mark_as_fork(self, repo, fork, user): | |
377 | repo = self._get_repo(repo) |
|
377 | repo = self._get_repo(repo) |
General Comments 0
You need to be logged in to leave comments.
Login now