示例#1
0
文件: base.py 项目: fph/indico
    def __init__(self):
        ObjectHolder.__init__(self)
        # These imports are done like this in order to avoid circular imports problems.
        from indico.modules import cssTpls

        ModuleHolder._availableModules = {
            cssTpls.CssTplsModule.id: cssTpls.CssTplsModule
        }
示例#2
0
 def __init__(self):
     """ Creates / Returns a PluginsHolder object,
         which is the "gateway" to all the methods for getting plugin meta-data.
     """
     ObjectHolder.__init__(self)
     if not self.hasKey("globalPluginOptions"):
         self.add(GlobalPluginOptions())
     if len(self._getIdx()) == 0: #no plugins
         self.loadAllPlugins()
示例#3
0
    def __init__(self):
        ObjectHolder.__init__(self)
        # These imports are done like this in order to avoid circular imports problems.
        import MaKaC.modules.news as news
        import MaKaC.modules.cssTpls as cssTpls
        import MaKaC.modules.upcoming as upcoming

        ModulesHolder._availableModules = {
            news.NewsModule.id:news.NewsModule,
            cssTpls.CssTplsModule.id:cssTpls.CssTplsModule,
            upcoming.UpcomingEventsModule.id:upcoming.UpcomingEventsModule
        }
示例#4
0
文件: base.py 项目: jacquesd/indico
    def __init__(self):
        ObjectHolder.__init__(self)
        # These imports are done like this in order to avoid circular imports problems.
        from indico.modules import news
        from indico.modules import cssTpls
        from indico.modules import upcoming

        ModuleHolder._availableModules = {
            news.NewsModule.id: news.NewsModule,
            cssTpls.CssTplsModule.id: cssTpls.CssTplsModule,
            upcoming.UpcomingEventsModule.id: upcoming.UpcomingEventsModule,
        }
示例#5
0
文件: db.py 项目: Ictp/indico
 def update(self, old_token, new_token):
     ObjectHolder.remove(self, old_token)
     Catalog.getIdx('user_oauth_request_token').unindex_obj(old_token)
     ObjectHolder.add(self, new_token)
     Catalog.getIdx('user_oauth_request_token').index_obj(new_token)
示例#6
0
文件: db.py 项目: Ictp/indico
 def remove(self, token):
     ObjectHolder.remove(self, token)
     Catalog.getIdx('user_oauth_request_token').unindex_obj(token)
示例#7
0
文件: db.py 项目: Ictp/indico
 def add(self, token):
     ObjectHolder.add(self, token)
     Catalog.getIdx('user_oauth_request_token').index_obj(token)
示例#8
0
 def _newId( self ):
     id = ObjectHolder._newId( self )
     return "%s"%id
示例#9
0
文件: domain.py 项目: NIIF/indico
 def remove(self, item):
     # METHOD HAS TO BE IMPLEMENTED...
     ObjectHolder.remove(self, item)
     TrashCanManager().add(item)
示例#10
0
文件: undo_merge.py 项目: NIIF/indico
def split_avatars(file):
    """Step 2: Split the merged avatars - run this on the POST-MERGE database"""
    data = json.load(file)
    if len(data) != 2:
        echo('Invalid data: Expected two items, found {}'.format(len(data)))
        raise click.Abort()
    avatars = [AvatarHolder().getById(x['id']) for x in data]
    if avatars.count(None) != 1:
        echo('Expected exactly one unreferenced avatar, got {}'.format(avatars))
        raise click.Abort()
    if avatars[0] is None:
        orig = avatars[1]
        orig_data = data[1]
        merged_data = data[0]
    else:
        orig = avatars[0]
        orig_data = data[0]
        merged_data = data[1]
    merged = [av for av in orig._mergeFrom if av.getId() == merged_data['id']]
    if len(merged) != 1:
        echo("Avatars don't seem to be merged into each other")
        raise click.Abort()
    merged = merged[0]
    if merged not in orig._mergeFrom or merged._mergeTo != orig:
        echo("Avatars don't seem to be merged into each other")
        raise click.Abort()
    # Remove merge references
    orig._mergeFrom.remove(merged)
    merged._mergeTo = None
    # Clean secondary emails
    orig.setSecondaryEmails(orig_data['secondary_emails'])
    merged.setSecondaryEmails(merged_data['secondary_emails'])
    # Clean identities
    for identity in merged.getIdentityList(create_identities=True):
        orig.removeIdentity(identity)
        identity.setUser(merged)
    # Re-index the avatars
    # noinspection PyCallByClass
    ObjectHolder.add(AvatarHolder(), merged)
    for index in {'organisation', 'email', 'name', 'surName', 'status'}:
        IndexesHolder().getById(index).unindexUser(orig)
        IndexesHolder().getById(index).indexUser(orig)
        IndexesHolder().getById(index).indexUser(merged)
    # Restore links for the merged avatar
    for key, links in merged_data['links'].iteritems():
        objtype, role = key.split('.')
        for link in links:
            # TODO: Add extra items here as necessary (use show_links to check if anything is missing)!
            if objtype == 'conference':
                event = ConferenceHolder().getById(link, quiet=True)
                if event is None:
                    echo('Event not found: {}'.format(link))
                    continue
                if event not in set(orig.linkedTo[objtype][role]):
                    echo('{!r} not linked to avatar via {}'.format(event, key))
                    continue
                if role == 'access':
                    event.revokeAccess(orig)
                    event.grantAccess(merged)
                else:
                    echo('Unexpected link type: {}'.format(key))
                    raise click.Abort()
                # print 'Updated {} - {!r}'.format(key, event)
            elif objtype == 'contribution':
                event_id, contrib_id = link
                event = ConferenceHolder().getById(event_id)
                if event is None:
                    echo('Event not found: {}'.format(event_id))
                    continue
                contrib = event.getContributionById(contrib_id)
                if contrib is None:
                    echo('Contrib not found: {}.{}'.format(event_id, contrib_id))
                    continue
                if contrib not in set(orig.linkedTo[objtype][role]):
                    echo('{} not linked to avatar via {}'.format(contrib, key))
                    continue
                if role == 'submission':
                    contrib.revokeSubmission(orig)
                    contrib.grantSubmission(merged)
                elif role == 'manager':
                    contrib.revokeModification(orig)
                    contrib.grantModification(merged)
                else:
                    echo('Unexpected link type: {}'.format(key))
                    raise click.Abort()
                # print 'Updated {} - {}'.format(key, contrib)
            else:
                # This results in inconsistent data in redis, but since we flush the redis
                # links after a successful merge, that's not an issue. Also, we only reach
                # this branch if someone is using different versions of this script...
                echo('Unexpected link type: {}'.format(key))
                raise click.Abort()
    if not click.confirm('Do you want to commit the changes now?'):
        transaction.abort()  # not really necessary, but let's stay on the safe side
        raise click.Abort()
    transaction.commit()
    # Refresh redis links
    avatar_links.delete_avatar(orig)
    avatar_links.delete_avatar(merged)
    avatar_links.init_links(orig)
    avatar_links.init_links(merged)
    # Delete suggestions
    suggestions.delete_avatar(orig)
    suggestions.delete_avatar(merged)