Esempio n. 1
0
def dispatch_annotation_request( request, id = None):
    from features.default import views as default_views
    from features.ordering import views as ordering_views
    
    if id is None:
        if "locationID" in request.REQUEST and "type" in request.REQUEST:
            try:
                category = None
                if request.REQUEST["type"] == "ENV":
                    category = Environment.objects.get(id=request.REQUEST["locationID"]).category
                elif request.REQUEST["type"] == "AREA":
                    category = Area.objects.get(id=request.REQUEST["locationID"]).category
                
                if category is None:
                    return bad_request_error("Annotation", msg = "No zone type (area/environment) identified.")
                else:
                    if category == "default":
                        return default_views.handle_annotation_request(request, id = id)
                    elif category == "ordering":
                        return ordering_views.handle_annotation_request(request, id = id)
                    else:
                        return bad_request_error("Annotation", msg = "Wrong category specification for associated environment/area.")
                
            except Exception, ex:
                return bad_request_error("Annotation", msg = "No zone type (area/environment) identified.")
        else:
            return bad_request_error("Annotation", msg = "No location id or zone type (area/environment) specified.")
Esempio n. 2
0
def dispatch_annotation_request(request, id=None):
    from features.default import views as default_views
    from features.ordering import views as ordering_views

    if id is None:
        if "locationID" in request.REQUEST and "type" in request.REQUEST:
            try:
                category = None
                if request.REQUEST["type"] == "ENV":
                    category = Environment.objects.get(
                        id=request.REQUEST["locationID"]).category
                elif request.REQUEST["type"] == "AREA":
                    category = Area.objects.get(
                        id=request.REQUEST["locationID"]).category

                if category is None:
                    return bad_request_error(
                        "Annotation",
                        msg="No zone type (area/environment) identified.")
                else:
                    if category == "default":
                        return default_views.handle_annotation_request(request,
                                                                       id=id)
                    elif category == "ordering":
                        return ordering_views.handle_annotation_request(
                            request, id=id)
                    else:
                        return bad_request_error(
                            "Annotation",
                            msg=
                            "Wrong category specification for associated environment/area."
                        )

            except Exception, ex:
                return bad_request_error(
                    "Annotation",
                    msg="No zone type (area/environment) identified.")
        else:
            return bad_request_error(
                "Annotation",
                msg="No location id or zone type (area/environment) specified."
            )
Esempio n. 3
0
            try:
                annotation = Annotation.objects.get(id=id)
                category = None
                    
                if not annotation.env is None:
                    category = annotation.env.category
                elif not annotation.area is None:
                    category = annotation.area.category
                    
                if category is None:
                    return not_found_error("Annotation")
                else:
                    if category == "default":
                        return default_views.handle_annotation_request(request, id = id)
                    elif category == "ordering":
                        return ordering_views.handle_annotation_request(request, id = id)
                    else:
                        return bad_request_error("Annotation", msg = "Wrong category specification for associated environment/area.")
                        
            except Exception, ex:
                return not_found_error("Annotation")
        else:
            not_allowed_error("Annotation", msg = "GET method not allowed. ")




def handle_history_request(request, userID):
    pass

Esempio n. 4
0
                annotation = Annotation.objects.get(id=id)
                category = None

                if not annotation.env is None:
                    category = annotation.env.category
                elif not annotation.area is None:
                    category = annotation.area.category

                if category is None:
                    return not_found_error("Annotation")
                else:
                    if category == "default":
                        return default_views.handle_annotation_request(request,
                                                                       id=id)
                    elif category == "ordering":
                        return ordering_views.handle_annotation_request(
                            request, id=id)
                    else:
                        return bad_request_error(
                            "Annotation",
                            msg=
                            "Wrong category specification for associated environment/area."
                        )

            except Exception, ex:
                return not_found_error("Annotation")
        else:
            not_allowed_error("Annotation", msg="GET method not allowed. ")


def handle_history_request(request, userID):
    pass