Skip to content

Commit

Permalink
Merge pull request projectcaluma#153 from sliverc/single_document_per…
Browse files Browse the repository at this point in the history
…_case

Let a document only be assigned to one case
  • Loading branch information
winged authored Dec 14, 2018
2 parents a1a9dc4 + c87908d commit f5b46f3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
1 change: 0 additions & 1 deletion caluma/form/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ class Document(DjangoObjectType):
class Meta:
model = models.Document
interfaces = (graphene.Node,)
exclude_fields = ("cases",)
filter_fields = ("form",)


Expand Down
1 change: 1 addition & 0 deletions caluma/tests/snapshots/snap_test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
form: Form!
meta: JSONString!
answers(before: String, after: String, first: Int, last: Int, question: ID, search: String, orderBy: [AnswerOrdering]): AnswerConnection
case: Case
}
type DocumentConnection {
Expand Down
25 changes: 25 additions & 0 deletions caluma/workflow/migrations/0002_auto_20181213_1334.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2018-12-13 13:34
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [("workflow", "0001_initial")]

operations = [
migrations.AlterField(
model_name="case",
name="document",
field=models.OneToOneField(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="case",
to="form.Document",
),
)
]
6 changes: 3 additions & 3 deletions caluma/workflow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ class Case(UUIDModel):
)
status = models.CharField(choices=STATUS_CHOICE_TUPLE, max_length=50, db_index=True)
meta = JSONField(default={})
document = models.ForeignKey(
document = models.OneToOneField(
"form.Document",
on_delete=models.DO_NOTHING,
related_name="cases",
on_delete=models.PROTECT,
related_name="case",
blank=True,
null=True,
)
Expand Down

0 comments on commit f5b46f3

Please sign in to comment.