Beispiel #1
0
 def create(self, request):
     serializer = serializers.PingDataPOSTSerializer(data=request.data)
     serializer.is_valid(raise_exception=True)
     try:
         result = serializer.create()
         return util.createResponse(True, 200, result, '')
     except Exception as err:
         return util.createResponse(False, 500, {}, str(err))
Beispiel #2
0
 def delete(self, request, pk):
     context = {'id': pk}
     serializer = serializers.PingDataPATCHSerializer(context=context)
     try:
         result = serializer.delete()
         return util.createResponse(True, 200, result, '')
     except models.PingData.DoesNotExist as err:
         return util.createResponse(False, 404, {}, str(err))
     except Exception as err:
         return util.createResponse(False, 500, {}, str(err))
Beispiel #3
0
 def partial_update(self, request, pk):
     context = {'id': pk}
     serializer = serializers.PingDataPATCHSerializer(data=request.data,
                                                      context=context)
     serializer.is_valid(raise_exception=True)
     try:
         result = serializer.partial_update()
         return util.createResponse(True, 200, result, '')
     except models.PingData.DoesNotExist as err:
         return util.createResponse(False, 404, {}, str(err))
     except Exception as err:
         return util.createResponse(False, 500, {}, str(err))
Beispiel #4
0
 def list(self, request):
     # # The following code is for testing facebook login with oauth social
     # print('Lemus Acá!!!!')
     # print(request.user)
     #
     # graph = facebook.GraphAPI('EAAK9u5tazckBAD9ggqeUllvGS6np5yklVXd53fuzY3f8YihsBF6WFc7NmYRR3ZCGuGJobj3eZAjbxBn4x8k57V6tTAzQaMkq1znJswVX1U5lLMv6DdQmvYCikbFV4dVorFs4kdgxfJQBwuczmZA5rhyTtUZAyZAYiEpVVZBcZBWkdiGb3Kmsx4osUq1xRZAY0CIZD')
     # args = {'fields': 'id,name,email,last_name,first_name,picture,age_range,gender'}
     #
     # profile = graph.get_object("me", **args)
     # print(profile)
     serializer = serializers.PingDataGETSerializer()
     try:
         result = serializer.list()
         return util.createResponse(True, 200, result, '')
     except Exception as err:
         return util.createResponse(False, 500, {}, str(err))