Esempio n. 1
0
    def update(self):
        # As structure is assigned by the parent/manager, we can use it
        # to determine the state of the migrate button and others.

        result = getExposureFileType(self, self.structure['file_type'])
        if result:
            title, views, tags, selected_view = result
            if views is None:
                self.label = '%s %s' % (self.label, 'not found')
                self.status = _(
                    u"Could not find the original file type definition that "
                    "defined this file."
                )
            else:
                self.label = '%s %s' % (self.label, title)
                previous_views = [v for v, n in self.structure['views']]
                self.showMigrateButton = previous_views != views
                if self.showMigrateButton:
                    self.status = _(
                        u"This file has an updated file type definition. "
                        "Select `migrate subgroup` to make use of the new "
                        "format."
                    )

        else:
            # Catalog got nuked?
            self.label = '%s %s' % (self.label, 'unknown')
            self.status = _(u"Catalog unavailable.")

        return super(ExposureFileTypeAnnotatorWizardGroup, self).update()
Esempio n. 2
0
    def handleNext(self, action):
        data, errors = self.extractData()
        group_names = None
        if 'annotators' in data and data['annotators']:
            group_names = list(data['annotators'])

        if group_names is None:
            result = getExposureFileType(self, data['eftypes'])
            if result is None:
                # abort, since there really is no catalog, let the user
                # know.
                self.status = _('Catalog not found.')
                return
            elif result:
                # we have what we want.
                title, views, tags, selected_view = result
                group_names = views
                self.context.setSubject(tags)
                self.context.selected_view = selected_view
                self.context.file_type = data['eftypes']
                self.status = _('File type assigned. Please select views '
                                'to add to this file.')

        self.context.views = self.group_names = group_names
        if group_names:
            # we have more views, redirect
            return self.request.response.redirect(
                self.context.absolute_url() + '/@@edit_annotations')

        # since there was no fields selected and the file type supplied 
        # had no views defined, we prompt the form again without the
        # types enabled.
        self.fields.omit('eftypes')
Esempio n. 3
0
    def handleMigrate(self, action):
        """\
        Migrate this group.

        This will fetch the new set of views available with the filetype
        associated with this group, bringing the views available to be 
        up-to-date with what is choosen.

        Should only be available when there is a need.
        """

        # XXX this really should be implemented as part of the file type
        # section.   However due to the implementation of the decorator
        # used to define this, new buttons are replaced completely if
        # defined at a subclass.

        result = getExposureFileType(self, self.structure['file_type'])
        if result is None:
            # XXX somehow error, see above comment about grouping...
            return

        title, views, tags, selected_view = result
        previous_views = dict(self.structure['views'])
        new_views = []
        for v in views:
            new_views.append((v, previous_views.get(v, None)))

        self.structure['views'] = new_views
        self.parentForm._updated = True