From 60ee176e622392a7ad745792bd3413684a015eac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Bedna=C5=99=C3=ADk?= <jan.bednarik@gmail.com>
Date: Sun, 25 Feb 2018 23:07:24 +0100
Subject: [PATCH] Add flag is_draft to Report.

---
 openlobby/core/documents.py                    |  1 +
 .../core/migrations/0011_report_is_draft.py    | 18 ++++++++++++++++++
 openlobby/core/models.py                       |  1 +
 tests/test_models.py                           |  2 ++
 4 files changed, 22 insertions(+)
 create mode 100644 openlobby/core/migrations/0011_report_is_draft.py

diff --git a/openlobby/core/documents.py b/openlobby/core/documents.py
index 4d4b339..69504a9 100644
--- a/openlobby/core/documents.py
+++ b/openlobby/core/documents.py
@@ -33,4 +33,5 @@ class ReportDoc(DocType):
         fields = [
             'date',
             'published',
+            'is_draft',
         ]
diff --git a/openlobby/core/migrations/0011_report_is_draft.py b/openlobby/core/migrations/0011_report_is_draft.py
new file mode 100644
index 0000000..f5a7d18
--- /dev/null
+++ b/openlobby/core/migrations/0011_report_is_draft.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.0.2 on 2018-02-25 22:04
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('core', '0010_user_has_colliding_name'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='report',
+            name='is_draft',
+            field=models.BooleanField(default=False),
+        ),
+    ]
diff --git a/openlobby/core/models.py b/openlobby/core/models.py
index 0860348..36dca03 100644
--- a/openlobby/core/models.py
+++ b/openlobby/core/models.py
@@ -64,6 +64,7 @@ class Report(models.Model):
     our_participants = models.TextField(null=True, blank=True)
     other_participants = models.TextField(null=True, blank=True)
     extra = JSONField(null=True, blank=True)
+    is_draft = models.BooleanField(default=False)
 
     def save(self, *args, **kwargs):
         super().save(*args, **kwargs)
diff --git a/tests/test_models.py b/tests/test_models.py
index 8988d6e..bccd5d0 100644
--- a/tests/test_models.py
+++ b/tests/test_models.py
@@ -34,6 +34,7 @@ def test_report__is_saved_in_elasticsearch():
         our_participants='me',
         other_participants='them',
         extra={'a': 3},
+        is_draft=False,
     )
     docs = list(ReportDoc.search())
     assert len(docs) == 1
@@ -49,6 +50,7 @@ def test_report__is_saved_in_elasticsearch():
     assert doc.our_participants == 'me'
     assert doc.other_participants == 'them'
     assert doc.extra == {'a': 3}
+    assert doc.is_draft is False
 
 
 def test_report__save_works_with_no_extra():
-- 
GitLab