From 4637f71c24d5cde1a52942ab456fa8b585a6693e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Bedna=C5=99=C3=ADk?= <jan.bednarik@gmail.com>
Date: Thu, 1 Mar 2018 17:46:18 +0100
Subject: [PATCH] Add is draft flag to Report type.

---
 openlobby/core/api/types.py                          | 3 +++
 tests/mutations/snapshots/snap_test_create_report.py | 2 ++
 tests/mutations/snapshots/snap_test_update_report.py | 4 ++++
 tests/mutations/test_create_report.py                | 1 +
 tests/mutations/test_update_report.py                | 1 +
 tests/schema/snapshots/snap_test_authors.py          | 3 +++
 tests/schema/snapshots/snap_test_node.py             | 2 ++
 tests/schema/snapshots/snap_test_report_drafts.py    | 1 +
 tests/schema/snapshots/snap_test_search_reports.py   | 6 ++++++
 tests/schema/test_authors.py                         | 1 +
 tests/schema/test_node.py                            | 4 ++++
 tests/schema/test_report_drafts.py                   | 1 +
 tests/schema/test_search_reports.py                  | 3 +++
 13 files changed, 32 insertions(+)

diff --git a/openlobby/core/api/types.py b/openlobby/core/api/types.py
index d88698d..d552d37 100644
--- a/openlobby/core/api/types.py
+++ b/openlobby/core/api/types.py
@@ -27,6 +27,7 @@ class Report(graphene.ObjectType):
     provided_benefit = graphene.String()
     our_participants = graphene.String()
     other_participants = graphene.String()
+    is_draft = graphene.Boolean()
     extra = JSONString()
 
     class Meta:
@@ -45,6 +46,7 @@ class Report(graphene.ObjectType):
             provided_benefit=get_higlighted(report, 'provided_benefit'),
             our_participants=get_higlighted(report, 'our_participants'),
             other_participants=get_higlighted(report, 'other_participants'),
+            is_draft=report.is_draft,
             extra=report.extra,
         )
 
@@ -61,6 +63,7 @@ class Report(graphene.ObjectType):
             provided_benefit=report.provided_benefit,
             our_participants=report.our_participants,
             other_participants=report.other_participants,
+            is_draft=report.is_draft,
             extra=report.extra,
         )
 
diff --git a/tests/mutations/snapshots/snap_test_create_report.py b/tests/mutations/snapshots/snap_test_create_report.py
index b7abf9d..4b33904 100644
--- a/tests/mutations/snapshots/snap_test_create_report.py
+++ b/tests/mutations/snapshots/snap_test_create_report.py
@@ -39,6 +39,7 @@ snapshots['test_full_report 1'] = {
                 'date': '2018-01-01 00:00:00+00:00',
                 'extra': None,
                 'id': '__STRIPPED__',
+                'isDraft': False,
                 'otherParticipants': 'Elon Musk',
                 'ourParticipants': 'me',
                 'providedBenefit': 'nothing',
@@ -65,6 +66,7 @@ snapshots['test_is_draft 1'] = {
                 'date': '2018-01-03 00:00:00+00:00',
                 'extra': None,
                 'id': '__STRIPPED__',
+                'isDraft': True,
                 'otherParticipants': 'Neil deGrasse Tyson',
                 'ourParticipants': 'myself',
                 'providedBenefit': 'coffee',
diff --git a/tests/mutations/snapshots/snap_test_update_report.py b/tests/mutations/snapshots/snap_test_update_report.py
index 18f47b8..b2c4902 100644
--- a/tests/mutations/snapshots/snap_test_update_report.py
+++ b/tests/mutations/snapshots/snap_test_update_report.py
@@ -90,6 +90,7 @@ snapshots['test_update_draft_with_draft 1'] = {
                 'date': '2018-03-03 00:00:00+00:00',
                 'extra': None,
                 'id': 'UmVwb3J0OjE=',
+                'isDraft': True,
                 'otherParticipants': 'Elon Musk',
                 'ourParticipants': 'me',
                 'providedBenefit': 'nothing',
@@ -116,6 +117,7 @@ snapshots['test_update_draft_with_published 1'] = {
                 'date': '2018-03-03 00:00:00+00:00',
                 'extra': None,
                 'id': 'UmVwb3J0OjE=',
+                'isDraft': False,
                 'otherParticipants': 'Elon Musk',
                 'ourParticipants': 'me',
                 'providedBenefit': 'nothing',
@@ -142,6 +144,7 @@ snapshots['test_update_published_with_published 1'] = {
                 'date': '2018-03-03 00:00:00+00:00',
                 'extra': None,
                 'id': 'UmVwb3J0OjE=',
+                'isDraft': False,
                 'otherParticipants': 'Elon Musk',
                 'ourParticipants': 'me',
                 'providedBenefit': 'nothing',
@@ -168,6 +171,7 @@ snapshots['test_input_sanitization 1'] = {
                 'date': '2018-03-03 00:00:00+00:00',
                 'extra': None,
                 'id': 'UmVwb3J0OjE=',
+                'isDraft': False,
                 'otherParticipants': 'you!',
                 'ourParticipants': 'me, myself',
                 'providedBenefit': 'tea',
diff --git a/tests/mutations/test_create_report.py b/tests/mutations/test_create_report.py
index 63086b7..df1837c 100644
--- a/tests/mutations/test_create_report.py
+++ b/tests/mutations/test_create_report.py
@@ -24,6 +24,7 @@ mutation createReport ($input: CreateReportInput!) {
             providedBenefit
             ourParticipants
             otherParticipants
+            isDraft
             extra
             author {
                 id
diff --git a/tests/mutations/test_update_report.py b/tests/mutations/test_update_report.py
index c0e1ff2..94e9267 100644
--- a/tests/mutations/test_update_report.py
+++ b/tests/mutations/test_update_report.py
@@ -25,6 +25,7 @@ mutation updateReport ($input: UpdateReportInput!) {
             providedBenefit
             ourParticipants
             otherParticipants
+            isDraft
             extra
             author {
                 id
diff --git a/tests/schema/snapshots/snap_test_authors.py b/tests/schema/snapshots/snap_test_authors.py
index 5bd5ce2..e29162b 100644
--- a/tests/schema/snapshots/snap_test_authors.py
+++ b/tests/schema/snapshots/snap_test_authors.py
@@ -200,6 +200,7 @@ snapshots['test_with_reports 1'] = {
                                         'date': '2018-01-05 00:00:00+00:00',
                                         'extra': '{"rings": 1}',
                                         'id': 'UmVwb3J0OjI=',
+                                        'isDraft': False,
                                         'otherParticipants': 'Saruman, Sauron',
                                         'ourParticipants': 'Frodo, Gimli, Legolas',
                                         'providedBenefit': '',
@@ -230,6 +231,7 @@ snapshots['test_with_reports 1'] = {
                                         'date': '2018-01-07 00:00:00+00:00',
                                         'extra': None,
                                         'id': 'UmVwb3J0OjM=',
+                                        'isDraft': False,
                                         'otherParticipants': 'Sauron',
                                         'ourParticipants': 'Aragorn',
                                         'providedBenefit': 'The Ring',
@@ -245,6 +247,7 @@ snapshots['test_with_reports 1'] = {
                                         'date': '2018-01-01 00:00:00+00:00',
                                         'extra': None,
                                         'id': 'UmVwb3J0OjE=',
+                                        'isDraft': False,
                                         'otherParticipants': 'Saruman',
                                         'ourParticipants': 'Frodo, Gandalf',
                                         'providedBenefit': '',
diff --git a/tests/schema/snapshots/snap_test_node.py b/tests/schema/snapshots/snap_test_node.py
index 52ce304..018addc 100644
--- a/tests/schema/snapshots/snap_test_node.py
+++ b/tests/schema/snapshots/snap_test_node.py
@@ -50,6 +50,7 @@ snapshots['test_report 1'] = {
             'date': '2018-01-01 00:00:00+00:00',
             'extra': None,
             'id': 'UmVwb3J0OjE=',
+            'isDraft': False,
             'otherParticipants': 'Saruman',
             'ourParticipants': 'Frodo, Gandalf',
             'providedBenefit': '',
@@ -102,6 +103,7 @@ snapshots['test_report__is_draft 1'] = {
     'data': {
         'node': {
             'id': 'UmVwb3J0OjQ=',
+            'isDraft': True,
             'title': 'The Silmarillion'
         }
     }
diff --git a/tests/schema/snapshots/snap_test_report_drafts.py b/tests/schema/snapshots/snap_test_report_drafts.py
index 0bc252a..b514fd2 100644
--- a/tests/schema/snapshots/snap_test_report_drafts.py
+++ b/tests/schema/snapshots/snap_test_report_drafts.py
@@ -21,6 +21,7 @@ snapshots['test_authenticated 1'] = {
                 'body': 'Not finished yet.',
                 'date': '2018-01-09 00:00:00+00:00',
                 'id': 'UmVwb3J0OjQ=',
+                'isDraft': True,
                 'otherParticipants': '',
                 'ourParticipants': '',
                 'providedBenefit': '',
diff --git a/tests/schema/snapshots/snap_test_search_reports.py b/tests/schema/snapshots/snap_test_search_reports.py
index 27a214f..a35f915 100644
--- a/tests/schema/snapshots/snap_test_search_reports.py
+++ b/tests/schema/snapshots/snap_test_search_reports.py
@@ -26,6 +26,7 @@ snapshots['test_all 1'] = {
                         'date': '2018-01-05 00:00:00+00:00',
                         'extra': '{"rings": 1}',
                         'id': 'UmVwb3J0OjI=',
+                        'isDraft': False,
                         'otherParticipants': 'Saruman, Sauron',
                         'ourParticipants': 'Frodo, Gimli, Legolas',
                         'providedBenefit': '',
@@ -49,6 +50,7 @@ snapshots['test_all 1'] = {
                         'date': '2018-01-07 00:00:00+00:00',
                         'extra': None,
                         'id': 'UmVwb3J0OjM=',
+                        'isDraft': False,
                         'otherParticipants': 'Sauron',
                         'ourParticipants': 'Aragorn',
                         'providedBenefit': 'The Ring',
@@ -72,6 +74,7 @@ snapshots['test_all 1'] = {
                         'date': '2018-01-01 00:00:00+00:00',
                         'extra': None,
                         'id': 'UmVwb3J0OjE=',
+                        'isDraft': False,
                         'otherParticipants': 'Saruman',
                         'ourParticipants': 'Frodo, Gandalf',
                         'providedBenefit': '',
@@ -111,6 +114,7 @@ snapshots['test_query 1'] = {
                         'date': '2018-01-05 00:00:00+00:00',
                         'extra': '{"rings": 1}',
                         'id': 'UmVwb3J0OjI=',
+                        'isDraft': False,
                         'otherParticipants': 'Saruman, Sauron',
                         'ourParticipants': 'Frodo, Gimli, Legolas',
                         'providedBenefit': '',
@@ -144,6 +148,7 @@ snapshots['test_highlight 1'] = {
                         'date': '2018-01-07 00:00:00+00:00',
                         'extra': None,
                         'id': 'UmVwb3J0OjM=',
+                        'isDraft': False,
                         'otherParticipants': 'Sauron',
                         'ourParticipants': 'Aragorn',
                         'providedBenefit': 'The <mark>Ring</mark>',
@@ -167,6 +172,7 @@ snapshots['test_highlight 1'] = {
                         'date': '2018-01-01 00:00:00+00:00',
                         'extra': None,
                         'id': 'UmVwb3J0OjE=',
+                        'isDraft': False,
                         'otherParticipants': 'Saruman',
                         'ourParticipants': 'Frodo, Gandalf',
                         'providedBenefit': '',
diff --git a/tests/schema/test_authors.py b/tests/schema/test_authors.py
index c0475ff..0e83176 100644
--- a/tests/schema/test_authors.py
+++ b/tests/schema/test_authors.py
@@ -187,6 +187,7 @@ def test_with_reports(client, snapshot):
                                 providedBenefit
                                 ourParticipants
                                 otherParticipants
+                                isDraft
                                 extra
                             }
                         }
diff --git a/tests/schema/test_node.py b/tests/schema/test_node.py
index 383b4a3..6a42cb5 100644
--- a/tests/schema/test_node.py
+++ b/tests/schema/test_node.py
@@ -76,6 +76,7 @@ def test_report(client, snapshot):
                 providedBenefit
                 ourParticipants
                 otherParticipants
+                isDraft
                 extra
                 author {{
                     id
@@ -101,6 +102,7 @@ def test_report__is_draft(client, snapshot):
             ... on Report {{
                 id
                 title
+                isDraft
             }}
         }}
     }}
@@ -117,6 +119,7 @@ def test_report__is_draft__unauthorized_viewer(client, snapshot):
             ... on Report {{
                 id
                 title
+                isDraft
             }}
         }}
     }}
@@ -133,6 +136,7 @@ def test_report__is_draft__viewer_is_not_author(client, snapshot):
             ... on Report {{
                 id
                 title
+                isDraft
             }}
         }}
     }}
diff --git a/tests/schema/test_report_drafts.py b/tests/schema/test_report_drafts.py
index 18a87b9..8189875 100644
--- a/tests/schema/test_report_drafts.py
+++ b/tests/schema/test_report_drafts.py
@@ -34,6 +34,7 @@ def test_authenticated(client, snapshot):
             providedBenefit
             ourParticipants
             otherParticipants
+            isDraft
         }
     }
     """
diff --git a/tests/schema/test_search_reports.py b/tests/schema/test_search_reports.py
index 83d7c0a..4da763b 100644
--- a/tests/schema/test_search_reports.py
+++ b/tests/schema/test_search_reports.py
@@ -25,6 +25,7 @@ def test_all(client, snapshot):
                     providedBenefit
                     ourParticipants
                     otherParticipants
+                    isDraft
                     extra
                     author {
                         id
@@ -67,6 +68,7 @@ def test_query(client, snapshot):
                     providedBenefit
                     ourParticipants
                     otherParticipants
+                    isDraft
                     extra
                     author {
                         id
@@ -103,6 +105,7 @@ def test_highlight(client, snapshot):
                     providedBenefit
                     ourParticipants
                     otherParticipants
+                    isDraft
                     extra
                     author {
                         id
-- 
GitLab