Add keyword arguments to CT get_for_model

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2019-05-10 00:39:20 -04:00
parent 680a7b6ae1
commit 76b75af1c2
6 changed files with 10 additions and 10 deletions

View File

@@ -171,7 +171,7 @@ class WritableAccessControlListSerializer(serializers.ModelSerializer):
def validate(self, attrs): def validate(self, attrs):
attrs['content_type'] = ContentType.objects.get_for_model( attrs['content_type'] = ContentType.objects.get_for_model(
self.context['content_object'] model=self.context['content_object']
) )
attrs['object_id'] = self.context['content_object'].pk attrs['object_id'] = self.context['content_object'].pk

View File

@@ -21,7 +21,7 @@ def get_kwargs_factory(variable_name):
) )
content_type = ContentType.objects.get_for_model( content_type = ContentType.objects.get_for_model(
context[variable_name] model=context[variable_name]
) )
return { return {
'app_label': '"{}"'.format(content_type.app_label), 'app_label': '"{}"'.format(content_type.app_label),

View File

@@ -45,7 +45,7 @@ class TransformationManager(models.Manager):
lambda entry: { lambda entry: {
'content_type': entry[0], 'object_id': entry[1] 'content_type': entry[0], 'object_id': entry[1]
}, zip( }, zip(
ContentType.objects.get_for_models(*targets).values(), ContentType.objects.get_for_models(models=targets).values(),
targets.values_list('pk', flat=True) targets.values_list('pk', flat=True)
) )
) )
@@ -72,7 +72,7 @@ class TransformationManager(models.Manager):
as_classes == True returns the transformation classes from .classes as_classes == True returns the transformation classes from .classes
ready to be feed to the converter class ready to be feed to the converter class
""" """
content_type = ContentType.objects.get_for_model(obj) content_type = ContentType.objects.get_for_model(model=obj)
transformations = self.filter( transformations = self.filter(
content_type=content_type, object_id=obj.pk content_type=content_type, object_id=obj.pk

View File

@@ -306,7 +306,7 @@ class DocumentsViewsTestCase(DocumentViewTestMixin, GenericDocumentViewTestCase)
def test_document_clear_transformations_view_no_permission(self): def test_document_clear_transformations_view_no_permission(self):
document_page = self.test_document.pages.first() document_page = self.test_document.pages.first()
content_type = ContentType.objects.get_for_model(document_page) content_type = ContentType.objects.get_for_model(model=document_page)
transformation = Transformation.objects.create( transformation = Transformation.objects.create(
content_type=content_type, object_id=document_page.pk, content_type=content_type, object_id=document_page.pk,
name=TEST_TRANSFORMATION_NAME, name=TEST_TRANSFORMATION_NAME,
@@ -332,7 +332,7 @@ class DocumentsViewsTestCase(DocumentViewTestMixin, GenericDocumentViewTestCase)
def test_document_clear_transformations_view_with_access(self): def test_document_clear_transformations_view_with_access(self):
document_page = self.test_document.pages.first() document_page = self.test_document.pages.first()
content_type = ContentType.objects.get_for_model(document_page) content_type = ContentType.objects.get_for_model(model=document_page)
transformation = Transformation.objects.create( transformation = Transformation.objects.create(
content_type=content_type, object_id=document_page.pk, content_type=content_type, object_id=document_page.pk,
name=TEST_TRANSFORMATION_NAME, name=TEST_TRANSFORMATION_NAME,
@@ -359,7 +359,7 @@ class DocumentsViewsTestCase(DocumentViewTestMixin, GenericDocumentViewTestCase)
def test_document_multiple_clear_transformations_view_no_permission(self): def test_document_multiple_clear_transformations_view_no_permission(self):
document_page = self.test_document.pages.first() document_page = self.test_document.pages.first()
content_type = ContentType.objects.get_for_model(document_page) content_type = ContentType.objects.get_for_model(model=document_page)
transformation = Transformation.objects.create( transformation = Transformation.objects.create(
content_type=content_type, object_id=document_page.pk, content_type=content_type, object_id=document_page.pk,
name=TEST_TRANSFORMATION_NAME, name=TEST_TRANSFORMATION_NAME,
@@ -382,7 +382,7 @@ class DocumentsViewsTestCase(DocumentViewTestMixin, GenericDocumentViewTestCase)
def test_document_multiple_clear_transformations_view_with_access(self): def test_document_multiple_clear_transformations_view_with_access(self):
document_page = self.test_document.pages.first() document_page = self.test_document.pages.first()
content_type = ContentType.objects.get_for_model(document_page) content_type = ContentType.objects.get_for_model(model=document_page)
transformation = Transformation.objects.create( transformation = Transformation.objects.create(
content_type=content_type, object_id=document_page.pk, content_type=content_type, object_id=document_page.pk,
name=TEST_TRANSFORMATION_NAME, name=TEST_TRANSFORMATION_NAME,

View File

@@ -21,7 +21,7 @@ def get_kwargs_factory(variable_name):
) )
content_type = ContentType.objects.get_for_model( content_type = ContentType.objects.get_for_model(
context[variable_name] model=context[variable_name]
) )
return { return {
'app_label': '"{}"'.format(content_type.app_label), 'app_label': '"{}"'.format(content_type.app_label),

View File

@@ -15,7 +15,7 @@ class EventsViewTestCase(GenericDocumentViewTestCase):
super(EventsViewTestCase, self).setUp() super(EventsViewTestCase, self).setUp()
self.test_object = self.test_document_type self.test_object = self.test_document_type
content_type = ContentType.objects.get_for_model(self.test_object) content_type = ContentType.objects.get_for_model(model=self.test_object)
self.view_arguments = { self.view_arguments = {
'app_label': content_type.app_label, 'app_label': content_type.app_label,