def processView(self): if self.user.admin == False: raise HTTPNotFound error_summary = {} userID = self.request.matchdict["user"] data = getUserDetails(self.request, userID) menus = listMenus(self.request) if self.request.method == "POST": if "edit" in self.request.POST: data = self.getPostDict() modified, message = modifyUser( self.request, userID, data["user_name"], data["user_telef"], data["user_email"], data["menu_id"], ) if modified: return HTTPFound(location=self.request.route_url("users")) return { "error_summary": error_summary, "data": data, "menus": menus, "userid": userID, }
def processView(self): if self.user.admin == False: raise HTTPNotFound error_summary = {} userID = self.request.matchdict["user"] data = getUserDetails(self.request, userID) menus = listMenus(self.request) if self.request.method == "POST": if "edit" in self.request.POST: data = self.getPostDict() if data["password1"] != "": if data["password1"] == data["password2"]: modified, message = modifyPassword( self.request, userID, data["password1"] ) if modified: return HTTPFound(location=self.request.route_url("users")) else: error_summary["password1"] = self._( "The password and its confirmation are not the same" ) else: error_summary["password1"] = self._("The password cannot be blank") return { "error_summary": error_summary, "data": data, "menus": menus, "userid": userID, }
def processView(self): if self.user.admin == False: raise HTTPNotFound error_summary = {} data = {} subCounties = getSubCounties(self.request) menus = listMenus(self.request) if self.request.method == "POST": if "add" in self.request.POST: data = self.getPostDict() if data["user_id"] != "": if data["password1"] != "": if data["password1"] == data["password2"]: parts = data["district"].split("-") if len(parts) == 2: added, message = addUser( self.request, data["user_id"], data["user_name"], data["user_telef"], data["user_email"], parts[0], parts[1], data["password1"], data["menu_id"], ) if added: return HTTPFound( location=self.request.route_url("users") ) else: error_summary["error"] = message else: error_summary["district"] = self._( "You need to select a district" ) else: error_summary["password1"] = self._( "The password and its confirmation are not the same" ) else: error_summary["password1"] = self._( "The password cannot be blank" ) else: error_summary["user_id"] = self._("The user ID cannot be blank") return { "error_summary": error_summary, "data": data, "subcounties": subCounties, "menus": menus, }
def processView(self): error_summary = {} data = {} subCounties = getSubCounties(self.request) menus = listMenus(self.request) if self.request.method == "POST": if "add" in self.request.POST: data = self.getPostDict() if data["group_sname"] != "": if data["group_name"] != "": if data["group_ward"] != "": parts = data["district"].split("-") if len(parts) == 2: added, message = addGroup( self.request, data["group_name"], data["group_twoword"], data["group_ward"], data["group_sname"], parts[0], parts[1], self.user.id, data["menu_id"], ) if added: addFormToGroup(self.request, message) return HTTPFound(location=self.request. route_url("groups")) else: error_summary["error"] = message else: error_summary["district"] = self._( "You need to select a district") else: error_summary["group_ward"] = self._( "The ward cannot be empty") else: error_summary["group_name"] = self._( "The full name cannot be empty") else: error_summary["group_sname"] = self._( "The name cannot be empty") return { "error_summary": error_summary, "data": data, "subcounties": subCounties, "menus": menus, }
def processView(self): groupID = self.request.matchdict["group"] data = getGroupDetails(self.request, groupID) error_summary = {} menus = listMenus(self.request) if self.request.method == "POST": data = self.getPostDict() editGroup( self.request, groupID, data["group_name"], data["group_twoword"], data["group_ward"], data["menu_id"], ) return HTTPFound(location=self.request.route_url("groups")) return { "error_summary": error_summary, "data": data, "groupid": groupID, "menus": menus, }
def processView(self): menus = listMenus(self.request) return {"menus": menus}