def setNewOrder(self, item1, item2): item1 = json.read(item1) item2 = json.read(item2) Model.MenuItems.setNewOrder(item1['id'], item1['order']) Model.MenuItems.setNewOrder(item2['id'], item2['order']) res = json.write({ 'item1_json': Model.MenuItems.getItemById(item1['id']).toJSON(), 'item2_json': Model.MenuItems.getItemById(item2['id']).toJSON() }) return res
def savePluginOptions(self, plugin, values): values = json.read(values) options = getPluginManager().getPluginOptions(plugin) for index, option in enumerate(options): option.value = values[index] option.save() return "ok"
def setTitle(self, data): data = json.read(data) #Update Page with new title Model.Pages.setPageTitle(data['page_id'], data['new_val']) AmiCache.expireCurrentPage() return "ok"
def deleteComments(self, ids, ident=""): ids = json.read(ids) if len(ids) > 0: first_id = ids[0] c = BlogCommentModel.getById(first_id) self._expireCommentCache(first_id) for id in ids: BlogCommentModel.delete(id) return 'ok'
def changeTemplate(self, id): try: exec "from templates.%s import template as m" % json.read(id) old_template_name = getConfig().CURRENT_TEMPLATE.NAME getConfig().CURRENT_TEMPLATE = m AmiCache.expireAllPages() rc = server.getRootController() site_template = m.SiteTemplate() site_edit_template = SiteEditTemplate(m.SiteTemplate) site_template.markChildren() rc.root_obj.template = site_template rc.root_obj.siteedit.template = site_edit_template initTemplate(site_template, 'addToSiteTemplate') initTemplate(site_edit_template, 'addToSiteEditTemplate') server.setTemplateStaticPaths(rc, old_template_name) except Exception, inst: print "'%s' is not a valid template" % inst
def delete(self, id): id = json.read(id) Model.MenuItems.delete(int(id)) return "ok"