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_get_concrete_resource(self):
        self.assertTrue(isinstance(
            OwnerRightsRequestViewUtils.get_resource(ResourceBase.objects.get(pk=self.d.id)), Document
        ))

        self.assertTrue(isinstance(
            OwnerRightsRequestViewUtils.get_resource(ResourceBase.objects.get(pk=self.la.id)), Dataset
        ))

        self.assertTrue(isinstance(
            OwnerRightsRequestViewUtils.get_resource(ResourceBase.objects.get(pk=self.s.id)), Service
        ))

        self.assertTrue(isinstance(
            OwnerRightsRequestViewUtils.get_resource(ResourceBase.objects.get(pk=self.m.id)), Map
        ))
Exemplo n.º 3
0
 def get(self, request, *args, **kwargs):
     r_base = ResourceBase.objects.get(pk=kwargs.get('pk'))
     self.resource = OwnerRightsRequestViewUtils.get_resource(r_base)
     initial = {
         'resource': r_base
     }
     form = self.form_class(initial=initial)
     return render(request, self.template_name, {'form': form, 'resource': self.resource})
Exemplo n.º 4
0
 def test_msg_recipients_workflow_off(self):
     users_count = 0
     self.assertEqual(
         users_count,
         OwnerRightsRequestViewUtils.get_message_recipients(
             self.user).count())
Exemplo n.º 5
0
 def test_msg_recipients_admin_mode(self):
     users_count = 1
     self.assertEqual(
         users_count,
         OwnerRightsRequestViewUtils.get_message_recipients(
             self.user).count())