예제 #1
0
 def approve(self, request, queryset):
     for obj in queryset:
         try:
             mturk.approve_assignment(
                 AssignmentId=obj.assignment_id,
                 OverrideRejection=True
             )
         except Exception as e:
             self.message_user(request, f'Unable to approve the assignment {obj.assignment_id}. {e}', messages.ERROR)
예제 #2
0
 def bonus(self, request, queryset):
     if request.POST.get('post'):
         form = HITApprovalForm(request.POST)
         if form.is_valid():
             for obj in queryset:
                 try:
                     #print('successful fake acceptance of ' + str(obj))
                     if form.cleaned_data['reason']:
                         mturk.approve_assignment(
                             AssignmentId=obj.assignment_id,
                             RequesterFeedback=form.cleaned_data['reason'],
                             OverrideRejection=True)
                     else:
                         mturk.approve_assignment(
                             AssignmentId=obj.assignment_id,
                             OverrideRejection=True)
                     obj.data['__cached_status'] = 'Approved'
                     obj.save()
                     if form.cleaned_data['bonus']:
                         #print('successful fake bonus of '+str(form.cleaned_data['bonus']))
                         mturk.send_bonus(
                             WorkerId=obj.workerID,
                             BonusAmount=str(form.cleaned_data['bonus']),
                             AssignmentId=obj.assignment_id,
                             Reason=form.cleaned_data['reason'],
                             UniqueRequestToken=obj.assignment_id)
                 except Exception as e:
                     self.message_user(
                         request,
                         f'Unable to approve the assignment {obj.assignment_id}. {e}',
                         messages.ERROR)
             return None
     else:
         form = HITApprovalForm()
     return render(
         request, 'admin/users/hit/hit_form.html', {
             'items': queryset.order_by('pk'),
             'form': form,
             'title': 'Approve selected hits',
             'action': 'bonus',
             'button': 'Approve',
         })
예제 #3
0
def approve_assignment(assignment_id):
    mturk.approve_assignment(AssignmentId=assignment_id,
                             OverrideRejection=True)