Beispiel #1
0
def processChildCount(actions):
    '''
    Process the child count for the provided actions list.
    '''
    actions = sorted(actions, key=lambda action: action.Path)
    for k, action in enumerate(actions):
        actionWithCount = Action()
        copy(action, actionWithCount, exclude=('ChildrenCount', ))
        childCount, path = 0, action.Path + '.'
        for i in range(k + 1, len(actions)):
            if actions[i].Path.startswith(path): childCount += 1
            else: break
        actionWithCount.ChildrenCount = childCount
        yield actionWithCount
Beispiel #2
0
def processChildCount(actions):
    '''
    Process the child count for the provided actions list.
    '''
    actions = sorted(actions, key=lambda action: action.Path)
    for k, action in enumerate(actions):
        actionWithCount = Action()
        copy(action, actionWithCount, exclude=('ChildrenCount',))
        childCount, path = 0, action.Path + '.'
        for i in range(k + 1, len(actions)):
            if actions[i].Path.startswith(path): childCount += 1
            else: break
        actionWithCount.ChildrenCount = childCount
        yield actionWithCount
Beispiel #3
0
def menuAction():
    return Action('media-archive',
                  Parent=defaults.menuAction(),
                  Label=NC_('Menu', 'Media Archive'),
                  Href='/media-archive',
                  ScriptPath=getPublishedGui(
                      'media-archive/scripts/js/menu-media-archive.js'))
Beispiel #4
0
def modulesAction():
    '''
    Register default action name: modules
    This node should contain actions to be used inside the application 
    as main modules (whole page for edit/add/etc.)
    '''
    return Action('modules')
Beispiel #5
0
def modulesDashboardAction():
    '''
    Register default action name: modules.dashboard
    This node should contain actions to be used inside the dashboard of the application 
    as main modules (whole page for edit/add/etc.)
    '''
    return Action('dashboard', Parent=modulesAction())
Beispiel #6
0
def modulesAction() -> Action:
    '''
    register image plugin on media archive actions
    '''
    return Action(
        'video',
        Parent=mediaArchiveAction(),
        Script=publishedURI('media-archive-video/scripts/js/media-archive/'))
Beispiel #7
0
    def insert(self, action):
        '''
        @see IActionManagerService.insert
        '''
        assert isinstance(action, Action), 'Invalid action %s' % action
        insertModel(ActionMapped, action)

        path = action.Path
        while '.' in path:
            path = path[:path.rfind('.')]
            if self.session().query(ActionMapped.Path).filter(
                    ActionMapped.Path == path).count():
                break
            insertModel(ActionMapped, Action(Path=path))

        return action.Path
Beispiel #8
0
def modulesManageCollaboratorsAction() -> Action:
    return Action(
        'manage-collaborators',
        Parent=modulesAction(),
        Script=publishedURI('livedesk/scripts/js/manage-collaborators.js'))
Beispiel #9
0
def modulesConfigureAction() -> Action:
    return Action('configure',
                  Parent=modulesAction(),
                  Script=publishedURI('livedesk/scripts/js/configure-blog.js'))
Beispiel #10
0
def modulesConfigureAction():
    return Action('configure',
                  Parent=modulesAction(),
                  ScriptPath=getPublishedGui(
                      'media-archive/scripts/js/configure-media-archive.js'))
Beispiel #11
0
def modulesAddAction() -> Action:
    return Action('add',
                  Parent=modulesAction(),
                  Script=publishedURI('superdesk/article/scripts/js/add.js'))
Beispiel #12
0
def modulesAction() -> Action:
    return Action('livedesk', Parent=defaults.modulesAction())
Beispiel #13
0
def menuAction() -> Action:
    return Action('livedesk',
                  Parent=defaults.menuAction(),
                  Label=NC_('menu', 'Live Blogs'))
Beispiel #14
0
def menuAction() -> Action:
    return Action('article',
                  Parent=defaults.menuAction(),
                  Label=NC_('menu', 'Article'),
                  NavBar='/article',
                  Script=publishedURI('superdesk/article/scripts/js/menu.js'))
Beispiel #15
0
    def process(self, chain, solicit: Solicit, **keyargs):
        '''
        @see: HandlerProcessor.process
        
        Synchronize the actions in the configuration file with the actions in the database.
        '''
        assert isinstance(chain, Chain), 'Invalid chain %s' % chain
        assert isinstance(solicit, Solicit), 'Invalid solicit %s' % solicit
        assert isinstance(
            solicit.repository,
            Repository), 'Invalid repository %s' % solicit.repository

        groups = listBFS(solicit.repository, Repository.children,
                         Repository.actions)

        actionsFromConfig = {}
        # check for actions with the same path -> display warning message
        isWarning = False
        for repository in groups:
            assert isinstance(repository,
                              Repository), 'Invalid repository %s' % repository
            for action in repository.actions:
                if action.path in actionsFromConfig:
                    action1, action2 = action, actionsFromConfig[action.path]
                    diffs = self.compareActions(action1, action2)
                    if diffs:
                        isWarning = True
                        warningId = '%s_%s_%s' % (action.path,
                                                  action1.lineNumber,
                                                  action2.lineNumber)
                        if warningId in self._warnings: continue

                        log.warning(
                            'Attributes: "%s" are different for Action with path="%s" at Line %s and Line %s',
                            ', '.join(diffs), action1.path, action1.lineNumber,
                            action2.lineNumber)
                        self._warnings.add(warningId)

                else:
                    actionsFromConfig[action.path] = action
        # if everything was ok, erase all warnings
        if not isWarning and len(self._warnings) > 0:
            log.warning('Actions OK')
            self._warnings.clear()

        actionsFromDb = set(self.actionManagerService.getAll())

        for action in sorted(actionsFromConfig.values(),
                             key=lambda action: action.path):
            assert isinstance(action,
                              ActionDefinition), 'Invalid action %s' % action
            data = asData(action, ActionDefinition)
            data = {
                modifyFirst(name, True): value
                for name, value in data.items()
            }
            apiAction = copyContainer(data, Action())
            resolved = False
            if action.path not in actionsFromDb:
                try:
                    self.actionManagerService.insert(apiAction)
                    resolved = True
                except:
                    log.warn('Cannot add action %s, maybe already exists' %
                             apiAction.Path)

            if not resolved:
                self.actionManagerService.update(apiAction)
                # except: log.warn('Cannot update action %s' % apiAction.Path)
                actionsFromDb.discard(action.path)

        for path in actionsFromDb:
            self.actionManagerService.delete(path)
Beispiel #16
0
def modulesMainAction() -> Action:
    return Action('list',
                  Parent=modulesAction(),
                  Script=publishedURI('superdesk/article/scripts/js/list.js'))
Beispiel #17
0
def modulesEditAction() -> Action:
    return Action('edit',
                  Parent=modulesAction(),
                  Script=publishedURI('superdesk/article/scripts/js/edit.js'))
Beispiel #18
0
def modulesManageFeedsAction() -> Action:
    return Action('manage-feeds',
                  Parent=modulesAction(),
                  Script=publishedURI('livedesk/scripts/js/manage-feeds.js'))
Beispiel #19
0
def modulesAddAction() -> Action:
    return Action('add',
                  Parent=modulesAction(),
                  Script=publishedURI('livedesk/scripts/js/add-live-blogs.js'))
Beispiel #20
0
def modulesArchiveAction() -> Action:
    return Action('archive',
                  Parent=modulesAction(),
                  Script=publishedURI('livedesk/scripts/js/archive.js'))
Beispiel #21
0
def modulesBlogPublishAction() -> Action:
    return Action('blog-publish',
                  Parent=modulesAction(),
                  Script=publishedURI('livedesk/scripts/js/blog-publish.js'))
Beispiel #22
0
def subMenuAction() -> Action:
    return Action(
        'submenu',
        Parent=menuAction(),
        Script=publishedURI('livedesk/scripts/js/submenu-live-blogs.js'))
Beispiel #23
0
def modulesAction() -> Action:
    return Action('request', Parent=defaults.modulesAction())
Beispiel #24
0
def dashboardAction() -> Action:
    return Action('livedesk',
                  Parent=defaults.modulesDashboardAction(),
                  Script=publishedURI('livedesk/scripts/js/dashboard.js'))
Beispiel #25
0
def modulesAction() -> Action:
    return Action('article', Parent=defaults.modulesAction())
Beispiel #26
0
def modulesBlogEditAction() -> Action:  # TODO: change to view
    return Action(
        'blog-edit',
        Parent=modulesAction(),
        Script=publishedURI('livedesk/scripts/js/edit-live-blogs.js'))
Beispiel #27
0
def modulesAction():
    return Action('media-archive', Parent=defaults.modulesAction())
Beispiel #28
0
def menuAction() -> Action:
    return Action('request',
                  NC_('menu', 'Request'),
                  Parent=defaults.menuAction(),
                  NavBar='/api-requests',
                  Script=publishedURI('superdesk/request/scripts/js/menu.js'))
Beispiel #29
0
def modulesAddAction():
    return Action(
        'add',
        Parent=modulesAction(),
        ScriptPath=getPublishedGui('media-archive/scripts/js/add-media.js'))
Beispiel #30
0
def modulesListAction() -> Action:
    return Action('list',
                  Parent=modulesAction(),
                  Script=publishedURI('superdesk/request/scripts/js/list.js'))
Beispiel #31
0
def modulesMainAction():
    return Action('main',
                  Parent=modulesAction(),
                  ScriptPath=getPublishedGui(
                      'media-archive/scripts/js/media-archive-main.js'))