Skip to content

Commit

Permalink
Merge pull request #1910 from SEED-platform/ft-GBR-create-state-certi…
Browse files Browse the repository at this point in the history
…ficates

minor issues with PropertyStateWritableSerializer and GreenAssessment…
  • Loading branch information
nllong committed Jul 8, 2019
2 parents 5309b07 + 9dc48d4 commit a3cce7e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion seed/serializers/certification.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class GreenAssessmentPropertySerializer(OrgValidateMixin, serializers.ModelSeria
metric = serializers.FloatField(required=False, allow_null=True)
rating = serializers.CharField(
required=False, allow_null=True, max_length=100)
expiration_date = serializers.DateField()
expiration_date = serializers.DateField(allow_null=True, required=False)
# ensure reuqest.users org matches that of view and assessment
org_validators = [ASSESSMENT_VALIDATOR, PROPERTY_VIEW_VALIDATOR]

Expand Down
9 changes: 5 additions & 4 deletions seed/serializers/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ def to_internal_value(self, data):
state = PropertyStateWritableSerializer(
instance=state_obj
).data
except ValueError:
state = json.loads(state)
except TypeError:
pass # already a PropertyStateWritableSerializer object
required = True if self.context['request'].method in ['PUT', 'POST'] else False
org = state.get('organization')
org_id = org if org else org_id
Expand Down Expand Up @@ -413,8 +413,9 @@ def _validate(self, data):
missing.append(field)
# type validation
for field in required_fields:
if data.get(field) and not isinstance(data[field], (basestring, int)):
wrong_type.append((field, type(field)))
if field != 'state': # state is a writeable serializer field
if data.get(field) and not isinstance(data[field], (basestring, int)):
wrong_type.append((field, type(field)))
for fields in unique_together:
field_vals = {}
for field in fields:
Expand Down

0 comments on commit a3cce7e

Please sign in to comment.