Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: organization PUT API AttributeError #410

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading