When changing document types, don't delete the old metadata that is

also found in the new document type. GitLab issue #421.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2017-08-24 19:44:08 -04:00
parent 61d064fb6d
commit 8b9e605e0b
6 changed files with 165 additions and 16 deletions

View File

@@ -1,5 +1,6 @@
from __future__ import unicode_literals
from django.apps import apps
from django.db import models
@@ -20,3 +21,16 @@ class MetadataTypeManager(models.Manager):
'metadata_type', flat=True
)
)
class DocumentTypeMetadataTypeManager(models.Manager):
def get_metadata_types_for(self, document_type):
DocumentType = apps.get_model(
app_label='metadata', model_name='MetadataType'
)
return DocumentType.objects.filter(
pk__in=self.filter(
document_type=document_type
).values_list('metadata_type__pk', flat=True)
)