Beispiel #1
0
    def delete(self, request, *args, **kwargs):
        if not request.user.has_perm('osf.mark_spam'):
            raise PermissionDenied(
                'You do not have permission to update a preprint flagged as spam.'
            )
        preprint_ids = []
        for key in list(request.POST.keys()):
            if key == 'spam_confirm':
                action = 'SPAM'
                action_flag = CONFIRM_HAM
            elif key == 'ham_confirm':
                action = 'HAM'
                action_flag = CONFIRM_SPAM
            elif key != 'csrfmiddlewaretoken':
                preprint_ids.append(key)

        for pid in preprint_ids:
            preprint = Preprint.load(pid)
            osf_admin_change_status_identifier(preprint)

            if action == 'SPAM':
                preprint.confirm_spam(save=True)
            elif action == 'HAM':
                preprint.confirm_ham(save=True)

            update_admin_log(user_id=self.request.user.id,
                             object_id=pid,
                             object_repr='Preprint',
                             message=f'Confirmed {action}: {pid}',
                             action_flag=action_flag)
        return redirect('preprints:flagged-spam')
Beispiel #2
0
 def get_context_data(self, **kwargs):
     preprint = Preprint.load(self.kwargs.get('guid'))
     # TODO - we shouldn't need this serialized_preprint value -- https://openscience.atlassian.net/browse/OSF-7743
     kwargs['serialized_preprint'] = serialize_preprint(preprint)
     kwargs['change_provider_form'] = ChangeProviderForm(instance=preprint)
     kwargs.update({'SPAM_STATUS': SpamStatus})  # Pass spam status in to check against
     kwargs.update({'message': kwargs.get('message')})
     return super(PreprintView, self).get_context_data(**kwargs)
Beispiel #3
0
 def get_context_data(self, **kwargs):
     preprint = Preprint.load(self.kwargs.get('guid'))
     # TODO - we shouldn't need this serialized_preprint value -- https://openscience.atlassian.net/browse/OSF-7743
     kwargs['serialized_preprint'] = serialize_preprint(preprint)
     kwargs['change_provider_form'] = ChangeProviderForm(instance=preprint)
     kwargs.update({'SPAM_STATUS':
                    SpamStatus})  # Pass spam status in to check against
     kwargs.update({'message': kwargs.get('message')})
     return super(PreprintView, self).get_context_data(**kwargs)
Beispiel #4
0
 def delete(self, request, *args, **kwargs):
     if not request.user.has_perm('auth.mark_spam'):
         raise PermissionDenied(
             'You do not have permission to update a preprint flagged as spam.'
         )
     preprint_ids = [
         pid for pid in request.POST.keys() if pid != 'csrfmiddlewaretoken'
     ]
     for pid in preprint_ids:
         preprint = Preprint.load(pid)
         osf_admin_change_status_identifier(preprint)
         preprint.confirm_spam(save=True)
         update_admin_log(user_id=self.request.user.id,
                          object_id=pid,
                          object_repr='Preprint',
                          message='Confirmed SPAM: {}'.format(pid),
                          action_flag=CONFIRM_SPAM)
     return redirect('preprints:flagged-spam')
Beispiel #5
0
 def delete(self, request, *args, **kwargs):
     if not request.user.has_perm('auth.mark_spam'):
         raise PermissionDenied('You do not have permission to update a preprint flagged as spam.')
     preprint_ids = [
         pid for pid in request.POST.keys()
         if pid != 'csrfmiddlewaretoken'
     ]
     for pid in preprint_ids:
         preprint = Preprint.load(pid)
         osf_admin_change_status_identifier(preprint)
         preprint.confirm_spam(save=True)
         update_admin_log(
             user_id=self.request.user.id,
             object_id=pid,
             object_repr='Preprint',
             message='Confirmed SPAM: {}'.format(pid),
             action_flag=CONFIRM_SPAM
         )
     return redirect('preprints:flagged-spam')
Beispiel #6
0
 def get_object(self, queryset=None):
     return Preprint.load(self.kwargs.get('guid'))
Beispiel #7
0
 def get_object(self, queryset=None):
     return (Preprint.load(self.kwargs.get('guid')),
             OSFUser.load(self.kwargs.get('user_id')))
Beispiel #8
0
 def get_object(self, queryset=None):
     return Preprint.load(self.kwargs.get('guid'))
Beispiel #9
0
 def get_object(self, queryset=None):
     return (Preprint.load(self.kwargs.get('guid')),
             OSFUser.load(self.kwargs.get('user_id')))