Exemple #1
0
 def offers(request, pk):
     """ Endpoint to get offers for organization """
     organization = get_object_or_404(Organization, id=pk)
     if logged_as_admin(request):
         offers = organization.offer_set.get_for_administrator()
     else:
         offers = organization.offer_set.get_weightened()
     return Response(
         serializers.OfferSerializer(
             offers,
             many=True,
             context={'request': request}).data,
         status=status.HTTP_200_OK)
Exemple #2
0
 def offers(request, pk):
     """ Endpoint to get offers for organization """
     organization = get_object_or_404(Organization, id=pk)
     is_user_org_member = False
     if request.user.is_authenticated:
         if organization in request.user.userprofile.organizations.all():
             is_user_org_member = True
     if logged_as_admin(request) or is_user_org_member:
         offers = organization.offer_set.get_for_administrator()
     else:
         offers = organization.offer_set.get_weightened()
     return Response(serializers.OfferSerializer(offers,
                                                 many=True,
                                                 context={
                                                     'request': request
                                                 }).data,
                     status=status.HTTP_200_OK)