def test_get_field(self):
        field = ObjectService.get_field(TestModel)
        self.assertEqual('my_field', field.name)

        try:
            ObjectService.get_field(TestModelWithoutStateField)
            self.assertFalse(True, "Trying getting field from a model does not contains state field should have thrown the error with code '8'")
        except RiverException as re:
            self.assertEqual(ErrorCode.NO_STATE_FIELD, re.code)
    def test_get_field(self):
        field = ObjectService.get_field(TestModel)
        self.assertEqual('my_field', field.name)

        try:
            ObjectService.get_field(TestModelWithoutStateField)
            self.assertFalse(
                True,
                "Trying getting field from a model does not contains state field should have thrown the error with code '8'"
            )
        except RiverException as re:
            self.assertEqual(ErrorCode.NO_STATE_FIELD, re.code)
 def save(self, *args, **kwargs):
     content_type = self.cleaned_data['content_type']
     field = ObjectService.get_field(content_type.model_class())
     instance = super(ProceedingMetaForm, self).save(commit=False)
     instance.field = field.name
     return super(ProceedingMetaForm, self).save(*args, **kwargs)
Example #4
0
 def save(self, *args, **kwargs):
     content_type = self.cleaned_data['content_type']
     field = ObjectService.get_field(content_type.model_class())
     instance = super(ProceedingMetaForm, self).save(commit=False)
     instance.field = field.name
     return super(ProceedingMetaForm, self).save(*args, **kwargs)