diff --git a/openbook_auth/checkers.py b/openbook_auth/checkers.py index bbc04306..43aa3cd0 100644 --- a/openbook_auth/checkers.py +++ b/openbook_auth/checkers.py @@ -123,7 +123,7 @@ def check_community_data(user, community, name=None, cover=None, avatar=None, ty def check_community_type_can_be_updated(type, community): Community = get_community_model() - if type == Community.COMMUNITY_TYPE_PUBLIC and community.is_private: + if type == Community.COMMUNITY_TYPE_PUBLIC and community.is_private(): raise ValidationError( _('A community cannot be changed from private to public'), ) diff --git a/openbook_communities/tests/views/community/test_views.py b/openbook_communities/tests/views/community/test_views.py index d2d1d4de..7cbd18f8 100644 --- a/openbook_communities/tests/views/community/test_views.py +++ b/openbook_communities/tests/views/community/test_views.py @@ -419,6 +419,31 @@ def test_can_update_administrated_community_description(self): self.assertEqual(community.description, new_community_description) + def test_can_update_administrated_community_description_with_type_unchanged(self): + """ + should be able to update an administrated community description with the same type + """ + user = make_user() + headers = make_authentication_headers_for_user(user) + + community = make_community(creator=user) + new_community_description = make_community_description() + + data = { + 'description': new_community_description, + 'type': 'P' + } + + url = self._get_url(community_name=community.name) + + response = self.client.patch(url, data, **headers) + + self.assertEqual(response.status_code, status.HTTP_200_OK) + + community.refresh_from_db() + + self.assertEqual(community.description, new_community_description) + def test_can_update_administrated_community_rules(self): """ should be able to update an administrated community rules