##// 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 391 # Interim workaround if the user participated on any pull requests as a
392 392 # reviewer.
393 has_review = bool(PullRequestReviewers.query().filter(
394 PullRequestReviewers.user_id == user_id).first())
393 has_review = len(user.reviewer_pull_requests)
395 394 c.can_delete_user = not has_review
396 c.can_delete_user_message = _(
397 'The user participates as reviewer in pull requests and '
398 'cannot be deleted. You can set the user to '
399 '"inactive" instead of deleting it.') if has_review else ''
395 c.can_delete_user_message = ''
396 inactive_link = h.link_to(
397 'inactive', h.url('edit_user', user_id=user_id, anchor='active'))
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 411 return htmlfill.render(
402 412 render('admin/users/user_edit.mako'),
@@ -606,6 +606,13 b' class User(Base, BaseModel):'
606 606 self._api_key = None
607 607
608 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 616 def firstname(self):
610 617 # alias for future
611 618 return self.name
@@ -285,6 +285,9 b' input.inline[type="file"] {'
285 285 margin: 0 0 @padding;
286 286 padding:.5em;
287 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 1808 .help-block {
1806 1809 margin: @padding 0;
1807 1810 color: @text-color;
1811 &.pre-formatting {
1812 white-space: pre;
1813 }
1808 1814 }
1809 1815
1810 1816 .empty_data {
@@ -533,6 +533,9 b' address {'
533 533 margin: 0 0 @padding;
534 534 color: @grey4;
535 535 font-family: @text-light;
536 &.pre-formatting {
537 white-space: pre;
538 }
536 539 }
537 540
538 541 .error-message {
@@ -12,6 +12,7 b''
12 12 (_('Repository groups'), len(c.user.repository_groups), '', [x.group_name for x in c.user.repository_groups]),
13 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 16 (_('Member of User groups'), len(c.user.group_member), '', [x.users_group.users_group_name for x in c.user.group_member]),
16 17 (_('Force password change'), c.user.user_data.get('force_password_change', 'False'), '', ''),
17 18 ]
@@ -142,7 +143,7 b''
142 143 </button>
143 144 </div>
144 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 147 % endif
147 148
148 149 <div class="field">
General Comments 0
You need to be logged in to leave comments. Login now