Exemplo n.º 1
0
    def post(self, request, *args, **kwargs):
        r_base = ResourceBase.objects.get(pk=kwargs.get('pk'))
        self.resource = OwnerRightsRequestViewUtils.get_resource(r_base)
        form = self.form_class(request.POST)
        if form.is_valid():
            reason = form.cleaned_data['reason']
            # object.save()
            notice_type_label = 'request_resource_edit'
            recipients = OwnerRightsRequestViewUtils.get_message_recipients()

            Message.objects.new_message(
                from_user=request.user,
                to_users=recipients,
                subject=_('System message: A request to modify resource'),
                content=_(
                    'The resource owner has requested to modify the resource')
                + '.'
                ' ' + _('Resource title') + ': ' + self.resource.title + '.'
                ' ' + _('Reason for the request') + ': "' + reason + '".' +
                ' ' +
                _('To allow the change, set the resource to not "Approved" under the metadata settings'
                  + 'and write message to the owner to notify him') + '.')
            send_notification(
                recipients, notice_type_label, {
                    'resource': self.resource,
                    'site_url': settings.SITEURL[:-1],
                    'reason': reason
                })
            return self.form_valid(form)
        else:
            return self.form_invalid(form)
Exemplo n.º 2
0
 def test_msg_recipients_workflow_off(self):
     users_count = 0
     self.assertEqual(
         users_count,
         OwnerRightsRequestViewUtils.get_message_recipients(
             self.user).count())
Exemplo n.º 3
0
 def test_msg_recipients_admin_mode(self):
     users_count = 1
     self.assertEqual(
         users_count,
         OwnerRightsRequestViewUtils.get_message_recipients(
             self.user).count())