Skip to content
Snippets Groups Projects
Commit b80f9a71 authored by jan.bednarik's avatar jan.bednarik
Browse files

Save of Report draft does not mark user as author.

parent 4cbff8ac
No related branches found
No related tags found
No related merge requests found
...@@ -68,6 +68,6 @@ class Report(models.Model): ...@@ -68,6 +68,6 @@ class Report(models.Model):
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
super().save(*args, **kwargs) super().save(*args, **kwargs)
if not self.author.is_author: if not self.is_draft and not self.author.is_author:
self.author.is_author = True self.author.is_author = True
self.author.save() self.author.save()
...@@ -18,6 +18,14 @@ def test_report__marks_user_as_author_on_save(): ...@@ -18,6 +18,14 @@ def test_report__marks_user_as_author_on_save():
assert user.is_author assert user.is_author
def test_report__marks_user_as_author_on_save__not_if_draft():
author = User.objects.create(id=1, is_author=False)
date = arrow.get(2018, 1, 1).datetime
Report.objects.create(author=author, is_draft=True, date=date, body='Lorem ipsum.')
user = User.objects.get(id=1)
assert not user.is_author
def test_report__is_saved_in_elasticsearch(): def test_report__is_saved_in_elasticsearch():
author = User.objects.create(id=6) author = User.objects.create(id=6)
date = arrow.get(2018, 1, 1).datetime date = arrow.get(2018, 1, 1).datetime
...@@ -50,7 +58,7 @@ def test_report__is_saved_in_elasticsearch(): ...@@ -50,7 +58,7 @@ def test_report__is_saved_in_elasticsearch():
assert doc.our_participants == 'me' assert doc.our_participants == 'me'
assert doc.other_participants == 'them' assert doc.other_participants == 'them'
assert doc.extra == {'a': 3} assert doc.extra == {'a': 3}
assert doc.is_draft is False assert not doc.is_draft
def test_report__save_works_with_no_extra(): def test_report__save_works_with_no_extra():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment