Exemplo n.º 1
0
def event_detail(request, event_id):
    try:
        error = helper.check_id_valid(event_id)
        if error:
            errors = {
                "code": 400,
                "message": "%s" % error,
                "fields": "event_id"
            }
            return Response(errors, status=400)

        event_list = Event.objects.get(pk=event_id)
        serializer = EventsSerializer(event_list, many=False)
        return Response(serializer.data)
    except Event.DoesNotExist, e:
        error = {"code": 400, "message": "%s" % e, "fields": "id"}
        return Response(error, status=400)
Exemplo n.º 2
0
def game_detail(request, game_id):
    try:
        error = helper.check_id_valid(game_id)
        if error:
            errors = {
                "code": 400,
                "message": "%s" % error,
                "fields": "game_id"
            }
            return Response(errors, status=400)

        game_detail = Game.objects.get(pk=game_id)
        serializer = GameDetailSerializer(game_detail, many=False)
        return Response(serializer.data)
    except Game.DoesNotExist, e:
        error = {"code": 400, "message": "%s" % e, "fields": "game_id"}
        return Response(error, status=400)
Exemplo n.º 3
0
def game_types_by_category(request, category_id):
    try:
        error = helper.check_id_valid(category_id)
        if not helper.is_empty(error):
            errors = {
                "code": 400,
                "message": "%s" % error,
                "fields": "type_id"
            }
            return Response(errors, status=400)

        game_types = Type.objects.filter(category_id=category_id)
        serializer = TypeSerializer(game_types, many=True)
        return Response(serializer.data)
    except Exception, e:
        error = {"code": 500, "message": "%s" % e, "fields": ""}
        return Response(error, status=500)
Exemplo n.º 4
0
def games(request):
    try:
        game_type_id = request.GET.get("type_id")
        error = helper.check_id_valid(game_type_id)
        if not helper.is_empty(error):
            errors = {
                "code": 400,
                "message": "%s" % error,
                "fields": "type_id"
            }
            return Response(errors, status=400)

        game_list = Game.objects.filter(is_draft=False,
                                        game_type_id=game_type_id)
        serializer = GameSerializer(game_list, many=True)
        return Response(serializer.data)
    except Exception, e:
        error = {"code": 500, "message": "%s" % e, "fields": ""}
        return Response(error, status=500)
Exemplo n.º 5
0
def posts(request):
    # TODO : Posts_image in request /posts is required?
    try:
        type_id = request.GET.get("type_id")

        error = helper.check_id_valid(type_id)
        if error:
            errors = {
                "code": 400,
                "message": "%s" % error,
                "fields": "type_id"
            }
            return Response(errors, status=400)

        post_list = Post.objects.filter(is_draft=False, post_type_id=type_id)
        print "description type ", post_list[0].post_type.description
        serializer = PostsSerializer(post_list, many=True)
        return Response(serializer.data)
    except Exception, e:
        error = {"code": 500, "message": "%s" % e, "fields": ""}
        return Response(error, status=500)