Esempio n. 1
0
    def cancel_button_handler(self, action):
        data, errors = self.extractData()

        if data.get('documents'):
            url = get_containing_document_tab_url(data.get('documents')[0])
        else:
            url = get_containing_document_tab_url(self.context)

        return self.request.RESPONSE.redirect(url)
Esempio n. 2
0
    def cancel_button_handler(self, action):
        data, errors = self.extractData()

        if data.get('documents'):
            url = get_containing_document_tab_url(data.get('documents')[0])
        else:
            url = get_containing_document_tab_url(self.context)

        return self.request.RESPONSE.redirect(url)
Esempio n. 3
0
    def __call__(self, *args, **kwargs):
        try:
            return layout.FormWrapper.__call__(self, *args, **kwargs)
        except NoItemsSelected:
            msg = _(u'You have not selected any documents.')
            IStatusMessage(self.request).addStatusMessage(msg, type=u'error')

            return self.request.RESPONSE.redirect(
                get_containing_document_tab_url(self.context))
Esempio n. 4
0
    def __call__(self, *args, **kwargs):
        try:
            return layout.FormWrapper.__call__(self, *args, **kwargs)
        except NoItemsSelected:
            msg = _(u'You have not selected any documents.')
            IStatusMessage(self.request).addStatusMessage(msg, type=u'error')

            return self.request.RESPONSE.redirect(
                get_containing_document_tab_url(self.context))
Esempio n. 5
0
    def send_button_handler(self, action):
        """Create and Send the Email."""
        data, errors = self.extractData()

        if len(errors) == 0:
            mh = getToolByName(self.context, 'MailHost')
            userid = self.context.portal_membership.getAuthenticatedMember()
            userid = userid.getId()
            intern_receiver = []
            for receiver in data.get('intern_receiver', []):
                # cut away the username
                intern_receiver.append(receiver.split(':')[0])

            extern_receiver = data.get('extern_receiver') or []
            addresses = intern_receiver + extern_receiver

            # create the mail
            msg = self.create_mail(
                data.get('message'),
                data.get('documents'),
                only_links=data.get('documents_as_links'))

            msg['Subject'] = Header(data.get('subject'), CHARSET)

            user = ogds_service().fetch_user(userid)
            sender_address = user and user.email
            if not sender_address:
                portal = self.context.portal_url.getPortalObject()
                sender_address = portal.email_from_address

            msg['From'] = make_addr_header(
                user.label(), sender_address, CHARSET)

            header_to = Header(','.join(addresses), CHARSET)
            msg['To'] = header_to

            # send it
            mfrom = u'{} <{}>'.format(
                user.label(), sender_address).encode(CHARSET)
            mh.send(msg, mfrom=mfrom, mto=','.join(addresses))

            # Store a copy of the sent mail in dossier
            if (data.get('file_copy_in_dossier', False)
                    and self._allow_save_file_copy_in_context()):
                self.file_sent_mail_in_dossier(msg)

            # let the user know that the mail was sent
            info = _(u'info_mail_sent', 'E-mail has been sent.')
            notify(DocumentSent(
                    self.context, userid, header_to, data.get('subject'),
                    data.get('message'), data.get('documents')))

            IStatusMessage(self.request).addStatusMessage(info, type='info')
            # and redirect to default view / tab
            return self.request.RESPONSE.redirect(
                get_containing_document_tab_url(data.get('documents')[0]))
Esempio n. 6
0
    def send_button_handler(self, action):
        """Create and Send the Email."""
        data, errors = self.extractData()

        if len(errors) == 0:
            mh = getToolByName(self.context, 'MailHost')
            userid = self.context.portal_membership.getAuthenticatedMember()
            userid = userid.getId()
            intern_receiver = []
            for receiver in data.get('intern_receiver', []):
                # cut away the username
                intern_receiver.append(receiver.split(':')[0])

            extern_receiver = data.get('extern_receiver') or []
            addresses = intern_receiver + extern_receiver

            # create the mail
            msg = self.create_mail(
                data.get('message'),
                data.get('documents'),
                only_links=data.get('documents_as_links'))

            msg['Subject'] = Header(data.get('subject'), CHARSET)

            user = ogds_service().fetch_user(userid)
            sender_address = user and user.email
            if not sender_address:
                portal = self.context.portal_url.getPortalObject()
                sender_address = portal.email_from_address

            msg['From'] = make_addr_header(
                user.label(), sender_address, CHARSET)

            header_to = Header(','.join(addresses), CHARSET)
            msg['To'] = header_to

            # send it
            mfrom = u'{} <{}>'.format(
                user.label(), sender_address).encode(CHARSET)
            mh.send(msg, mfrom=mfrom, mto=','.join(addresses))

            # Store a copy of the sent mail in dossier
            if (data.get('file_copy_in_dossier', False)
                    and self._allow_save_file_copy_in_context()):
                self.file_sent_mail_in_dossier(msg)

            # let the user know that the mail was sent
            info = _(u'info_mail_sent', 'E-mail has been sent.')
            notify(DocumentSent(
                    self.context, userid, header_to, data.get('subject'),
                    data.get('message'), data.get('documents')))

            IStatusMessage(self.request).addStatusMessage(info, type='info')
            # and redirect to default view / tab
            return self.request.RESPONSE.redirect(
                get_containing_document_tab_url(data.get('documents')[0]))
Esempio n. 7
0
    def checkin(self):
        try:
            self.checkin_controller.checkin_documents(
                self.request.get('paths'), )
        except NoItemsSelected:
            msg = _(u'You have not selected any documents.')
            IStatusMessage(self.request).addStatusMessage(msg, type=u'error')

            return self.request.RESPONSE.redirect(
                get_containing_document_tab_url(self.context))
    def test_without_required_permission_function_returns_context_url(self):
        document_url = 'http://nohost/plone/dossier-1/task-1/document'
        document = self.mock_obj(document_url)
        dossier = self.mock_obj()
        self.mock_finder(dossier)
        self.mock_membership_tool(permission_granted=False)
        self.replay()

        url = get_containing_document_tab_url(document)
        self.assertEqual(url, document_url)
    def test_given_required_permission_function_returns_tab_url(self):
        dossier_url = 'http://nohost/plone/dossier-1'
        dossier = self.mock_obj(dossier_url)
        document = self.mock_obj()
        self.mock_finder(dossier)
        self.mock_membership_tool(permission_granted=True)
        self.replay()

        url = get_containing_document_tab_url(document)
        self.assertEqual(url, '%s#documents' % dossier_url)
Esempio n. 10
0
    def checkin(self):
        try:
            self.checkin_controller.checkin_documents(self.request.get('paths'))
        except NoItemsSelected:
            msg = _(u'You have not selected any documents')
            IStatusMessage(self.request).addStatusMessage(
                msg, type='error')

            return self.request.RESPONSE.redirect(
                get_containing_document_tab_url(self.context))
Esempio n. 11
0
 def redirect(self):
     return self.request.RESPONSE.redirect(
         get_containing_document_tab_url(self.context))
Esempio n. 12
0
 def nextURL(self):
     return get_containing_document_tab_url(self.context)
Esempio n. 13
0
 def nextURL(self):
     return get_containing_document_tab_url(self.context)
Esempio n. 14
0
 def redirect(self):
     return self.request.RESPONSE.redirect(
         get_containing_document_tab_url(self.context))