add in link, decorator and normalize url (bug 740888)
This commit is contained in:
Родитель
53c73134aa
Коммит
d3a591f25c
|
@ -3,7 +3,7 @@
|
|||
{% set title = _('Report Abuse') %}
|
||||
{% block title %}
|
||||
{# L10n: {0} is the name of the user. #}
|
||||
{{ mkt_page_title(_('Report abuse for {0}')|f(user.name)) }}
|
||||
{{ mkt_page_title(_('Report abuse for {0}')|f(profile.name)) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@ -24,8 +24,7 @@
|
|||
{% include 'site/helpers/abuse.html' %}
|
||||
<p class="form-footer">
|
||||
<button type="submit">{{ _('Send Report') }}</button> {{ _('or') }}
|
||||
{# TODO: bounce to somewhere more useful #}
|
||||
<a href="/">{{ _('Cancel') }}</a>
|
||||
<a href="{{ url('users.profile', profile.username) }}">{{ _('Cancel') }}</a>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -859,4 +859,6 @@ class TestAbuse(amo.tests.TestCase):
|
|||
res = self.client.post(self.url, data={'text':'test', 'recaptcha': '',
|
||||
'recaptcha_shown': ''})
|
||||
eq_(res.status_code, 302)
|
||||
self.assertRedirects(res, reverse('users.profile',
|
||||
args=[self.user.username]))
|
||||
eq_(AbuseReport.objects.filter(user=self.user).count(), 1)
|
||||
|
|
|
@ -36,10 +36,8 @@ users_patterns = patterns('',
|
|||
# Keeping the same URL pattern since admin pages already know about this.
|
||||
url(r'^(?:(?P<user_id>\d+)/)?edit$', views.admin_edit,
|
||||
name='users.admin_edit'),
|
||||
url(r'''(?P<username>[^/<>"']+)$''', views.profile,
|
||||
url(r'''^(?P<username>[^/<>"']+)$''', views.profile,
|
||||
name='users.profile'),
|
||||
)
|
||||
|
||||
abuse_patterns = patterns('',
|
||||
url(r'^abuse$', views.abuse, name='users.abuse')
|
||||
url(r'''^(?P<username>[^/<>"']+)/abuse$''', views.abuse,
|
||||
name='users.abuse')
|
||||
)
|
||||
|
|
|
@ -29,6 +29,7 @@ from users.views import logout
|
|||
from mkt.account.forms import CurrencyForm
|
||||
from mkt.site import messages
|
||||
from . import forms
|
||||
from .decorators import profile_view
|
||||
from .utils import purchase_list
|
||||
|
||||
log = commonware.log.getLogger('mkt.account')
|
||||
|
@ -258,12 +259,8 @@ def delete_photo(request):
|
|||
return http.HttpResponse()
|
||||
|
||||
|
||||
def profile(request, username):
|
||||
if username.isdigit():
|
||||
user = get_object_or_404(UserProfile, id=username)
|
||||
else:
|
||||
user = get_object_or_404(UserProfile, username=username)
|
||||
|
||||
@profile_view
|
||||
def profile(request, user):
|
||||
edit_any_user = acl.action_allowed(request, 'Users', 'Edit')
|
||||
own_profile = (request.user.is_authenticated() and
|
||||
request.amo_user.id == user.id)
|
||||
|
@ -292,16 +289,13 @@ def activity_log(request, userid):
|
|||
|
||||
|
||||
@anonymous_csrf_exempt
|
||||
def abuse(request, user_id):
|
||||
user = get_object_or_404(UserProfile, pk=user_id)
|
||||
@profile_view
|
||||
def abuse(request, profile):
|
||||
form = AbuseForm(request.POST or None, request=request)
|
||||
if request.method == 'POST' and form.is_valid():
|
||||
send_abuse_report(request, user, form.cleaned_data['text'])
|
||||
send_abuse_report(request, profile, form.cleaned_data['text'])
|
||||
messages.success(request, _('Abuse reported.'))
|
||||
# We don't have a profile page to redirect back to. Once the abuse
|
||||
# is reported, that would be the place I'd recommend redirecting
|
||||
# back to.
|
||||
return redirect('/')
|
||||
return redirect(reverse('users.profile', args=[profile.username]))
|
||||
else:
|
||||
return jingo.render(request, 'account/abuse.html',
|
||||
{'user': user, 'abuse_form': form})
|
||||
{'abuse_form': form, 'profile': profile})
|
||||
|
|
|
@ -9,8 +9,7 @@ import amo
|
|||
from apps.users.views import logout
|
||||
from apps.users.urls import (detail_patterns as user_detail_patterns,
|
||||
users_patterns as users_users_patterns)
|
||||
from mkt.account.urls import (abuse_patterns, purchases_patterns,
|
||||
settings_patterns,
|
||||
from mkt.account.urls import (purchases_patterns, settings_patterns,
|
||||
users_patterns as mkt_users_patterns)
|
||||
from mkt.developers.views import login
|
||||
from mkt.purchase.urls import bluevia_services_patterns
|
||||
|
@ -65,8 +64,6 @@ urlpatterns = patterns('',
|
|||
# Support (e.g., refunds, FAQs).
|
||||
('^support/', include('mkt.support.urls')),
|
||||
|
||||
# Override the legacy abuse page for one that works.
|
||||
('^user/(?P<user_id>\d+)/', include(abuse_patterns)),
|
||||
# Users (Legacy).
|
||||
('^user/(?P<user_id>\d+)/', include(user_detail_patterns)),
|
||||
('^users/', include(users_users_patterns)),
|
||||
|
|
Загрузка…
Ссылка в новой задаче