feat: harden dashboard editing and translations
This commit is contained in:
@@ -125,26 +125,26 @@ class DashboardViewTests(TestCase):
|
||||
response = self.client.get(reverse("claims:admin-list") + "?status=approved")
|
||||
self.assertFalse(response.context["has_filtered_claims"])
|
||||
|
||||
def test_attester_can_update_project_when_deciding(self):
|
||||
project_old = Project.objects.create(name="Original", is_active=True)
|
||||
project_new = Project.objects.create(name="Corrected", is_active=True)
|
||||
claim = self._create_claim(project=project_old)
|
||||
def test_attester_can_reset_claim_to_pending(self):
|
||||
claim = self._create_claim(status=Claim.Status.APPROVED)
|
||||
|
||||
response = self.client.post(
|
||||
reverse("claims:admin-list"),
|
||||
{
|
||||
"action_type": "decision",
|
||||
"claim_id": claim.id,
|
||||
"action": ClaimDecisionForm.ACTION_APPROVE,
|
||||
"decision_note": "Updated project",
|
||||
"project": project_new.id,
|
||||
"action": ClaimDecisionForm.ACTION_PENDING,
|
||||
"decision_note": "Behöver komplettering",
|
||||
},
|
||||
follow=True,
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
claim.refresh_from_db()
|
||||
self.assertEqual(claim.project, project_new)
|
||||
self.assertTrue(claim.logs.filter(action=ClaimLog.Action.PROJECT_CHANGED).exists())
|
||||
self.assertEqual(claim.status, Claim.Status.PENDING)
|
||||
log = claim.logs.filter(action=ClaimLog.Action.STATUS_CHANGED).first()
|
||||
self.assertIsNotNone(log)
|
||||
self.assertEqual(log.from_status, Claim.Status.APPROVED)
|
||||
self.assertEqual(log.to_status, Claim.Status.PENDING)
|
||||
|
||||
def test_attester_can_edit_details(self):
|
||||
project = Project.objects.create(name="Event", is_active=True)
|
||||
@@ -174,3 +174,26 @@ class DashboardViewTests(TestCase):
|
||||
edit_log = claim.logs.filter(action=ClaimLog.Action.DETAILS_EDITED).first()
|
||||
self.assertIsNotNone(edit_log)
|
||||
self.assertIn("Namn", edit_log.note)
|
||||
self.assertIn("Changed Name", edit_log.note)
|
||||
|
||||
def test_edit_blocked_for_non_pending_claims(self):
|
||||
claim = self._create_claim(status=Claim.Status.APPROVED)
|
||||
response = self.client.post(
|
||||
reverse("claims:admin-list"),
|
||||
{
|
||||
"action_type": "edit",
|
||||
"edit_claim_id": claim.id,
|
||||
"full_name": "Blocked",
|
||||
"email": "blocked@example.com",
|
||||
"account_number": "456",
|
||||
"amount": "200",
|
||||
"currency": Claim.Currency.SEK,
|
||||
"project": "",
|
||||
"description": "Blocked edit",
|
||||
},
|
||||
follow=True,
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
claim.refresh_from_db()
|
||||
self.assertNotEqual(claim.full_name, "Blocked")
|
||||
self.assertFalse(claim.logs.filter(action=ClaimLog.Action.DETAILS_EDITED).exists())
|
||||
|
||||
Reference in New Issue
Block a user