Skip to content

Commit

Permalink
Fix #3432 : corrige l'absence de date de réservation (validation)
Browse files Browse the repository at this point in the history
  • Loading branch information
Augustin Laville committed Jun 4, 2017
1 parent ee5cae6 commit 773a858
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
3 changes: 3 additions & 0 deletions templates/misc/validation.part.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

{% if validation.date_reserve %}
{{ validation.date_reserve|format_date:True }}
{% if validation.date_proposition > validation.date_reserve %}
({% trans 'contenu mis à jour depuis la réservation' %})
{% endif %}
<br>
{% endif %}
{% endif %}
Expand Down
56 changes: 56 additions & 0 deletions zds/tutorialv2/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5731,6 +5731,62 @@ def test_validation_history_for_new_content(self):
result = self.client.get(reverse('validation:list') + '?type=tuto')
self.assertNotIn('class="update_content"', result.content)

def test_ask_validation_update(self):
"""
Test AskValidationView.
"""
text_validation = u'La validation on vous aime !'
content = PublishableContentFactory(author_list=[self.user_author], type='ARTICLE')
content.save()
content_draft = content.load_version()

self.assertEqual(Validation.objects.count(), 0)

# login with user and ask validation
self.assertEqual(self.client.login(username=self.user_author.username, password='hostel77'), True)
result = self.client.post(
reverse('validation:ask', kwargs={'pk': content_draft.pk, 'slug': content_draft.slug}),
{'text': text_validation, 'source': '', 'version': content_draft.current_version},
follow=False)
self.assertEqual(result.status_code, 302)
self.assertEqual(Validation.objects.count(), 1)

# login with staff and reserve the content
self.assertEqual(self.client.login(username=self.user_staff.username, password='hostel77'), True)
validation = Validation.objects.filter(content=content).last()
result = self.client.post(
reverse('validation:reserve', kwargs={'pk': validation.pk}),
{'version': validation.version},
follow=False)
self.assertEqual(result.status_code, 302)

# login with user, edit content and ask validation for update
self.assertEqual(self.client.login(username=self.user_author.username, password='hostel77'), True)
result = self.client.post(
reverse('content:edit', args=[content_draft.pk, content_draft.slug]),
{
'title': content_draft.title + u'2',
'description': content_draft.description,
'introduction': content_draft.introduction,
'conclusion': content_draft.conclusion,
'type': content_draft.type,
'licence': self.licence.pk,
'subcategory': self.subcategory.pk,
'last_hash': content_draft.compute_hash(),
'image': content_draft.image
},
follow=False)
self.assertEqual(result.status_code, 302)
result = self.client.post(
reverse('validation:ask', kwargs={'pk': content_draft.pk, 'slug': content_draft.slug}),
{'text': text_validation, 'source': '', 'version': content_draft.current_version},
follow=False)
self.assertEqual(result.status_code, 302)

# ensure the validation is effective
self.assertEqual(Validation.objects.count(), 2)
self.assertIsNotNone(Validation.objects.last().date_reserve) # issue #3432

def test_beta_article_closed_when_published(self):
"""Test that the beta of an article is locked when the content is published"""

Expand Down
1 change: 1 addition & 0 deletions zds/tutorialv2/views/views_validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def form_valid(self, form):
validation.version = form.cleaned_data['version']
if old_validator:
validation.validator = old_validator
validation.date_reserve = old_validation.date_reserve
validation.status = 'PENDING_V'
validation.save()

Expand Down

0 comments on commit 773a858

Please sign in to comment.