def update(self):
        result = {}
        site = get_site_folder(True, self.request)
        user = get_current(self.request)
        is_manager = has_any_roles(
            user=user,
            roles=('Admin', ('SiteAdmin', site))) or\
            is_site_moderator(self.request)
        duplicates = find_duplicates_artist(self.context, self.duplicates_state)
        diff_bodies = {}
        context_view = self.content(
            args={'object': self.context},
            template=self.context.templates.get('diff', None))['body']

        for duplicate in duplicates:
            duplicate_view = self.content(
                args={'object': duplicate},
                template=duplicate.templates.get('diff', None))['body']
            soupt, textdiff = html_diff_wrapper.render_html_diff(
                context_view, duplicate_view)
            diff_bodies[duplicate] = (textdiff, get_oid(duplicate))

        values = {'context': self.context,
                  'oid': get_oid(self.context),
                  'context_view': context_view,
                  'contents': diff_bodies,
                  'row_len': math.ceil(len(diff_bodies)/2),
                  'is_manager': is_manager,
                  'view': self}
        body = self.content(args=values, template=self.template)['body']
        item = self.adapt_item(body, self.viewid)
        result['coordinates'] = {self.coordinates: [item]}
        return result
示例#2
0
def clean_artists_duplicates(root, registry):
    from lac.views.filter import find_entities
    from lac.content.interface import IArtistInformationSheet
    from lac.utilities.duplicates_utility import (
        find_duplicates_artist)

    contents = find_entities(interfaces=[IArtistInformationSheet])
    len_entities = str(len(contents))
    for index, artist in enumerate(contents):
        if artist and artist.__parent__ and not artist.author:
            duplicates = find_duplicates_artist(artist)
            if duplicates:
                duplicates.append(artist)
                publisheds = [v for v in duplicates if 'published' in v.state]
                published = publisheds[0] if publisheds else artist
                duplicates.remove(published)
                for dup in duplicates:
                    replaced = dup.replace_by(published)
                    if replaced:
                        root.delfromproperty('artists', dup)

        if index % 1000 == 0:
            log.info("**** Commit ****")
            transaction.commit()

        log.info(str(index) + "/" + len_entities)

    log.info('Clean artists evolved.')
示例#3
0
def clean_artists_duplicates(root, registry):
    from lac.views.filter import find_entities
    from lac.content.interface import IArtistInformationSheet
    from lac.utilities.duplicates_utility import (find_duplicates_artist)

    contents = find_entities(interfaces=[IArtistInformationSheet])
    len_entities = str(len(contents))
    for index, artist in enumerate(contents):
        if artist and artist.__parent__ and not artist.author:
            duplicates = find_duplicates_artist(artist)
            if duplicates:
                duplicates.append(artist)
                publisheds = [v for v in duplicates if 'published' in v.state]
                published = publisheds[0] if publisheds else artist
                duplicates.remove(published)
                for dup in duplicates:
                    replaced = dup.replace_by(published)
                    if replaced:
                        root.delfromproperty('artists', dup)

        if index % 1000 == 0:
            log.info("**** Commit ****")
            transaction.commit()

        log.info(str(index) + "/" + len_entities)

    log.info('Clean artists evolved.')
示例#4
0
def merge_artists(artists):
    root = getSite()
    new_artists = []
    from lac.utilities.duplicates_utility import (find_duplicates_artist)
    for artist in artists:
        old_artists = find_duplicates_artist(artist)
        published_old_artists = [
            a for a in old_artists if 'published' in a.state
        ]
        if old_artists:
            old_artist = published_old_artists[0] if \
                published_old_artists else old_artists[0]
            new_artists.append(old_artist)
        else:
            new_artists.append(artist)
            artist.state = PersistentList(['editable'])
            root.addtoproperty('artists', artist)
            artist.reindex()
            import transaction
            transaction.commit()

    return new_artists
def merge_artists(artists):
    root = getSite()
    new_artists = []
    from lac.utilities.duplicates_utility import (
        find_duplicates_artist)
    for artist in artists:
        old_artists = find_duplicates_artist(artist)
        published_old_artists = [a for a in old_artists
                                 if 'published' in a.state]
        if old_artists:
            old_artist = published_old_artists[0] if \
                published_old_artists else old_artists[0]
            new_artists.append(old_artist)
        else:
            new_artists.append(artist)
            artist.state = PersistentList(['editable'])
            root.addtoproperty('artists', artist)
            artist.reindex()
            import transaction
            transaction.commit()

    return new_artists
示例#6
0
    def update(self):
        result = {}
        site = get_site_folder(True, self.request)
        user = get_current(self.request)
        is_manager = has_any_roles(
            user=user,
            roles=('Admin', ('SiteAdmin', site))) or\
            is_site_moderator(self.request)
        duplicates = find_duplicates_artist(self.context,
                                            self.duplicates_state)
        diff_bodies = {}
        context_view = self.content(args={'object': self.context},
                                    template=self.context.templates.get(
                                        'diff', None))['body']

        for duplicate in duplicates:
            duplicate_view = self.content(args={'object': duplicate},
                                          template=duplicate.templates.get(
                                              'diff', None))['body']
            soupt, textdiff = html_diff_wrapper.render_html_diff(
                context_view, duplicate_view)
            diff_bodies[duplicate] = (textdiff, get_oid(duplicate))

        values = {
            'context': self.context,
            'oid': get_oid(self.context),
            'context_view': context_view,
            'contents': diff_bodies,
            'row_len': math.ceil(len(diff_bodies) / 2),
            'is_manager': is_manager,
            'view': self
        }
        body = self.content(args=values, template=self.template)['body']
        item = self.adapt_item(body, self.viewid)
        result['coordinates'] = {self.coordinates: [item]}
        return result
示例#7
0
def managedup_processsecurity_validation(process, context):
    objects = find_duplicates_artist(context, ('published',))
    return objects and global_user_processsecurity(process, context)
示例#8
0
 def get_duplicates(self, states=('published', )):
     return find_duplicates_artist(self, states)
示例#9
0
def managedup_processsecurity_validation(process, context):
    objects = find_duplicates_artist(context, ('published', ))
    return objects and global_user_processsecurity(process, context)