def add_item(request): system = SystemObject(request) if system.permission.user is None: return HttpResponseRedirect(reverse('core.view.userprofileadmin.login')) system.new() type_module = ModuleType.objects.get(name='Menu') rmodule = RegisteredModule() rmodule.type = type_module rmodule.owner = system.permission.user rmodule.name = ' (Menu)' rmodule.order = 0 rmodule.save() rmodule.sites.add(system.portal.get_active_site()) rmodule.active.add(system.portal.get_active_site()) menuoption = MenuModuleOption() menuoption.menu = system.manager.item menuoption.registered_module = rmodule menuoption.save() """ rootmenuitem = MenuItem() rootmenuitem.noedit = True rootmenuitem.save() rootmenuitem.sites.add(system.portal.get_active_site()) rootmenuitem.active.add(system.portal.get_active_site()) system.language.set_non_existent_language_items(rootmenuitem, MenuItemLanguage) for l in rootmenuitem.languages.all(): l.name = 'Root' l.save() """ return HttpResponseRedirect(reverse('core.view.menu_admin.edit_item', args=(system.manager.item.id,)))
def edit_item(request, itemId): system = SystemObject(request) if system.permission.user is None: return HttpResponseRedirect( reverse('core.view.userprofileadmin.login')) system.manager.fetch_item(itemId) system.manager.set_language(system.language.currentLanguage) menuoption = MenuModuleOption.objects.filter(menu=system.manager.item) if len(menuoption) > 0: menuoption = menuoption[0] else: type_module = ModuleType.objects.get(name='Menu') rmodule = RegisteredModule() rmodule.owner = system.permission.user rmodule.name = ' (Pozycja menu)' rmodule.type = type_module rmodule.order = 0 rmodule.menu = 0 rmodule.save() rmodule.sites.add(system.portal.get_active_site()) rmodule.active.add(system.portal.get_active_site()) rmodule.save() menuoption = MenuModuleOption() menuoption.menu = system.manager.item menuoption.registered_module = rmodule menuoption.save() system.manager.options_item = menuoption system.manager.form_options_class = MenuOptionForm().__class__ system.manager.modelOptions = menuoption result = system.edit_item(request, itemId) system.manager.options_form.choices(system) if result is not None: menuoption.registered_module.name = system.manager.item.name + u' (Menu)' menuoption.registered_module.save() return result system.manager.options_form.choices(system, edit_menu=True) system.manager.form.choices(system) system.template = loader.get_template( system.sheet.get_sheet_file('admin_menu_edit')) c = RequestContext(request, system.get_context()) return HttpResponse(system.template.render(c))
def edit_item(request, itemId): system = SystemObject(request) if system.permission.user is None: return HttpResponseRedirect(reverse('core.view.userprofileadmin.login')) system.manager.fetch_item(itemId) system.manager.set_language(system.language.currentLanguage) menuoption = MenuModuleOption.objects.filter(menu=system.manager.item) if len(menuoption) > 0: menuoption = menuoption[0] else: type_module = ModuleType.objects.get(name='Menu') rmodule = RegisteredModule() rmodule.owner = system.permission.user rmodule.name = ' (Pozycja menu)' rmodule.type = type_module rmodule.order = 0 rmodule.menu = 0 rmodule.save() rmodule.sites.add(system.portal.get_active_site()) rmodule.active.add(system.portal.get_active_site()) rmodule.save() menuoption = MenuModuleOption() menuoption.menu = system.manager.item menuoption.registered_module = rmodule menuoption.save() system.manager.options_item = menuoption system.manager.form_options_class = MenuOptionForm().__class__ system.manager.modelOptions = menuoption result = system.edit_item(request, itemId) system.manager.options_form.choices(system) if result is not None: menuoption.registered_module.name = system.manager.item.name + u' (Menu)' menuoption.registered_module.save() return result system.manager.options_form.choices(system, edit_menu=True) system.manager.form.choices(system) system.template = loader.get_template(system.sheet.get_sheet_file('admin_menu_edit')) c = RequestContext(request, system.get_context()) return HttpResponse(system.template.render(c))
def add_item(request): system = SystemObject(request) if system.permission.user is None: return HttpResponseRedirect( reverse('core.view.userprofileadmin.login')) system.new() type_module = ModuleType.objects.get(name='Menu') rmodule = RegisteredModule() rmodule.type = type_module rmodule.owner = system.permission.user rmodule.name = ' (Menu)' rmodule.order = 0 rmodule.save() rmodule.sites.add(system.portal.get_active_site()) rmodule.active.add(system.portal.get_active_site()) menuoption = MenuModuleOption() menuoption.menu = system.manager.item menuoption.registered_module = rmodule menuoption.save() """ rootmenuitem = MenuItem() rootmenuitem.noedit = True rootmenuitem.save() rootmenuitem.sites.add(system.portal.get_active_site()) rootmenuitem.active.add(system.portal.get_active_site()) system.language.set_non_existent_language_items(rootmenuitem, MenuItemLanguage) for l in rootmenuitem.languages.all(): l.name = 'Root' l.save() """ return HttpResponseRedirect( reverse('core.view.menu_admin.edit_item', args=(system.manager.item.id, )))