Skip to content

Commit

Permalink
[Dépôt de besoin] Sondage J+30 : mettre à jour siae_transactioned (#922)
Browse files Browse the repository at this point in the history
* Survey transactioned: also update siae_transactioned field

* Update tests
  • Loading branch information
raphodn authored Sep 28, 2023
1 parent ff1ca28 commit 0dc9056
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lemarche/www/tenders/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,7 @@ def test_only_tender_author_with_sesame_token_can_call_tender_survey_transaction
def test_update_tender_stats_on_tender_survey_transactioned_answer_true(self):
user_sesame_query_string = sesame_get_query_string(self.user_buyer_1)
self.assertEqual(self.tender.survey_transactioned_answer, None)
self.assertEqual(self.tender.siae_transactioned, None)
# load without answer
url = (
reverse("tenders:detail-survey-transactioned", kwargs={"slug": self.tender.slug})
Expand All @@ -1292,6 +1293,7 @@ def test_update_tender_stats_on_tender_survey_transactioned_answer_true(self):
self.assertEqual(response.status_code, 200) # redirect
self.assertRedirects(response, reverse("tenders:detail", kwargs={"slug": self.tender.slug}))
self.assertEqual(Tender.objects.get(id=self.tender.id).survey_transactioned_answer, None)
self.assertEqual(Tender.objects.get(id=self.tender.id).siae_transactioned, None)
# load with answer
url = (
reverse("tenders:detail-survey-transactioned", kwargs={"slug": self.tender.slug})
Expand All @@ -1303,6 +1305,7 @@ def test_update_tender_stats_on_tender_survey_transactioned_answer_true(self):
self.assertRedirects(response, reverse("tenders:detail", kwargs={"slug": self.tender.slug}))
self.assertContains(response, "Merci pour vote réponse")
self.assertEqual(Tender.objects.get(id=self.tender.id).survey_transactioned_answer, True)
self.assertEqual(Tender.objects.get(id=self.tender.id).siae_transactioned, True)
# reload with answer, ignore changes
url = (
reverse("tenders:detail-survey-transactioned", kwargs={"slug": self.tender.slug})
Expand All @@ -1314,10 +1317,12 @@ def test_update_tender_stats_on_tender_survey_transactioned_answer_true(self):
self.assertRedirects(response, reverse("tenders:detail", kwargs={"slug": self.tender.slug}))
self.assertContains(response, "Votre réponse a déjà été prise en compte")
self.assertEqual(Tender.objects.get(id=self.tender.id).survey_transactioned_answer, True)
self.assertEqual(Tender.objects.get(id=self.tender.id).siae_transactioned, True)

def test_update_tender_stats_on_tender_survey_transactioned_answer_false(self):
user_sesame_query_string = sesame_get_query_string(self.user_buyer_1)
self.assertEqual(self.tender.survey_transactioned_answer, None)
self.assertEqual(self.tender.siae_transactioned, None)
# load without answer
url = (
reverse("tenders:detail-survey-transactioned", kwargs={"slug": self.tender.slug})
Expand All @@ -1327,6 +1332,7 @@ def test_update_tender_stats_on_tender_survey_transactioned_answer_false(self):
self.assertEqual(response.status_code, 200) # redirect
self.assertRedirects(response, reverse("tenders:detail", kwargs={"slug": self.tender.slug}))
self.assertEqual(Tender.objects.get(id=self.tender.id).survey_transactioned_answer, None)
self.assertEqual(Tender.objects.get(id=self.tender.id).siae_transactioned, None)
# load with answer
url = (
reverse("tenders:detail-survey-transactioned", kwargs={"slug": self.tender.slug})
Expand All @@ -1338,6 +1344,7 @@ def test_update_tender_stats_on_tender_survey_transactioned_answer_false(self):
self.assertRedirects(response, reverse("tenders:detail", kwargs={"slug": self.tender.slug}))
self.assertContains(response, "Merci pour vote réponse")
self.assertEqual(Tender.objects.get(id=self.tender.id).survey_transactioned_answer, False)
self.assertEqual(Tender.objects.get(id=self.tender.id).siae_transactioned, False)
# reload with answer, ignore changes
url = (
reverse("tenders:detail-survey-transactioned", kwargs={"slug": self.tender.slug})
Expand All @@ -1349,3 +1356,4 @@ def test_update_tender_stats_on_tender_survey_transactioned_answer_false(self):
self.assertRedirects(response, reverse("tenders:detail", kwargs={"slug": self.tender.slug}))
self.assertContains(response, "Votre réponse a déjà été prise en compte")
self.assertEqual(Tender.objects.get(id=self.tender.id).survey_transactioned_answer, False)
self.assertEqual(Tender.objects.get(id=self.tender.id).siae_transactioned, False)
1 change: 1 addition & 0 deletions lemarche/www/tenders/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ def get(self, request, *args, **kwargs):
Tender.objects.filter(id=self.object.id).update(
survey_transactioned_answer=survey_transactioned_answer,
survey_transactioned_answer_date=timezone.now(),
siae_transactioned=survey_transactioned_answer,
updated_at=timezone.now(),
)
messages.add_message(
Expand Down

0 comments on commit 0dc9056

Please sign in to comment.