Show More
@@ -33,22 +33,21 b' from rhodecode import forms' | |||
|
33 | 33 | from rhodecode.lib import helpers as h |
|
34 | 34 | from rhodecode.lib import audit_logger |
|
35 | 35 | from rhodecode.lib.ext_json import json |
|
36 | from rhodecode.lib.auth import LoginRequired, NotAnonymous, CSRFRequired, \ | |
|
37 | HasRepoPermissionAny, HasRepoGroupPermissionAny | |
|
36 | from rhodecode.lib.auth import ( | |
|
37 | LoginRequired, NotAnonymous, CSRFRequired, | |
|
38 | HasRepoPermissionAny, HasRepoGroupPermissionAny, AuthUser) | |
|
38 | 39 | from rhodecode.lib.channelstream import ( |
|
39 | 40 | channelstream_request, ChannelstreamException) |
|
40 | 41 | from rhodecode.lib.utils2 import safe_int, md5, str2bool |
|
41 | 42 | from rhodecode.model.auth_token import AuthTokenModel |
|
42 | 43 | from rhodecode.model.comment import CommentsModel |
|
43 | 44 | from rhodecode.model.db import ( |
|
44 |
IntegrityError, |
|
|
45 | IntegrityError, or_, in_filter_generator, | |
|
45 | 46 | Repository, UserEmailMap, UserApiKeys, UserFollowing, |
|
46 | 47 | PullRequest, UserBookmark, RepoGroup) |
|
47 | 48 | from rhodecode.model.meta import Session |
|
48 | 49 | from rhodecode.model.pull_request import PullRequestModel |
|
49 | from rhodecode.model.scm import RepoList | |
|
50 | 50 | from rhodecode.model.user import UserModel |
|
51 | from rhodecode.model.repo import RepoModel | |
|
52 | 51 | from rhodecode.model.user_group import UserGroupModel |
|
53 | 52 | from rhodecode.model.validation_schema.schemas import user_schema |
|
54 | 53 | |
@@ -345,23 +344,59 b' class MyAccountView(BaseAppView, DataGri' | |||
|
345 | 344 | 'You should see a new live message now.'} |
|
346 | 345 | |
|
347 | 346 | def _load_my_repos_data(self, watched=False): |
|
347 | ||
|
348 | allowed_ids = [-1] + self._rhodecode_user.repo_acl_ids_from_stack(AuthUser.repo_read_perms) | |
|
349 | ||
|
348 | 350 | if watched: |
|
349 | admin = False | |
|
350 |
|
|
|
351 | .filter(UserFollowing.user_id == self._rhodecode_user.user_id)\ | |
|
352 | .options(joinedload(UserFollowing.follows_repository))\ | |
|
351 | # repos user watch | |
|
352 | repo_list = Session().query( | |
|
353 | Repository | |
|
354 | ) \ | |
|
355 | .join( | |
|
356 | (UserFollowing, UserFollowing.follows_repo_id == Repository.repo_id) | |
|
357 | ) \ | |
|
358 | .filter( | |
|
359 | UserFollowing.user_id == self._rhodecode_user.user_id | |
|
360 | ) \ | |
|
361 | .filter(or_( | |
|
362 | # generate multiple IN to fix limitation problems | |
|
363 | *in_filter_generator(Repository.repo_id, allowed_ids)) | |
|
364 | ) \ | |
|
365 | .order_by(Repository.repo_name) \ | |
|
353 | 366 | .all() |
|
354 | repo_list = [x.follows_repository for x in follows_repos] | |
|
367 | ||
|
355 | 368 | else: |
|
356 | admin = True | |
|
357 |
repo_list = |
|
|
358 | user_id=self._rhodecode_user.user_id) | |
|
359 | repo_list = RepoList(repo_list, perm_set=[ | |
|
360 | 'repository.read', 'repository.write', 'repository.admin'], | |
|
361 |
|
|
|
369 | # repos user is owner of | |
|
370 | repo_list = Session().query( | |
|
371 | Repository | |
|
372 | ) \ | |
|
373 | .filter( | |
|
374 | Repository.user_id == self._rhodecode_user.user_id | |
|
375 | ) \ | |
|
376 | .filter(or_( | |
|
377 | # generate multiple IN to fix limitation problems | |
|
378 | *in_filter_generator(Repository.repo_id, allowed_ids)) | |
|
379 | ) \ | |
|
380 | .order_by(Repository.repo_name) \ | |
|
381 | .all() | |
|
362 | 382 | |
|
363 | repos_data = RepoModel().get_repos_as_dict( | |
|
364 | repo_list=repo_list, admin=admin, short_name=False) | |
|
383 | _render = self.request.get_partial_renderer( | |
|
384 | 'rhodecode:templates/data_table/_dt_elements.mako') | |
|
385 | ||
|
386 | def repo_lnk(name, rtype, rstate, private, archived, fork_of): | |
|
387 | return _render('repo_name', name, rtype, rstate, private, archived, fork_of, | |
|
388 | short_name=False, admin=False) | |
|
389 | ||
|
390 | repos_data = [] | |
|
391 | for repo in repo_list: | |
|
392 | row = { | |
|
393 | "name": repo_lnk(repo.repo_name, repo.repo_type, repo.repo_state, | |
|
394 | repo.private, repo.archived, repo.fork), | |
|
395 | "name_raw": repo.repo_name.lower(), | |
|
396 | } | |
|
397 | ||
|
398 | repos_data.append(row) | |
|
399 | ||
|
365 | 400 | # json used to render the grid |
|
366 | 401 | return json.dumps(repos_data) |
|
367 | 402 |
@@ -1051,6 +1051,8 b' class AuthUser(object):' | |||
|
1051 | 1051 | anonymous access is enabled and if so, it returns default user as logged in |
|
1052 | 1052 | """ |
|
1053 | 1053 | GLOBAL_PERMS = [x[0] for x in Permission.PERMS] |
|
1054 | repo_read_perms = ['repository.read', 'repository.admin', 'repository.write'] | |
|
1055 | repo_group_read_perms = ['group.read', 'group.write', 'group.admin'] | |
|
1054 | 1056 | |
|
1055 | 1057 | def __init__(self, user_id=None, api_key=None, username=None, ip_addr=None): |
|
1056 | 1058 |
@@ -40,8 +40,8 b'' | |||
|
40 | 40 | <li class="${h.is_active('external_identity', c.active)}"><a href="${my_account_external_url}">${_('External Identities')}</a></li> |
|
41 | 41 | % endif |
|
42 | 42 | |
|
43 | <li class="${h.is_active('repos', c.active)}"><a href="${h.route_path('my_account_repos')}">${_('Repositories')}</a></li> | |
|
44 | <li class="${h.is_active('watched', c.active)}"><a href="${h.route_path('my_account_watched')}">${_('Watched')}</a></li> | |
|
43 | <li class="${h.is_active('repos', c.active)}"><a href="${h.route_path('my_account_repos')}">${_('Owned Repositories')}</a></li> | |
|
44 | <li class="${h.is_active('watched', c.active)}"><a href="${h.route_path('my_account_watched')}">${_('Watched Repositories')}</a></li> | |
|
45 | 45 | <li class="${h.is_active('pullrequests', c.active)}"><a href="${h.route_path('my_account_pullrequests')}">${_('Pull Requests')}</a></li> |
|
46 | 46 | <li class="${h.is_active('perms', c.active)}"><a href="${h.route_path('my_account_perms')}">${_('Permissions')}</a></li> |
|
47 | 47 | <li class="${h.is_active('my_notifications', c.active)}"><a href="${h.route_path('my_account_notifications')}">${_('Live Notifications')}</a></li> |
@@ -15,13 +15,10 b'' | |||
|
15 | 15 | <script> |
|
16 | 16 | $(document).ready(function() { |
|
17 | 17 | |
|
18 | var get_datatable_count = function(){ | |
|
19 |
|
|
|
20 | $('#repo_count').text(api.page.info().recordsDisplay); | |
|
21 | }; | |
|
18 | // repo list | |
|
19 | $repoListTable = $('#repo_list_table'); | |
|
22 | 20 | |
|
23 | // repo list | |
|
24 | $('#repo_list_table').DataTable({ | |
|
21 | $repoListTable.DataTable({ | |
|
25 | 22 | data: ${c.data|n}, |
|
26 | 23 | dom: 'rtp', |
|
27 | 24 | pageLength: ${c.visual.admin_grid_items}, |
@@ -29,39 +26,23 b'' | |||
|
29 | 26 | columns: [ |
|
30 | 27 | { data: {"_": "name", |
|
31 | 28 | "sort": "name_raw"}, title: "${_('Name')}", className: "td-componentname" }, |
|
32 | { data: 'menu', className: "quick_repo_menu" }, | |
|
33 | { data: {"_": "last_changeset", | |
|
34 | "sort": "last_changeset_raw", | |
|
35 | "type": Number}, title: "${_('Commit')}", className: "td-hash" }, | |
|
36 | { data: {"_": "action", | |
|
37 | "sort": "action"}, title: "${_('Action')}", className: "td-action" } | |
|
38 | 29 | ], |
|
39 | 30 | language: { |
|
40 | 31 | paginate: DEFAULT_GRID_PAGINATION, |
|
41 | 32 | emptyTable: _gettext("No repositories available yet.") |
|
42 | 33 | }, |
|
43 | "initComplete": function( settings, json ) { | |
|
44 | get_datatable_count(); | |
|
45 | quick_repo_menu(); | |
|
46 | } | |
|
47 | }); | |
|
48 | 34 | |
|
49 | // update the counter when doing search | |
|
50 | $('#repo_list_table').on( 'search.dt', function (e,settings) { | |
|
51 | get_datatable_count(); | |
|
52 | 35 | }); |
|
53 | 36 | |
|
54 | // filter, filter both grids | |
|
55 |
$('#q_filter').on( |
|
|
56 | var repo_api = $('#repo_list_table').dataTable().api(); | |
|
57 | repo_api | |
|
58 | .columns(0) | |
|
59 | .search(this.value) | |
|
60 |
|
|
|
61 |
|
|
|
37 | // filter | |
|
38 | $('#q_filter').on('keyup', | |
|
39 | $.debounce(250, function() { | |
|
40 | $repoListTable.DataTable().search( | |
|
41 | $('#q_filter').val() | |
|
42 | ).draw(); | |
|
43 | }) | |
|
44 | ); | |
|
62 | 45 | |
|
63 | // refilter table if page load via back button | |
|
64 | $("#q_filter").trigger('keyup'); | |
|
65 | 46 | |
|
66 | 47 | }); |
|
67 | 48 |
@@ -15,13 +15,10 b'' | |||
|
15 | 15 | <script> |
|
16 | 16 | $(document).ready(function() { |
|
17 | 17 | |
|
18 | var get_datatable_count = function(){ | |
|
19 |
|
|
|
20 | $('#repo_count').text(api.page.info().recordsDisplay); | |
|
21 | }; | |
|
18 | // repo list | |
|
19 | $repoListTable = $('#repo_list_table'); | |
|
22 | 20 | |
|
23 | // repo list | |
|
24 | $('#repo_list_table').DataTable({ | |
|
21 | $repoListTable.DataTable({ | |
|
25 | 22 | data: ${c.data|n}, |
|
26 | 23 | dom: 'rtp', |
|
27 | 24 | pageLength: ${c.visual.admin_grid_items}, |
@@ -29,37 +26,23 b'' | |||
|
29 | 26 | columns: [ |
|
30 | 27 | { data: {"_": "name", |
|
31 | 28 | "sort": "name_raw"}, title: "${_('Name')}", className: "td-componentname" }, |
|
32 | { data: 'menu', className: "quick_repo_menu" }, | |
|
33 | { data: {"_": "last_changeset", | |
|
34 | "sort": "last_changeset_raw", | |
|
35 | "type": Number}, title: "${_('Commit')}", className: "td-hash" } | |
|
36 | 29 | ], |
|
37 | 30 | language: { |
|
38 | 31 | paginate: DEFAULT_GRID_PAGINATION, |
|
39 | 32 | emptyTable: _gettext("No repositories available yet.") |
|
40 | 33 | }, |
|
41 | "initComplete": function( settings, json ) { | |
|
42 | get_datatable_count(); | |
|
43 | quick_repo_menu(); | |
|
44 | } | |
|
45 | }); | |
|
46 | 34 | |
|
47 | // update the counter when doing search | |
|
48 | $('#repo_list_table').on( 'search.dt', function (e,settings) { | |
|
49 | get_datatable_count(); | |
|
50 | 35 | }); |
|
51 | 36 | |
|
52 | // filter, filter both grids | |
|
53 |
$('#q_filter').on( |
|
|
54 | var repo_api = $('#repo_list_table').dataTable().api(); | |
|
55 | repo_api | |
|
56 | .columns(0) | |
|
57 | .search(this.value) | |
|
58 |
|
|
|
59 |
|
|
|
37 | // filter | |
|
38 | $('#q_filter').on('keyup', | |
|
39 | $.debounce(250, function() { | |
|
40 | $repoListTable.DataTable().search( | |
|
41 | $('#q_filter').val() | |
|
42 | ).draw(); | |
|
43 | }) | |
|
44 | ); | |
|
60 | 45 | |
|
61 | // refilter table if page load via back button | |
|
62 | $("#q_filter").trigger('keyup'); | |
|
63 | 46 | |
|
64 | 47 | }); |
|
65 | 48 |
General Comments 0
You need to be logged in to leave comments.
Login now