Skip to content

Commit

Permalink
Merge pull request #4853 from onepercentclub/hotfix/slot-contributor
Browse files Browse the repository at this point in the history
Fix the current user slot participant
  • Loading branch information
gannetson committed Nov 24, 2021
2 parents 40dde7b + 784378d commit ca208e7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions bluebottle/activities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class JSONAPIMeta(object):
'initiative',
'goals',
'goals.type',
'initiative.owner',
'initiative.place',
'initiative.location',
'initiative.activity_managers',
Expand Down
21 changes: 20 additions & 1 deletion bluebottle/bb_accounts/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OrganizationFactory, OrganizationContactFactory
)
from bluebottle.test.factory_models.geo import CountryFactory, PlaceFactory
from bluebottle.test.utils import BluebottleTestCase
from bluebottle.test.utils import BluebottleTestCase, APITestCase

ASSERTION_MAPPING = {
'assertion_mapping': {
Expand Down Expand Up @@ -754,3 +754,22 @@ def test_token_expired(self):
data={'user_id': self.user.pk, 'token': token}
)
self.assertEqual(response.status_code, 404)


class MemberDetailViewAPITestCase(APITestCase):
def setUp(self):
super().setUp()
self.user1 = BlueBottleUserFactory()
self.user2 = BlueBottleUserFactory()
self.model = self.user1
self.url = reverse('member-detail', args=(self.user1.id,))

def test_get_current_user(self):
self.perform_get(user=self.user1)
self.assertStatus(status.HTTP_200_OK)
self.assertEqual(self.response.data['id'], self.user1.id)

def test_get_other_user(self):
self.perform_get(user=self.user2)
self.assertStatus(status.HTTP_200_OK)
self.assertEqual(self.response.data['id'], self.user1.id)
7 changes: 1 addition & 6 deletions bluebottle/bb_accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,7 @@ class MemberDetail(JsonApiViewMixin, AutoPrefetchMixin, RetrieveAPIView):
queryset = USER_MODEL.objects.all()
serializer_class = MemberSerializer

permission_classes = (CurrentUserPermission, )

def get_object(self):
if isinstance(self.request.user, AnonymousUser):
raise Http404()
return self.request.user
permission_classes = [IsAuthenticatedOrOpenPermission]


class CurrentUser(RetrieveAPIView):
Expand Down

0 comments on commit ca208e7

Please sign in to comment.