Ejemplo n.º 1
0
    def processView(self):
        menuID = self.request.matchdict["menu"]
        itemID = self.request.matchdict["item"]
        menus = getAllItems(self.request, itemID)
        menuName = getMenuName(self.request, menuID)
        error_summary = {}
        data = getItemData(self.request, itemID)
        if data["next_item"] is None:
            data["next_item"] = "None"
        if data["audio_id"] is None:
            data["audio_id"] = "None"
        audios = listPodcasts(self.request)
        data["item_type"] = str(data["item_type"])
        if self.request.method == "POST":
            if "edit" in self.request.POST:
                data = self.getPostDict()
                if data["item_name"] != "":
                    if data["item_type"] != "3" and data["item_desc"] == "":
                        error_summary["item_desc"] = self._(
                            "The item needs content")
                    else:
                        if data["next_item"] == "None":
                            data["next_item"] = None
                        if data["audio_id"] == "None":
                            data["audio_id"] = None
                        modified, message = modifyItem(
                            self.request,
                            itemID,
                            data["item_type"],
                            data["item_name"],
                            data["item_desc"],
                            data["next_item"],
                            data["audio_id"],
                        )
                        if modified:
                            return HTTPFound(location=self.request.route_url(
                                "items", menu=menuID))
                        else:
                            error_summary["error"] = message
                else:
                    error_summary["item_name"] = self._(
                        "The name cannot be empty")

        return {
            "menus": menus,
            "menuid": menuID,
            "menuname": menuName,
            "error_summary": error_summary,
            "data": data,
            "itemid": itemID,
            "audios": audios,
        }
Ejemplo n.º 2
0
 def processView(self):
     menuID = self.request.matchdict["menu"]
     itemID = self.request.matchdict["item"]
     responses = listResponses(self.request, itemID)
     menuName = getMenuName(self.request, menuID)
     itemName = getItemName(self.request, itemID)
     return {
         "responses": responses,
         "menuid": menuID,
         "menuname": menuName,
         "itemid": itemID,
         "itemname": itemName,
     }
Ejemplo n.º 3
0
    def processView(self):
        menuID = self.request.matchdict["menu"]
        itemID = self.request.matchdict["item"]
        responses = listResponses(self.request, menuID)
        menuName = getMenuName(self.request, menuID)
        itemName = getItemName(self.request, itemID)
        menus = getAllItems(self.request, itemID)
        error_summary = {}
        data = {}
        if self.request.method == "POST":
            if "add" in self.request.POST:
                data = self.getPostDict()
                if data["target_item"] != "":
                    if data["resp_num"] != "":
                        added, message = addRenponse(self.request, itemID,
                                                     data["resp_num"],
                                                     data["target_item"])
                        if added:
                            return HTTPFound(location=self.request.route_url(
                                "responses", menu=menuID, item=itemID))
                        else:
                            error_summary["error"] = message
                    else:
                        error_summary["resp_num"] = self._(
                            "You need to indicate a response number")
                else:
                    error_summary["target_item"] = self._(
                        "You need to indicate a target item")

        return {
            "responses": responses,
            "menuid": menuID,
            "menuname": menuName,
            "itemid": itemID,
            "itemname": itemName,
            "error_summary": error_summary,
            "data": data,
            "menus": menus,
        }
Ejemplo n.º 4
0
 def processView(self):
     menuID = self.request.matchdict["menu"]
     items = listItems(self.request, menuID)
     menuName = getMenuName(self.request, menuID)
     return {"items": items, "menuid": menuID, "menuname": menuName}