Esempio n. 1
0
def dispatch_announcement_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("Announcement", msg = "No zone type (area/environment) identified.")
                else:
                    if category == "default":
                        return default_views.handle_announcement_request(request, id = id)
                    elif category == "ordering":
                        return ordering_views.handle_announcement_request(request, id = id)
                    else:
                        return bad_request_error("Announcement", msg = "Wrong category specification for associated environment/area.")
                    
            except Exception, ex:
                return bad_request_error("Announcement", msg = "No zone type (area/environment) identified.")
        else:
            return bad_request_error("Announcement", msg = "No location id or zone type (area/environment) specified.")
Esempio n. 2
0
def dispatch_announcement_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(
                        "Announcement",
                        msg="No zone type (area/environment) identified.")
                else:
                    if category == "default":
                        return default_views.handle_announcement_request(
                            request, id=id)
                    elif category == "ordering":
                        return ordering_views.handle_announcement_request(
                            request, id=id)
                    else:
                        return bad_request_error(
                            "Announcement",
                            msg=
                            "Wrong category specification for associated environment/area."
                        )

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



def dispatch_annotation_request( request, id = None):
    from features.default import views as default_views
Esempio n. 4
0
    else:
        if request.method != "GET":
            try:
                announcement = Announcement.objects.get(id=id)
                category = None

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

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

            except Exception, ex:
                return not_found_error("Announcement")

        else:
            return not_allowed_error("Announcement",