Example #1
0
    def get_dossier_attributes(self):
        filing_columns = [
            {'id': 'filing_no',
             'title': _('filing_no_filing'),
             'transform': filing_no_filing},

            {'id': 'filing_no',
             'title': _('filing_no_year'),
             'transform': filing_no_year},

            {'id': 'filing_no',
             'title': _('filing_no_number'),
             'transform': filing_no_number},

            {'id': 'filing_no',
             'title': _(u'filing_no', default="Filing number")},
        ]
        filing_columns.reverse()

        columns = super(
            DossierFilingNumberReporter, self).get_dossier_attributes()

        index = [col.get('id') for col in columns].index('review_state')
        for column in filing_columns:
            columns.insert(index, column)

        return columns
Example #2
0
    def render(self):

        wft = getToolByName(self.context, 'portal_workflow')
        # check for resolved subdossiers
        for subdossier in self.context.get_subdossiers():

            if wft.getInfoFor(subdossier.getObject(), 'review_state') \
                    == 'dossier-state-resolved':
                IStatusMessage(self.request).add(
                    _("The Dossier can't be deactivated, the subdossier "
                     "${dossier} is already resolved",
                    mapping=dict(dossier=subdossier.Title,)), type='error')
                return self.request.RESPONSE.redirect(
                    self.context.absolute_url())

        # recursively resolve all dossier
        for subdossier in self.context.get_subdossiers():
            if wft.getInfoFor(subdossier.getObject(), 'review_state') \
                    != 'dossier-state-inactive':
                wft.doActionFor(
                    subdossier.getObject(), 'dossier-transition-deactivate')

        # deactivate main dossier
        wft.doActionFor(
            self.context, 'dossier-transition-deactivate')

        IStatusMessage(self.request).add(
            _("The Dossier has been deactivated"), type='info')

        return self.request.RESPONSE.redirect(self.context.absolute_url())
Example #3
0
    def templates(self):
        """List the available template documents the user can choose from.
        """

        catalog = getToolByName(self.context, 'portal_catalog')
        templates = catalog(
            path=dict(
                depth=-1, query=self.templatedossier),
            portal_type="opengever.document.document")

        generator = getUtility(ITableGenerator, 'ftw.tablegenerator')
        columns = (
            (''),
            ('', helper.path_radiobutton),
            {'column': 'Title',
             'column_title': _(u'label_title', default=u'title'),
             'sort_index': 'sortable_title',
             'transform': linked},
            {'column': 'Creator',
             'column_title': _(u'label_creator', default=u'Creator'),
             'sort_index': 'document_author'},
            {'column': 'modified',
             'column_title': _(u'label_modified', default=u'Modified'),
             'transform': helper.readable_date}
            )
        return generator.generate(templates, columns)
Example #4
0
    def create_statusmessages(
        self,
        copied_items,
        failed_objects,
        failed_resource_locked_objects, ):
        """ Create statusmessages with errors and infos af the move-process
        """
        if copied_items:
            msg = _(u'${copied_items} Elements were moved successfully',
                    mapping=dict(copied_items=copied_items))
            IStatusMessage(self.request).addStatusMessage(
                msg, type='info')

        if failed_objects:
            msg = _(u'Failed to copy following objects: ${failed_objects}',
                    mapping=dict(failed_objects=','.join(failed_objects)))
            IStatusMessage(self.request).addStatusMessage(
                msg, type='error')

        if failed_resource_locked_objects:
            msg = _(u'Failed to copy following objects: ${failed_objects}. '
                    u'Locked via WebDAV',
                    mapping=dict(failed_objects=','.join(
                        failed_resource_locked_objects)))
            IStatusMessage(self.request).addStatusMessage(
                msg, type='error')
Example #5
0
    def check_preconditions(self):
        satisfied = True

        if not self.context.is_all_checked_in():
            api.portal.show_message(
                _(u"The Dossier can't be deactivated, not all contained"
                  "documents are checked in."), self.request, type='error')
            satisfied = False

        if self.context.has_active_proposals():
            api.portal.show_message(
                _(u"The Dossier can't be deactivated, it contains active "
                  "proposals."), self.request, type='error')
            satisfied = False

        # check for resolved subdossiers
        for subdossier in self.context.get_subdossiers():
            state = api.content.get_state(obj=subdossier.getObject())
            if state == 'dossier-state-resolved':
                msg = _(u"The Dossier can't be deactivated, the subdossier "
                       "${dossier} is already resolved",
                       mapping=dict(dossier=subdossier.Title.decode('utf-8')))
                api.portal.show_message(msg, self.request, type='error')

                satisfied = False

        if self.context.has_active_tasks():
            satisfied = False
            api.portal.show_message(
                _(u"The Dossier can't be deactivated, not all contained "
                  "tasks are in a closed state."),
                self.request, type='error')

        return satisfied
Example #6
0
    def render(self):

        if not self.request.get('paths'):
            msg = _(
                u'error_no_items', default=u'You have not selected any Items')
            IStatusMessage(self.request).addStatusMessage(msg, type='error')
            return_temp = self.request.get(
                'orig_template', self.context.absolute_url())

            return self.request.RESPONSE.redirect(return_temp)

        dossiers = self.get_selected_dossiers()

        # generate the xls data with the XLSReporter
        reporter = XLSReporter(
            self.request, self.get_dossier_attributes(), dossiers)

        data = reporter()
        if not data:
            msg = _(u'Could not generate the report')
            IStatusMessage(self.request).addStatusMessage(
                msg, type='error')
            return self.request.RESPONSE.redirect(self.context.absolute_url())

        response = self.request.RESPONSE

        response.setHeader(
            'Content-Type',
            'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
        set_attachment_content_disposition(self.request, "dossier_report.xlsx")

        return data
Example #7
0
    def check_preconditions(self):
        errors = []
        if not self.context.is_all_checked_in():
            errors.append(NOT_ALL_CHECKED_IN)

        if self.context.has_active_proposals():
            errors.append(CONTAINS_ACTIVE_PROPOSAL)

        # Check for subdossiers the user cannot deactivate
        for subdossier in self.context.get_subdossiers(unrestricted=True):
            with elevated_privileges():
                subdossier = subdossier.getObject()

            wftool = api.portal.get_tool('portal_workflow')
            user_can_deactivate = any(
                transition['name'] == 'dossier-transition-deactivate'
                for transition in wftool.getTransitionsFor(subdossier)
            )
            state = api.content.get_state(subdossier)

            # A subdossier already being inactive is not a blocker
            if not user_can_deactivate and state != 'dossier-state-inactive':
                if api.user.has_permission('View', obj=subdossier):
                    subdossier_title = subdossier.title_or_id()
                    # We cannot deactivate if some of the subdossiers are already resolved
                    if state == 'dossier-state-resolved':
                        msg = _(
                            u"The Dossier can't be deactivated, the subdossier ${dossier} is already resolved.",
                            mapping=dict(dossier=subdossier_title),
                        )
                    else:
                        # The deactvation of this subdossier is most likely not allowed by role
                        msg = _(
                            u"The Dossier ${dossier} can't be deactivated by the user.",
                            mapping=dict(dossier=subdossier_title),
                        )
                # Inform the user which of the parents contains the blocking subdossier they cannot see
                else:
                    # We are guaranteed to hit a dossier the user can view
                    # Grab the title of the first parent we do have access to
                    # Default to an empty string
                    parent_title = ''
                    parent = subdossier.get_parent_dossier()
                    while parent:
                        if api.user.has_permission('View', obj=parent):
                            parent_title = parent.title_or_id()
                            break
                        parent = subdossier.get_parent_dossier()

                    msg = _(
                        u"The Dossier ${dossier} contains a subdossier which can't be deactivated by the user.",
                        mapping=dict(dossier=parent_title),
                    )
                errors.append(msg)

        if self.context.has_active_tasks():
            errors.append(CONTAINS_ACTIVE_TASK)

        return errors
Example #8
0
    def archive(self, action):
        """Try to archive this dossier.

        For that to happen, first all subdossiers need to have filing_no
        and end_date set, and then be resolved. If resolving any of the
        subdossier fails, we'll throw and error and return.
        """

        data, errors = self.extractData()

        # Abort if there were errors
        if len(errors) > 0:
            return
        self.ptool = getToolByName(self.context, 'plone_utils')
        self.wft = self.context.portal_workflow

        action = data.get('filing_action')
        filing_year = data.get('filing_year')
        filing_no = None
        filing_prefix = data.get('filing_prefix')
        end_date = data.get('dossier_enddate')

        if action == METHOD_FILING:
            # allready resolved only give a filing number
            IDossierArchiver(self.context).archive(filing_prefix, filing_year)
            self.ptool.addPortalMessage(
                _("The filing number has been given"), type="info")
            return self.request.RESPONSE.redirect(self.context.absolute_url())

        # archiving must passed to the resolving view
        resolver = IDossierResolver(self.context)
        if resolver.is_resolve_possible():
            raise TypeError
        if resolver.are_enddates_valid():
            raise TypeError

        if action == METHOD_RESOLVING_AND_FILING:
            IDossierArchiver(self.context).archive(filing_prefix, filing_year)

        if action == METHOD_RESOLVING_EXISTING_FILING:
            # archive all with the existing filing number
            filing_no = IFilingNumber(self.context).filing_no
            filing_prefix = IDossier(self.context).filing_prefix
            IDossierArchiver(self.context).archive(
                filing_prefix, filing_year, number=filing_no)

        if action == METHOD_RESOLVING:
            # only update the prefixes
            if filing_prefix:
                IDossierArchiver(self.context).update_prefix(filing_prefix)

        # If everything went well, resolve the main dossier
        resolver.resolve(end_date=end_date)

        self.ptool.addPortalMessage(
            _("The Dossier has been resolved"), type="info")
        return self.request.RESPONSE.redirect(self.context.absolute_url())
Example #9
0
    def validate(self, value):
        if not value:
            raise MissingValue(
                _(u'error_enddate', default=u'The enddate is required.'))

        earliest_date = self.context.earliest_possible_end_date()
        if earliest_date and value < earliest_date:
            raise Invalid(
                _(u'The given end date is not valid, it needs to be younger or\
                  equal than ${date} (the youngest contained object).',
                  mapping=dict(date=earliest_date.strftime('%d.%m.%Y'),),))
Example #10
0
    def participations_tab(self):
        if is_contact_feature_enabled():
            return {
                'id': 'participations',
                'title': _(u'label_participations', default=u'Participations'),
                }

        return {
            'id': 'participants',
            'title': _(u'label_participants', default=u'Participants'),
            }
Example #11
0
    def make_participation_box(self):
        if is_contact_feature_enabled():
            return dict(id='participations',
                        content=self.sql_participations(),
                        href='participations',
                        label=_("Participations"),
                        available=self.context.has_participation_support())

        else:
            return dict(id='participants',
                        content=self.plone_participations(),
                        href='participants',
                        label=_("Participants"),
                        available=self.context.has_participation_support())
Example #12
0
    def handle_submit(self, action):
        data, errors = self.extractData()
        if len(errors) == 0:

            destination = data['destination_folder']
            failed_objects = []
            failed_resource_locked_objects = []
            copied_items = 0

            try:
                objs = self.extract_selected_objs(data)
            except KeyError:
                IStatusMessage(self.request).addStatusMessage(
                    _(u"The selected objects can't be found, please try it again."),
                    type='error')
                return self.request.RESPONSE.redirect(self.context.absolute_url())

            for obj in objs:
                parent = aq_parent(aq_inner(obj))

                if IDocumentSchema.providedBy(obj) and not obj.is_movable():
                    msg = _(u'Document ${name} is connected to a Task. '
                            'Please move the Task.',
                            mapping=dict(name=obj.title))
                    IStatusMessage(self.request).addStatusMessage(msg, type='error')
                    continue

                try:
                    # Try to cut and paste object
                    clipboard = parent.manage_cutObjects(obj.id)
                    destination.manage_pasteObjects(clipboard)
                    copied_items += 1

                except ResourceLockedError:
                    # The object is locket over webdav
                    failed_resource_locked_objects.append(obj.title)
                    continue

                except (ValueError, CopyError):
                    # Catch exception and add title to a list of failed objects
                    failed_objects.append(obj.title)
                    continue

            self.create_statusmessages(
                copied_items,
                failed_objects,
                failed_resource_locked_objects, )

            self.request.RESPONSE.redirect(destination.absolute_url())
Example #13
0
    def translations(self):
        msg_confirm = _(u'note_text_confirm_abord', default=u'Confirm abbord')
        msg_title_info = ogbmf(u'message_title_info', default=u'Information')
        msg_title_error = ogbmf(u'message_title_error', default=u'Error')
        msg_body_info = _(u'message_body_info', default=u'Changes saved')
        msg_body_error = _(u'message_body_error', default=u'Changes not saved')
        create_translations = lambda msg: translate(msg, context=self.request)

        return json.dumps(
            {'note_text_confirm_abord': create_translations(msg_confirm),
             'message_title_info': create_translations(msg_title_info),
             'message_title_error': create_translations(msg_title_error),
             'message_body_info': create_translations(msg_body_info),
             'message_body_error': create_translations(msg_body_error)
             })
Example #14
0
    def create_tasks_listing_pdf(self):
        """Creates a pdf representation of the dossier tasks, and add it to
        the dossier as a normal document.

        If the dossiers has an end date use that date as the document date.
        This prevents the dossier from entering an invalid state with a
        document date outside the dossiers start-end range.
        """
        if not self.get_property('tasks_pdf_enabled'):
            return

        view = self.context.unrestrictedTraverse('pdf-dossier-tasks')

        today = api.portal.get_localized_time(
            datetime=datetime.today(), long_format=True)
        filename = u'Tasks {}.pdf'.format(today)
        title = _(u'title_dossier_tasks',
                  default=u'Task list of dossier ${title}, ${timestamp}',
                  mapping={'title': self.context.title,
                           'timestamp': today})
        kwargs = {
            'preserved_as_paper': False,
        }
        dossier = IDossier(self.context)
        if dossier and dossier.end:
            kwargs['document_date'] = dossier.end

        results = api.content.find(object_provides=IDossierTasksPDFMarker,
                                   depth=1,
                                   context=self.context)

        with elevated_privileges():
            if len(results) > 0:
                document = results[0].getObject()
                document.title = translate(title, context=self.context.REQUEST)
                comment = _(u'Updated with a newer generated version from dossier ${title}.',
                            mapping=dict(title=self.context.title))
                document.update_file(view.get_data(), create_version=True,
                                     comment=comment)
                return

            document = CreateDocumentCommand(
                self.context, filename, view.get_data(),
                title=translate(title, context=self.context.REQUEST),
                content_type='application/pdf',
                interfaces=[IDossierTasksPDFMarker],
                **kwargs).execute()
            document.reindexObject(idxs=['object_provides'])
Example #15
0
    def create_journal_pdf(self):
        """Creates a pdf representation of the dossier journal, and add it to
        the dossier as a normal document.

        If the dossiers has an end date use that date as the document date.
        This prevents the dossier from entering an invalid state with a
        document date outside the dossiers start-end range.
        """
        if not self.get_property('journal_pdf_enabled'):
            return

        view = self.context.unrestrictedTraverse('pdf-dossier-journal')
        today = api.portal.get_localized_time(
            datetime=datetime.today(), long_format=True)
        filename = u'Journal {}.pdf'.format(today)
        title = _(u'title_dossier_journal',
                  default=u'Journal of dossier ${title}, ${timestamp}',
                  mapping={'title': self.context.title,
                           'timestamp': today})
        kwargs = {
            'preserved_as_paper': False,
        }
        dossier = IDossier(self.context)
        if dossier and dossier.end:
            kwargs['document_date'] = dossier.end

        with elevated_privileges():
            CreateDocumentCommand(
                self.context, filename, view.get_data(),
                title=translate(title, context=self.context.REQUEST),
                content_type='application/pdf',
                **kwargs).execute()
Example #16
0
 def proposals_tab(self):
     if is_meeting_feature_enabled():
         return {
             'id': 'proposals',
             'title': _(u'label_proposals', default=u'Proposals'),
             }
     return None
Example #17
0
 def show_invalid_end_dates(self, titles):
     for title in titles:
         msg = _("The dossier ${dossier} has a invalid end_date",
                 mapping=dict(dossier=title,))
         api.portal.show_message(
             message=msg, request=self.request, type='error')
     return self.redirect(self.context_url)
Example #18
0
 def meeting_templates_tab(self):
     if is_meeting_feature_enabled():
         return {
             'id': 'meetingtemplates',
             'title': _(u'label_meeting_templates', default=u'Meeting Templates'),
         }
     return None
Example #19
0
    def validate(self, value):
        super(DestinationValidator, self).validate(value)

        # Allowed contenttypes for destination-folder
        allowed_types = [t.getId() for t in value.allowedContentTypes()]

        # Paths to source object
        source = self.view.widgets['request_paths'].value.split(';;')

        # Get source-brains
        portal_catalog = getToolByName(self.context, 'portal_catalog')
        src_brains = portal_catalog(path={'query': source, 'depth': 0})
        failed_objects = []

        # Look for invalid contenttype
        for src_brain in src_brains:
            if src_brain.portal_type not in allowed_types:
                failed_objects.append(src_brain.Title.decode('utf8'))

        # If we found one or more invalid contenttypes, we raise an error
        if failed_objects:
            raise NotInContentTypes(
                _(u"error_NotInContentTypes ${failed_objects}",
                  default=u"It isn't allowed to add such items there: "
                          "${failed_objects}", mapping=dict(
                              failed_objects=', '.join(failed_objects))))
Example #20
0
    def render(self):
        ptool = getToolByName(self, 'plone_utils')

        resolver = IDossierResolver(self.context)

        # check preconditions
        if resolver.is_reactivate_possible():
            resolver.reactivate()
            ptool.addPortalMessage(_('Dossiers successfully reactivated.'),
                                   type="info")
            self.request.RESPONSE.redirect(self.context.absolute_url())
        else:
            ptool.addPortalMessage(
                _("It isn't possible to reactivate a sub dossier."),
                type="warning")
            self.request.RESPONSE.redirect(self.context.absolute_url())
Example #21
0
    def subdossiers_tab(self):
        if self.context.show_subdossier:
            return {'id': 'subdossiers',
                    'title': _(u'label_subdossiers', default=u'Subdossiers'),
                    }

        return None
Example #22
0
    def __call__(self):
        factory = getUtility(
            IVocabularyFactory,
            name='opengever.ogds.base.OtherAssignedClientsVocabulary')
        voc = tuple(factory(self.context))

        if not len(voc):
            # if there is no client in the vocabulary we cannot continue
            msg = _(u'warning_copy_to_remote_no_client',
                    default=u'You are not assigned to another client where you'
                    ' could copy the documents to.')
            IStatusMessage(self.request).addStatusMessage(msg, type='error')
            return self.request.RESPONSE.redirect(self.context.absolute_url())

        elif len(voc) == 1:
            # we have only one client - selecting this one does not make sense.
            # so we redirect to the next wizard step.
            self.form_instance.update()
            data = urllib.urlencode({
                    'form.widgets.paths': ';;'.join(
                        self.form_instance.item_paths),
                    'form.widgets.client': voc[0].token})

            target = self.context.absolute_url() + \
                '/@@copy-documents-to-remote-client2?' + data
            return self.request.RESPONSE.redirect(target)

        else:
            return layout.FormWrapper.__call__(self)
Example #23
0
 def __call__(self):
     oids = self.request.get('oids')
     if not oids:
         msg = _(u'warning_no_participants_selected',
                 default=u'You didn\'t select any participants.')
         IStatusMessage(self.request).addStatusMessage(msg, type='error')
         return self.request.RESPONSE.redirect(self.redirect_url)
     phandler = IParticipationAware(self.context)
     for a in oids:
         oid = base64.decodestring(a)
         obj = self.context._p_jar[oid]
         phandler.remove_participation(obj)
     status = IStatusMessage(self.request)
     msg = _(u'info_removed_participations',
             'Removed participations.')
     status.addStatusMessage(msg, type='info')
     return self.request.RESPONSE.redirect(self.redirect_url)
Example #24
0
    def sablon_tab(self):
        if is_meeting_feature_enabled():
            return {
                'id': 'sablontemplates-proxy',
                'title': _(u'label_sablon_templates', default=u'Sablon Templates'),
                }

        return None
Example #25
0
    def blocked_local_roles_tab(self):
        if api.user.has_permission('opengever.sharing: List Protected Objects', obj=self.context):
            return {
                'id': 'blocked-local-roles',
                'title': _(u'label_blocked_local_roles', default=u'Protected Objects'),
                }

        return None
Example #26
0
    def subdossiers_tab(self):
        if self.is_subdossier_visible():
            return {
                'id': 'subdossiers',
                'title': _(u'label_subdossiers', default=u'Subdossiers'),
                }

        return None
Example #27
0
    def proposal_templates_tab(self):
        if is_meeting_feature_enabled():
            return {
                'id': 'proposaltemplates-proxy',
                'title': _(u'label_proposal_templates', default=u'Proposal Templates'),
                }

        return None
Example #28
0
    def oneoffixxtemplate_tab(self):
        if is_oneoffixx_feature_enabled():
            return {
                'id': 'oneoffixxtemplates',
                'title': _(u'label_oneoffixx_templates', default=u'OneOffixx'),
            }

        return None
Example #29
0
 def label(self):
     if IDossierMarker.providedBy(self.context):
         return _(u'Add Subdossier')
     else:
         portal_type = self.portal_type
         fti = getUtility(IDexterityFTI, name=portal_type)
         type_name = fti.Title()
         return pd_mf(u"Add ${name}", mapping={'name': type_name})
Example #30
0
    def dossiertemplate_tab(self):
        if is_dossier_template_feature_enabled():
            return {
                'id': 'dossiertemplates',
                'title': _(u'label_dossier_templates', default=u'Dossier templates'),
                }

        return None
Example #31
0
def valid_filing_year(value):
    if tryint(value):
        if 1900 < int(value) < 3000:
            if str(int(value)) == value:
                return True
    raise Invalid(_(u'The given value is not a valid Year.'))
Example #32
0
from plone import api
from Products.CMFCore.utils import getToolByName
from Products.Five.browser import BrowserView
from zope.annotation import IAnnotations
from zope.component import adapter
from zope.component import getAdapter
from zope.component import getSiteManager
from zope.i18n import translate
from zope.interface import implementer
from zope.interface import implements
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.schema.interfaces import IVocabularyFactory
from zope.schema.vocabulary import SimpleVocabulary
import transaction

MAIN_DOSSIER_NOT_ACTIVE = _("Dossier is not active and cannot be resolved.")
NOT_SUPPLIED_OBJECTS = _(
    "not all documents and tasks are stored in a subdossier.")
NOT_CHECKED_IN_DOCS = _("not all documents are checked in")
NOT_CLOSED_TASKS = _("not all task are closed")
NO_START_DATE = _("the dossier start date is missing.")
MSG_ACTIVE_PROPOSALS = _("The dossier contains active proposals.")
MSG_ALREADY_BEING_RESOLVED = _("Dossier is already being resolved")

AFTER_RESOLVE_JOBS_PENDING_KEY = 'opengever.dossier.resolve.after_resolve_jobs_pending'


class AlreadyBeingResolved(Exception):
    """A concurrent attempt at resolving a dossier was made.
    """
Example #33
0
 def show_already_resolved_msg(self):
     api.portal.show_message(
         message=_('Dossier has already been resolved.'),
         request=self.request,
         type='info')
     return self.redirect(self.context_url)
Example #34
0
class ISelectRecipientAddress(form.Schema):

    address = TableChoice(
        title=_(u"label_address", default=u"Address"),
        required=False,
        source=make_address_vocabulary,
        columns=(
            {'column': 'label',
             'column_title': _(u'label_label', default=u'Label')},
            {'column': 'address',
             'column_title': _(u'label_address', default=u'Address'),
             'transform': address_lines},
        ))

    mail_address = TableChoice(
        title=_(u"label_mail_address", default=u"Mail-Address"),
        required=False,
        source=make_mail_address_vocabulary,
        columns=(
            {'column': 'label',
             'column_title': _(u'label_label', default=u'Label')},
            {'column': 'address',
             'column_title': _(u'label_mail_address', default=u'Mail-Address')},
        ))

    phonenumber = TableChoice(
        title=_(u"label_phonenumber", default=u"Phonenumber"),
        required=False,
        source=make_phonenumber_vocabulary,
        columns=(
            {'column': 'label',
             'column_title': _(u'label_label', default=u'Label')},
            {'column': 'phone_number',
             'column_title': _(u'label_phonenumber', default=u'Phonenumber')},
        ))

    url = TableChoice(
        title=_(u"label_url", default=u"URL"),
        required=False,
        source=make_url_vocabulary,
        columns=(
            {'column': 'label',
             'column_title': _(u'label_label', default=u'Label')},
            {'column': 'url',
             'column_title': _(u'label_url', default=u'URL')},
        ))
Example #35
0
class MissingValue(Invalid):
    """ The Missing value was defined Exception."""
    __doc__ = _(u"Not all required fields are filled.")
Example #36
0
 def show_dossier_resolved_msg(self):
     api.portal.show_message(
         message=_('The dossier has been succesfully resolved.'),
         request=self.request,
         type='info')
     return self.redirect(self.context_url)
Example #37
0
from opengever.dossier.interfaces import IDossierResolveProperties
from opengever.dossier.interfaces import IDossierResolver
from plone import api
from Products.CMFCore.utils import getToolByName
from Products.Five.browser import BrowserView
from zope.component import adapter
from zope.component import getAdapter
from zope.component import getSiteManager
from zope.i18n import translate
from zope.interface import implementer
from zope.interface import implements
from zope.schema.interfaces import IVocabularyFactory
from zope.schema.vocabulary import SimpleVocabulary


NOT_SUPPLIED_OBJECTS = _(
    "not all documents and tasks are stored in a subdossier.")
NOT_CHECKED_IN_DOCS = _("not all documents are checked in")
NOT_CLOSED_TASKS = _("not all task are closed")
NO_START_DATE = _("the dossier start date is missing.")
MSG_ACTIVE_PROPOSALS = _("The dossier contains active proposals.")


def get_resolver(dossier):
    """Return the currently configured dossier-resolver."""

    resolver_name = api.portal.get_registry_record(
        'resolver_name', IDossierResolveProperties)
    return getAdapter(dossier, IDossierResolver, name=resolver_name)


class ValidResolverNamesVocabularyFactory(object):
Example #38
0
 def label(self):
     if IDossierTemplateSchema.providedBy(self.context):
         return _(u'Add Subdossier')
     return super(DossierTemplateAddForm, self).label
Example #39
0
 def label(self):
     if IDossierTemplateSchema.providedBy(aq_parent(aq_inner(
             self.context))):
         return _(u'Edit Subdossier')
     return super(DossierTemplateEditForm, self).label
Example #40
0
 def steps(self):
     if not is_contact_feature_enabled():
         return []
     return [('select-document', _(u'Select document')),
             ('select-address', _(u'Select recipient address'))]
Example #41
0
from zope.annotation.interfaces import IAnnotations
from zope.component import adapter
from zope.component import getUtility
from zope.interface import implementer
from zope.interface import Invalid
from zope.interface import invariant
from zope.interface import provider
from zope.schema.interfaces import IContextAwareDefaultFactory
from zope.schema.interfaces import IContextSourceBinder
from zope.schema.vocabulary import getVocabularyRegistry
from zope.schema.vocabulary import SimpleVocabulary
import re


# action vocabulary terms
RESOLVE_AND_NUMBER = _('resolve and set filing no')
ONLY_RESOLVE = _('only resolve, set filing no later')
RESOLVE_WITH_EXISTING_NUMBER = _('resolve and take the existing filing no')
RESOLVE_WITH_NEW_NUMBER = _('resolve and set a new filing no')
ONLY_NUMBER = _('set a filing no')

# filing methods
METHOD_RESOLVING_AND_FILING = 0
METHOD_RESOLVING = 1
METHOD_FILING = 2
METHOD_RESOLVING_EXISTING_FILING = 3

# annotation key
FILING_NO_KEY = "filing_no"

# filing no pattern
Example #42
0
class ArchiveForm(Form):

    label = _(u'heading_archive_form', u'Archive Dossier')
    fields = field.Fields(IArchiveFormSchema)
    ignoreContext = True

    # define custom widgets.
    fields['filing_action'].widgetFactory[INPUT_MODE] = radio.RadioFieldWidget
    fields['dossier_enddate'].widgetFactory[INPUT_MODE] = DatePickerFieldWidget

    @button.buttonAndHandler(_(u'button_archive', default=u'Archive'))
    def archive(self, action):
        """Try to archive this dossier.

        For that to happen, first all subdossiers need to have filing_no
        and end_date set, and then be resolved. If resolving any of the
        subdossier fails, we'll throw and error and return.
        """

        data, errors = self.extractData()

        # Abort if there were errors
        if len(errors) > 0:
            return
        self.ptool = getToolByName(self.context, 'plone_utils')
        self.wft = self.context.portal_workflow

        action = data.get('filing_action')
        filing_year = data.get('filing_year')
        filing_no = None
        filing_prefix = data.get('filing_prefix')
        end_date = data.get('dossier_enddate')

        if action == METHOD_FILING:
            # allready resolved only give a filing number
            IDossierArchiver(self.context).archive(filing_prefix, filing_year)
            self.ptool.addPortalMessage(
                _("The filing number has been given."), type="info")
            return self.request.RESPONSE.redirect(self.context.absolute_url())

        # archiving must passed to the resolving view
        resolver = get_resolver(self.context)
        if resolver.is_resolve_possible():
            raise TypeError
        if resolver.are_enddates_valid():
            raise TypeError

        if action == METHOD_RESOLVING_AND_FILING:
            IDossierArchiver(self.context).archive(filing_prefix, filing_year)

        if action == METHOD_RESOLVING_EXISTING_FILING:
            # archive all with the existing filing number
            filing_no = IFilingNumber(self.context).filing_no
            filing_prefix = IDossier(self.context).filing_prefix
            IDossierArchiver(self.context).archive(
                filing_prefix, filing_year, number=filing_no)

        if action == METHOD_RESOLVING:
            # only update the prefixes
            if filing_prefix:
                IDossierArchiver(self.context).update_prefix(filing_prefix)

        # If everything went well, resolve the main dossier
        resolver.resolve(end_date=end_date)

        self.ptool.addPortalMessage(
            _("The Dossier has been resolved"), type="info")
        return self.request.RESPONSE.redirect(self.context.absolute_url())

    @button.buttonAndHandler(_(u'button_cancel', default=u'Cancel'))
    def cancel(self, action):
        return self.request.RESPONSE.redirect(self.context.absolute_url())