diff --git a/templates/member/profile.html b/templates/member/profile.html index bac9329567..c2be43d571 100644 --- a/templates/member/profile.html +++ b/templates/member/profile.html @@ -608,6 +608,8 @@
{% trans "Type" %} | +{% trans "Explication" %} | +{% trans "Modérateur" %} | +{% trans "Date" %} | + + + {% for sanction in sanctions %} +
---|---|---|---|
{{ sanction.type }} | ++ {% if sanction.note %} + {{ sanction.note }} + {% else %} + – + {% endif %} + | +{{ sanction.moderator.username }} | +{{ sanction.pubdate|format_date|capfirst }} | +
{{ usr.username }} {% trans "n'a jamais été sanctionné." %}
+ {% endif %} +{% endblock %} diff --git a/zds/member/commons.py b/zds/member/commons.py index 970d399b10..178943669a 100644 --- a/zds/member/commons.py +++ b/zds/member/commons.py @@ -224,7 +224,7 @@ class ReadingOnlySanction(MemberSanctionState): """ def get_type(self): - return _(u'Lecture Seule') + return _(u'Lecture seule définitive') def get_text(self): return self.array_infos.get('ls-text', '') @@ -246,7 +246,7 @@ class TemporaryReadingOnlySanction(MemberSanctionState): """ def get_type(self): - return _(u'Lecture Seule Temporaire') + return _(u'Lecture seule temporaire') def get_text(self): return self.array_infos.get('ls-text', '') @@ -271,7 +271,7 @@ class DeleteReadingOnlySanction(MemberSanctionState): """ def get_type(self): - return _(u"Autorisation d'écrire") + return _(u'Fin de lecture seule') def get_text(self): return self.array_infos.get('unls-text', '') @@ -293,7 +293,7 @@ class BanSanction(MemberSanctionState): """ def get_type(self): - return _(u'Ban définitif') + return _(u'Bannissement définitif') def get_text(self): return self.array_infos.get('ban-text', '') @@ -315,7 +315,7 @@ class TemporaryBanSanction(MemberSanctionState): """ def get_type(self): - return _(u'Ban Temporaire') + return _(u'Bannissement temporaire') def get_text(self): return self.array_infos.get('ban-text', '') @@ -341,7 +341,7 @@ class DeleteBanSanction(MemberSanctionState): """ def get_type(self): - return _(u'Autorisation de se connecter') + return _(u'Fin de bannissement') def get_text(self): return self.array_infos.get('unban-text', '') diff --git a/zds/member/tests/tests_views.py b/zds/member/tests/tests_views.py index df9187a263..32d32124dc 100644 --- a/zds/member/tests/tests_views.py +++ b/zds/member/tests/tests_views.py @@ -192,6 +192,54 @@ def test_details_member(self): ) self.assertEqual(result.status_code, 404) + def test_sanctions_history(self): + user = ProfileFactory().user + + ban = Ban( + user=user, + moderator=self.staff, + type='Lecture seule temporaire', + note='Test de LS' + ) + ban.save() + + # staff rights are required to view the history, check that + self.client.logout() + self.client.login(username=user.username, password='hostel77') + + result = self.client.get( + reverse('member-sanctions-history', args=[user.pk]), + follow=False + ) + + self.assertEqual(result.status_code, 403) + + self.client.logout() + self.client.login(username=self.staff.username, password='hostel77') + + result = self.client.get( + reverse('member-sanctions-history', args=[user.pk]), + follow=False + ) + + self.assertEqual(result.status_code, 200) + + # now, check that the history of a unknown user returns a 404 + result = self.client.get( + reverse('member-sanctions-history', args=[0]), + follow=False + ) + + self.assertEqual(result.status_code, 404) + + # finally, check that the history contains the note + result = self.client.get( + reverse('member-sanctions-history', args=[user.pk]), + follow=False + ) + + self.assertContains(result, 'Test de LS') + def test_profile_page_of_weird_member_username(self): # create some user with weird username @@ -635,7 +683,7 @@ def test_sanctions(self): self.assertIsNone(user.end_ban_write) self.assertIsNone(user.end_ban_read) ban = Ban.objects.filter(user__id=user.user.id).order_by('-pubdate')[0] - self.assertEqual(ban.type, 'Lecture Seule') + self.assertEqual(ban.type, 'Lecture seule définitive') self.assertEqual(ban.note, 'Texte de test pour LS') self.assertEquals(len(mail.outbox), 1) @@ -657,7 +705,7 @@ def test_sanctions(self): self.assertIsNone(user.end_ban_write) self.assertIsNone(user.end_ban_read) ban = Ban.objects.filter(user__id=user.user.id).order_by('-id')[0] - self.assertEqual(ban.type, u'Autorisation d\'écrire') + self.assertEqual(ban.type, u'Fin de lecture seule') self.assertEqual(ban.note, 'Texte de test pour un-LS') self.assertEquals(len(mail.outbox), 2) @@ -681,7 +729,7 @@ def test_sanctions(self): self.assertIsNotNone(user.end_ban_write) self.assertIsNone(user.end_ban_read) ban = Ban.objects.filter(user__id=user.user.id).order_by('-id')[0] - self.assertEqual(ban.type, u'Lecture Seule Temporaire') + self.assertEqual(ban.type, u'Lecture seule temporaire') self.assertEqual(ban.note, u'Texte de test pour LS TEMP') self.assertEquals(len(mail.outbox), 3) @@ -704,7 +752,7 @@ def test_sanctions(self): self.assertIsNone(user.end_ban_write) self.assertIsNone(user.end_ban_read) ban = Ban.objects.filter(user__id=user.user.id).order_by('-id')[0] - self.assertEqual(ban.type, u'Ban définitif') + self.assertEqual(ban.type, u'Bannissement définitif') self.assertEqual(ban.note, u'Texte de test pour BAN') self.assertEquals(len(mail.outbox), 4) @@ -727,7 +775,7 @@ def test_sanctions(self): self.assertIsNone(user.end_ban_write) self.assertIsNone(user.end_ban_read) ban = Ban.objects.filter(user__id=user.user.id).order_by('-id')[0] - self.assertEqual(ban.type, u'Autorisation de se connecter') + self.assertEqual(ban.type, u'Fin de bannissement') self.assertEqual(ban.note, u'Texte de test pour BAN') self.assertEquals(len(mail.outbox), 5) @@ -751,7 +799,7 @@ def test_sanctions(self): self.assertIsNone(user.end_ban_write) self.assertIsNotNone(user.end_ban_read) ban = Ban.objects.filter(user__id=user.user.id).order_by('-id')[0] - self.assertEqual(ban.type, u'Ban Temporaire') + self.assertEqual(ban.type, u'Bannissement temporaire') self.assertEqual(ban.note, u'Texte de test pour BAN TEMP') self.assertEquals(len(mail.outbox), 6) diff --git a/zds/member/urls.py b/zds/member/urls.py index f7d0096d27..3ac55cfe43 100644 --- a/zds/member/urls.py +++ b/zds/member/urls.py @@ -5,7 +5,8 @@ from zds.member.views import MemberList, MemberDetail, UpdateMember, UpdateAvatarMember, UpdatePasswordMember, \ UpdateUsernameEmailMember, RegisterView, SendValidationEmailView, modify_karma, \ modify_profile, settings_mini_profile, member_from_ip, tutorials, articles, settings_promote, login_view, \ - logout_view, forgot_password, new_password, activate_account, generate_token_account, unregister, warning_unregister + logout_view, forgot_password, new_password, activate_account, generate_token_account, unregister, \ + warning_unregister, sanctions_history urlpatterns = [ # list @@ -23,6 +24,7 @@ # moderation url(r'^profil/karmatiser/$', modify_karma, name='member-modify-karma'), url(r'^profil/modifier/(?P