Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
fix bug 882446, 882444 - Add user ban links
Browse files Browse the repository at this point in the history
  • Loading branch information
darkwing committed Jun 13, 2013
1 parent 89be3a8 commit 67607cb
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 8 deletions.
5 changes: 4 additions & 1 deletion apps/dashboards/templates/dashboards/revisions.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ <h3>{{ _('Revision Filter') }}</h3>
<li> <a id="view" href="#">{{ _('View Page') }}</a> </li>
<li class="page-edit"> <a id="edit" href="#">{{ _('Edit Page') }}</a> </li>
<li class="page-history"> <a id="history" href="#">{{ _('History') }}</a> </li>
<li id="ban-user"></li>
</ul>
</section>

Expand Down Expand Up @@ -169,7 +170,8 @@ <h2>{{ _('Revision Diff') }}</h2>
$revertLink = $('a#revert'),
$viewLink = $('a#view'),
$editLink = $('a#edit'),
$historyLink = $('a#history');
$historyLink = $('a#history'),
$banUserItem = $('#ban-user');

if(e.target.tagName == 'A') return;

Expand All @@ -194,6 +196,7 @@ <h2>{{ _('Revision Diff') }}</h2>
$viewLink.attr('href', data.doc_url);
$editLink.attr('href', data.edit_url);
$historyLink.attr('href', data.history_url);
$banUserItem.html(data.ban_link);
}
});
}
Expand Down
6 changes: 5 additions & 1 deletion apps/dashboards/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
from sumo.parser import get_object_fallback
from sumo.urlresolvers import reverse
from sumo.utils import smart_int

from users.helpers import ban_link

from wiki.events import (ApproveRevisionInLocaleEvent,
ReviewableRevisionInLocaleEvent)
from wiki.models import Document, Revision
Expand Down Expand Up @@ -222,7 +225,8 @@ def revisions(request):
'title': rev.title,
'richTitle': richTitle,
'date': rev.created.strftime('%b %d, %y - %H:%M'),
'slug': rev.document.slug
'slug': rev.document.slug,
'ban_link': ban_link(rev.creator, request.user)
})

result = json.dumps(revision_json)
Expand Down
5 changes: 3 additions & 2 deletions apps/devmo/templates/devmo/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,13 @@ <h2>{{_("Areas of Expertise")}}</h2>
</div>

<!-- Only shown for the user and admins -->
<p class="edit">
{% if profile.allows_editing_by(request.user) %}
<p class="edit">
<a href="{{ url('authkeys.list') }}" class="button">{{_("Manage API Keys")}}</a>
<a id="edit-profile" href="{{ url('devmo.views.profile_edit', username=profile.user.username) }}" class="button">{{_("Edit Profile")}}</a>
</p>
{% endif %}
{{ ban_link(profile.user, request.user) }}
</p>
</section>

{% if demos_page.object_list | length > 0 %}
Expand Down
11 changes: 11 additions & 0 deletions apps/users/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from jinja2 import escape, Markup
from jingo import register

from tower import ugettext as _

from sumo.urlresolvers import reverse


Expand Down Expand Up @@ -35,6 +37,15 @@ def display_name(user):
return user.username
return profile.fullname if profile.fullname else user.username

@register.function
def ban_link(ban_user, banner_user):
"""Returns a link to ban a user"""

link = ''
if ban_user.id != banner_user.id and banner_user.has_perm('users.add_userban'):
url = '%s?user=%s&by=%s' % (reverse('admin:users_userban_add'), ban_user.id, banner_user.id)
link = '<a href="%s" class="button ban-link">%s</a>' % (url, _('Ban User'))
return Markup(link)

@register.filter
def public_email(email):
Expand Down
5 changes: 1 addition & 4 deletions apps/wiki/templates/wiki/revision.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ <h1 class="title">{{ document.title }}</h1>
<li>
<mark>{{ _('Creator:') }}</mark>
<span>{{ revision.creator }}</span>

{% if user.has_perm('users.add_userban') and revision.creator != request.user %}
(<a href="{{ url('admin:users_userban_add') }}?user={{revision.creator.id}}&by={{request.user.id}}">Ban user</a>)
{% endif %}
{{ ban_link(revision.creator, request.user) }}
</li>
<li class="revision-is-reviewed">
<mark>{{ _('Is reviewed?') }}</mark>
Expand Down
2 changes: 2 additions & 0 deletions media/css/wiki-screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ a.edit-section:hover, a.edit-section:active, a.edit-section:focus { color: #333;
#page-buttons .page-watch input:hover, #page-buttons .page-watch a:focus, #page-buttons .page-watch a:active { background-color: #f8daa9; text-decoration: none; }
#page-buttons .page-watch input.disabled { cursor: pointer; opacity: .75; background-color: #f0e4c7; }

#action-bar .ban-link { background-image: none; }

.btn-save {
background: #d7eca1;
background: -moz-linear-gradient(top, #d7eca1 0, #cce390 100%);
Expand Down

0 comments on commit 67607cb

Please sign in to comment.