Skip to content

Commit

Permalink
Merge pull request #410 from jramnai/org-api-fix
Browse files Browse the repository at this point in the history
fix: organization PUT API AttributeError
  • Loading branch information
felipemontoya authored Sep 3, 2024
2 parents dee1f11 + c77a8a3 commit f59e694
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 9 additions & 0 deletions organizations/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,21 @@ def update_logo(self, obj, logo_url):
obj.logo.save(logo_url.split('/')[-1], ContentFile(logo.content))

def create(self, validated_data):
"""
New organizations created through the API are always Active
"""
validated_data.update({'active': True})
logo_url = validated_data.pop('logo_url', None)
obj = super().create(validated_data)
self.update_logo(obj, logo_url)
return obj

def update(self, instance, validated_data):
"""
Existing organizations updated through the API always end up Active,
regardless of whether or not they were previously active
"""
validated_data.update({'active': True})
logo_url = validated_data.pop('logo_url', None)
super().update(instance, validated_data)
self.update_logo(instance, logo_url)
Expand Down
1 change: 0 additions & 1 deletion organizations/v0/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def update(self, request, *args, **kwargs):
raise ValidationError(
"Value of 'active' may not be specified via Organizations HTTP API."
)
self.request.data['active'] = True
try:
return super().update(request, *args, **kwargs)
except Http404:
Expand Down

0 comments on commit f59e694

Please sign in to comment.