def deletemoduletarget(self,**kwargs):
     pages.require("/admin/modules.edit")
     with modulesLock:
        ActiveModules.pop(kwargs['name'])
     #Get rid of any lingering cached events
     newevt.removeModuleEvents(kwargs['name'])
     #Get rid of any permissions defined in the modules.
     auth.importPermissionsFromModules()
     raise cherrypy.HTTPRedirect("/modules")
Example #2
0
 def deletemoduletarget(self,**kwargs):
     pages.require("/admin/modules.edit")
     global moduleschanged
     moduleschanged = True
     with modulesLock:
        ActiveModules.pop(kwargs['name'])
     #Get rid of any lingering cached events
     newevt.removeModuleEvents(kwargs['name'])
     #Get rid of any permissions defined in the modules.
     auth.importPermissionsFromModules()
     usrpages.removeModulePages(kwargs['name'])
     messagebus.postMessage("/system/notifications","User "+ pages.getAcessingUser() + " Deleted module " + kwargs['name'])    
     raise cherrypy.HTTPRedirect("/modules")
Example #3
0
 def deletemoduletarget(self, **kwargs):
     pages.require("/admin/modules.edit")
     global moduleschanged
     moduleschanged = True
     with modulesLock:
         ActiveModules.pop(kwargs['name'])
     #Get rid of any lingering cached events
     newevt.removeModuleEvents(kwargs['name'])
     #Get rid of any permissions defined in the modules.
     auth.importPermissionsFromModules()
     usrpages.removeModulePages(kwargs['name'])
     messagebus.postMessage(
         "/system/notifications", "User " + pages.getAcessingUser() +
         " Deleted module " + kwargs['name'])
     raise cherrypy.HTTPRedirect("/modules")
Example #4
0
    def module(self,module,*path,**kwargs):
        global moduleschanged

        #If we are not performing an action on a module just going to its page
        if not path:
            pages.require("/admin/modules.view")
            return pages.get_template("modules/module.html").render(module = ActiveModules[module],name = module)
            
        else:
            #This gets the interface to add a page
            if path[0] == 'addresource':
                #path[1] tells what type of resource is being created and addResourceDispatcher returns the appropriate crud screen
                return addResourceDispatcher(module,path[1])

            #This case handles the POST request from the new resource target
            if path[0] == 'addresourcetarget':
                return addResourceTarget(module,path[1],kwargs['name'],kwargs)

            #This case shows the information and editing page for one resource
            if path[0] == 'resource':
                return resourceEditPage(module,path[1])

            #This goes to a dispatcher that takes into account the type of resource and updates everything about the resource.
            if path[0] == 'updateresource':
                return resourceUpdateTarget(module,path[1],kwargs)

            #This returns a page to delete any resource by name
            if path[0] == 'deleteresource':
                pages.require("/admin/modules.edit")
                return pages.get_template("modules/deleteresource.html").render(module=module)

            #This handles the POST request to actually do the deletion
            if path[0] == 'deleteresourcetarget':
                pages.require("/admin/modules.edit")
                moduleschanged = True
                with modulesLock:
                   r = ActiveModules[module].pop(kwargs['name'])
                   
                if r['resource-type'] == 'page':
                    usrpages.removeOnePage(module,kwargs['name'])
                #Annoying bookkeeping crap to get rid of the cached crap
                if r['resource-type'] == 'event':
                    newevt.removeOneEvent(module,kwargs['name'])
                    
                if r['resource-type'] == 'permission':
                    auth.importPermissionsFromModules() #sync auth's list of permissions
                    
                messagebus.postMessage("/system/notifications","User "+ pages.getAcessingUser() + " deleted resource " +
                           kwargs['name'] + " from module " + module)    
                raise cherrypy.HTTPRedirect('/modules')

            #This is the target used to change the name and description(basic info) of a module  
            if path[0] == 'update':
                pages.require("/admin/modules.edit")
                moduleschanged = True
                with modulesLock:
                    ActiveModules[module]['__description']['text'] = kwargs['description']
                    ActiveModules[kwargs['name']] = ActiveModules.pop(module)
                    
                    #UHHG. So very much code tht just syncs data structures.
                    #This gets rid of the cache under the old name
                    newevt.removeModuleEvents(module)
                    usrpages.removeModulePages(module)
                    #And calls this function the generate the new cache
                    bookkeeponemodule(kwargs['name'])
                    #Just for fun, we should probably also sync the permissions
                    auth.importPermissionsFromModules()
                raise cherrypy.HTTPRedirect('/modules/module/'+util.url(kwargs['name']))
Example #5
0
    def module(self, module, *path, **kwargs):
        global moduleschanged

        #If we are not performing an action on a module just going to its page
        if not path:
            pages.require("/admin/modules.view")
            return pages.get_template("modules/module.html").render(
                module=ActiveModules[module], name=module)

        else:
            #This gets the interface to add a page
            if path[0] == 'addresource':
                #path[1] tells what type of resource is being created and addResourceDispatcher returns the appropriate crud screen
                return addResourceDispatcher(module, path[1])

            #This case handles the POST request from the new resource target
            if path[0] == 'addresourcetarget':
                return addResourceTarget(module, path[1], kwargs['name'],
                                         kwargs)

            #This case shows the information and editing page for one resource
            if path[0] == 'resource':
                return resourceEditPage(module, path[1])

            #This goes to a dispatcher that takes into account the type of resource and updates everything about the resource.
            if path[0] == 'updateresource':
                return resourceUpdateTarget(module, path[1], kwargs)

            #This returns a page to delete any resource by name
            if path[0] == 'deleteresource':
                pages.require("/admin/modules.edit")
                return pages.get_template(
                    "modules/deleteresource.html").render(module=module)

            #This handles the POST request to actually do the deletion
            if path[0] == 'deleteresourcetarget':
                pages.require("/admin/modules.edit")
                moduleschanged = True
                with modulesLock:
                    r = ActiveModules[module].pop(kwargs['name'])

                if r['resource-type'] == 'page':
                    usrpages.removeOnePage(module, kwargs['name'])
                #Annoying bookkeeping crap to get rid of the cached crap
                if r['resource-type'] == 'event':
                    newevt.removeOneEvent(module, kwargs['name'])

                if r['resource-type'] == 'permission':
                    auth.importPermissionsFromModules(
                    )  #sync auth's list of permissions

                messagebus.postMessage(
                    "/system/notifications",
                    "User " + pages.getAcessingUser() + " deleted resource " +
                    kwargs['name'] + " from module " + module)
                raise cherrypy.HTTPRedirect('/modules')

            #This is the target used to change the name and description(basic info) of a module
            if path[0] == 'update':
                pages.require("/admin/modules.edit")
                moduleschanged = True
                with modulesLock:
                    ActiveModules[module]['__description']['text'] = kwargs[
                        'description']
                    ActiveModules[kwargs['name']] = ActiveModules.pop(module)

                    #UHHG. So very much code tht just syncs data structures.
                    #This gets rid of the cache under the old name
                    newevt.removeModuleEvents(module)
                    usrpages.removeModulePages(module)
                    #And calls this function the generate the new cache
                    bookkeeponemodule(kwargs['name'])
                    #Just for fun, we should probably also sync the permissions
                    auth.importPermissionsFromModules()
                raise cherrypy.HTTPRedirect('/modules/module/' +
                                            util.url(kwargs['name']))