Skip to content

Commit

Permalink
Add save method to UserProfile model
Browse files Browse the repository at this point in the history
  • Loading branch information
DjangoCRM committed Sep 12, 2024
1 parent b9a154b commit 045d2d9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,8 @@ def __str__(self):

def get_absolute_url(self):
return reverse('site:common_userprofile_change', args=(self.pk,))

def save(self, *args, **kwargs):
if not self.language_code:
self.language_code = settings.LANGUAGE_CODE
super().save(*args, **kwargs)
5 changes: 2 additions & 3 deletions tests/tasks/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,8 @@ def test_close_project(self):
response = self.client.post(change_url, data, follow=True)
self.assertEqual(response.status_code, 200, response.reason_phrase)
self.assertNoFormErrors(response)
self.assertEqual(len(mail.outbox), 2)
self.assertEqual(mail.outbox[0].to, [self.sergey.email])
self.assertEqual(mail.outbox[1].to, [self.chief.email])
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(mail.outbox[0].to, [self.sergey.email, self.chief.email])
self.assertIn(project.name, mail.outbox[0].subject)
mail.outbox = []

Expand Down
4 changes: 2 additions & 2 deletions tests/tasks/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_subtask_completed_in_email(self):
self.assertEqual(msg.to, [self.masha.email])
mail.outbox = []
complete_url = reverse("email-subtask_completed", args=(task.token, self.masha.id))
self.assertIn(complete_url, msg.body)
self.assertIn(complete_url[4:], msg.body)
self.client.logout()
response = self.client.get(complete_url, follow=True)
self.assertEqual(response.status_code, 200, response.reason_phrase)
Expand Down Expand Up @@ -187,7 +187,7 @@ def test_task_completed_in_email(self):
self.assertEqual(msg.to, [self.sergey.email])
mail.outbox = []
complete_url = reverse("task_completed", args=(task.token, self.sergey.id))
self.assertIn(complete_url, msg.body)
self.assertIn(complete_url[4:], msg.body)
self.client.logout()
response = self.client.get(complete_url, follow=True)
self.assertEqual(response.status_code, 200, response.reason_phrase)
Expand Down

0 comments on commit 045d2d9

Please sign in to comment.