Esempio n. 1
0
 def _migrate_related_items_annotations(self):
     query = {'portal_type': 'opengever.document.document',
              'object_provides': IHasRelations.__identifier__}
     for obj in self.objects(query, 'Migrate relatedItems annotations'):
         ann = IAnnotations(obj)
         if OLD_KEY in ann:
             ann[NEW_KEY] = ann[OLD_KEY]
             ann.pop(OLD_KEY)
Esempio n. 2
0
 def _migrate_related_items_annotations(self):
     query = {
         'portal_type': 'opengever.document.document',
         'object_provides': IHasRelations.__identifier__
     }
     for obj in self.objects(query, 'Migrate relatedItems annotations'):
         ann = IAnnotations(obj)
         if OLD_KEY in ann:
             ann[NEW_KEY] = ann[OLD_KEY]
             ann.pop(OLD_KEY)
Esempio n. 3
0
    def logout(self):
        """
        Delete any cached localrole information from the request.
        """
        super(TestGroupspaceBehavior, self).logout()
        annotations = IAnnotations(self.request)
        keys_to_remove = []
        for key in annotations.keys():
            if (isinstance(key, basestring)
                    and key.startswith('borg.localrole')):
                keys_to_remove.append(key)

        for key in keys_to_remove:
            annotations.pop(key)
Esempio n. 4
0
    def logout(self):
        """
        Delete any cached localrole information from the request.
        """
        super(TestCasePermissioningTodos, self).logout()
        annotations = IAnnotations(self.request)
        keys_to_remove = []
        for key in annotations.keys():
            if (isinstance(key, basestring)
                    and key.startswith('borg.localrole')):
                keys_to_remove.append(key)
            if (isinstance(key, tuple) and key[0] == 'workspaces'):
                keys_to_remove.append(key)

        for key in keys_to_remove:
            annotations.pop(key)
Esempio n. 5
0
    def migrate(self):
        favorites_moves = []

        catalog = api.portal.get_tool('portal_catalog')
        reporoots = [b.getObject() for b in catalog.unrestrictedSearchResults(
            portal_type='opengever.repository.repositoryroot')]

        for root in reporoots:
            root_path = '/'.join(root.getPhysicalPath())
            annotations = IAnnotations(root).get(ANNOTATION_KEY)
            if not annotations:
                continue

            for old_userid, new_userid in self.principal_mapping.items():
                if old_userid in annotations:
                    # Create target favorites list if it doesn't exist yet
                    if new_userid not in annotations:
                        annotations[new_userid] = PersistentList()

                    # Copy over each entry to new list if not present yet
                    for uuid in annotations[old_userid]:
                        if uuid not in annotations[new_userid]:
                            annotations[new_userid].append(uuid)

                    # Drop favorites for old user ID
                    annotations.pop(old_userid)

                    favorites_moves.append((root_path, old_userid, new_userid))
                    logger.info("Migrated repo favorites for %s (%s -> %s)" % (
                        root_path, old_userid, new_userid))

        results = {
            'favorites': {
                'moved': favorites_moves,
                'copied': [],
                'deleted': []},
        }
        return results
Esempio n. 6
0
    def __call__(self):
        context = self.context

        if 'land-matrix' not in context.getId():
            return "View should be called on the matrix excel file"
        site = getSite()
        anno = IAnnotations(site)
        sheet_number = 0
        fcontents = open_workbook(file_contents=context.file.data)

        for sheet in fcontents.sheets():
            sheet_name = 'matrix_%s' % sheet_number
            matrix = anno.get(sheet_name)

            if matrix:
                anno.pop(sheet_name)
                anno[sheet_name] = OrderedDict()
                matrix = anno[sheet_name]
            else:
                anno[sheet_name] = OrderedDict()
                matrix = anno[sheet_name]
            matrix['header'] = []

            for i in range(sheet.ncols):
                # datatable needs it's heading values to be string as such
                # each header value is converted to string
                matrix['header'].append(str(sheet.cell(0, i).value))

            for row in range(1, sheet.nrows):
                fromv = sheet.cell(row, sheet_number).value

                if fromv not in matrix:
                    matrix[fromv] = []
                matrix_list = matrix[fromv]
                row_values = []

                for col in range(sheet.ncols):
                    cell_value = sheet.cell(row, col).value
                    cell_type = type(cell_value)

                    if cell_type == float:
                        cell_value = truncate(cell_value, 4)
                    elif cell_type == unicode:
                        cell_value = cell_value.strip()
                    row_values.append(cell_value)
                matrix_list.append(row_values)
            sheet_number += 1

        # select categories import, if it runs within a different browserview
        # then the data saved from this logic isn't persisted
        form = self.context.REQUEST.form
        num_of_rows = form.get('num_of_rows', 3)
        matrix = anno["matrix_1"]
        anno["matrix_1"]['select_categories'] = OrderedDict()
        header_values = matrix['header'][0:num_of_rows]

        for value in header_values:
            matrix['select_categories'][value] = []
        matrix_keys = matrix.keys()
        select_categories_keys = matrix['select_categories'].keys()

        for key in matrix_keys[1:-1]:
            rows = matrix[key]

            for row in rows:
                for idx, single_row in enumerate(row[0:num_of_rows]):
                    category_list = anno["matrix_1"]['select_categories'][
                        select_categories_keys[idx]]

                    if single_row not in category_list:
                        category_list.append(single_row)

        return "Ok"
 def _clear_recently_touched_mapping(self):
     annotations = IAnnotations(self.portal)
     annotations.pop(RECENTLY_TOUCHED_KEY, None)
 def _clear_recently_touched_mapping(self):
     annotations = IAnnotations(self.portal)
     annotations.pop(RECENTLY_TOUCHED_KEY, None)
Esempio n. 9
0
    def remove_custom_initial_version_comment(self):
        annotations = IAnnotations(self.document)

        if CUSTOM_INITIAL_VERSION_COMMENT in annotations:
            annotations.pop(CUSTOM_INITIAL_VERSION_COMMENT)
Esempio n. 10
0
    def remove_custom_initial_version_comment(self):
        annotations = IAnnotations(self.document)

        if CUSTOM_INITIAL_VERSION_COMMENT in annotations:
            annotations.pop(CUSTOM_INITIAL_VERSION_COMMENT)