##// END OF EJS Templates
users: add additional information why user with pending reviews shouldn't be deleted.
dan -
r1923:4a76cf6b default
parent child Browse files
Show More
@@ -390,13 +390,23 b' class UsersController(BaseController):'
390
390
391 # Interim workaround if the user participated on any pull requests as a
391 # Interim workaround if the user participated on any pull requests as a
392 # reviewer.
392 # reviewer.
393 has_review = bool(PullRequestReviewers.query().filter(
393 has_review = len(user.reviewer_pull_requests)
394 PullRequestReviewers.user_id == user_id).first())
395 c.can_delete_user = not has_review
394 c.can_delete_user = not has_review
396 c.can_delete_user_message = _(
395 c.can_delete_user_message = ''
397 'The user participates as reviewer in pull requests and '
396 inactive_link = h.link_to(
398 'cannot be deleted. You can set the user to '
397 'inactive', h.url('edit_user', user_id=user_id, anchor='active'))
399 '"inactive" instead of deleting it.') if has_review else ''
398 if has_review == 1:
399 c.can_delete_user_message = h.literal(_(
400 'The user participates as reviewer in {} pull request and '
401 'cannot be deleted. \nYou can set the user to '
402 '"{}" instead of deleting it.').format(
403 has_review, inactive_link))
404 elif has_review:
405 c.can_delete_user_message = h.literal(_(
406 'The user participates as reviewer in {} pull requests and '
407 'cannot be deleted. \nYou can set the user to '
408 '"{}" instead of deleting it.').format(
409 has_review, inactive_link))
400
410
401 return htmlfill.render(
411 return htmlfill.render(
402 render('admin/users/user_edit.mako'),
412 render('admin/users/user_edit.mako'),
@@ -606,6 +606,13 b' class User(Base, BaseModel):'
606 self._api_key = None
606 self._api_key = None
607
607
608 @property
608 @property
609 def reviewer_pull_requests(self):
610 return PullRequestReviewers.query() \
611 .options(joinedload(PullRequestReviewers.pull_request)) \
612 .filter(PullRequestReviewers.user_id == self.user_id) \
613 .all()
614
615 @property
609 def firstname(self):
616 def firstname(self):
610 # alias for future
617 # alias for future
611 return self.name
618 return self.name
@@ -285,6 +285,9 b' input.inline[type="file"] {'
285 margin: 0 0 @padding;
285 margin: 0 0 @padding;
286 padding:.5em;
286 padding:.5em;
287 background-color: @grey6;
287 background-color: @grey6;
288 &.pre-formatting {
289 white-space: pre;
290 }
288 }
291 }
289 }
292 }
290
293
@@ -1805,6 +1808,9 b' BIN_FILENODE = 7'
1805 .help-block {
1808 .help-block {
1806 margin: @padding 0;
1809 margin: @padding 0;
1807 color: @text-color;
1810 color: @text-color;
1811 &.pre-formatting {
1812 white-space: pre;
1813 }
1808 }
1814 }
1809
1815
1810 .empty_data {
1816 .empty_data {
@@ -533,6 +533,9 b' address {'
533 margin: 0 0 @padding;
533 margin: 0 0 @padding;
534 color: @grey4;
534 color: @grey4;
535 font-family: @text-light;
535 font-family: @text-light;
536 &.pre-formatting {
537 white-space: pre;
538 }
536 }
539 }
537
540
538 .error-message {
541 .error-message {
@@ -12,6 +12,7 b''
12 (_('Repository groups'), len(c.user.repository_groups), '', [x.group_name for x in c.user.repository_groups]),
12 (_('Repository groups'), len(c.user.repository_groups), '', [x.group_name for x in c.user.repository_groups]),
13 (_('User groups'), len(c.user.user_groups), '', [x.users_group_name for x in c.user.user_groups]),
13 (_('User groups'), len(c.user.user_groups), '', [x.users_group_name for x in c.user.user_groups]),
14
14
15 (_('Reviewer of pull requests'), len(c.user.reviewer_pull_requests), '', ['Pull Request #{}'.format(x.pull_request.pull_request_id) for x in c.user.reviewer_pull_requests]),
15 (_('Member of User groups'), len(c.user.group_member), '', [x.users_group.users_group_name for x in c.user.group_member]),
16 (_('Member of User groups'), len(c.user.group_member), '', [x.users_group.users_group_name for x in c.user.group_member]),
16 (_('Force password change'), c.user.user_data.get('force_password_change', 'False'), '', ''),
17 (_('Force password change'), c.user.user_data.get('force_password_change', 'False'), '', ''),
17 ]
18 ]
@@ -142,7 +143,7 b''
142 </button>
143 </button>
143 </div>
144 </div>
144 % if c.can_delete_user_message:
145 % if c.can_delete_user_message:
145 <p class="help-block">${c.can_delete_user_message}</p>
146 <p class="help-block pre-formatting">${c.can_delete_user_message}</p>
146 % endif
147 % endif
147
148
148 <div class="field">
149 <div class="field">
General Comments 0
You need to be logged in to leave comments. Login now