Ejemplo n.º 1
0
    def pay_hit_bonuses(self, is_confirmed):

        total_money_paid = 0
        for participant in self.experiment.participants():
            bonus = participant.bonus()
            if bonus == None:
                bonus = 0
            total_money_paid += bonus

            if not is_confirmed:
                print "Participant {}: {}".format(participant.id, participant.bonus_display())
            if is_confirmed:
                if bonus > 0:
                    print bonus, Price(cents_to_dollars(bonus))
                    self.connection.grant_bonus(
                        worker_id=participant.mturk_worker_id,
                        assignment_id=participant.mturk_assignment_id,
                        bonus_price=Price(cents_to_dollars(bonus)),
                        reason="Thanks!",
                    )
        if not is_confirmed:
            print "Total amount to pay: {}".format(currency(total_money_paid))
        if is_confirmed:
            print "Total amount paid: {}".format(currency(total_money_paid))
            self.experiment.payment_was_sent = True
            self.experiment.save()
Ejemplo n.º 2
0
    def payments(self, request, pk):
        session = self.model.objects.get(pk=pk)
        participants = session.participants()
        total_payments = sum(participant.total_pay() or 0 for participant in session.participants())

        # order by label if they are numbers. or should we always order by label?


        return render_to_response('admin/Payments.html',
                                  {'participants': participants,
                                  'total_payments': currency(total_payments),
                                  'session_code': session.code,
                                  'session_name': session,
                                  'base_pay': currency(session.base_pay),
                                  })
Ejemplo n.º 3
0
 def bonus_display(self):
     """printable version of the bonus"""
     try:
         return currency(self.bonus())
     except:
         return currency(None)
Ejemplo n.º 4
0
 def total_pay_display(self):
     return currency(self.total_pay())
Ejemplo n.º 5
0
 def base_pay_display(self):
     if not self.treatment:
         return currency(None)
     else:
         return currency(self.treatment.base_pay)
Ejemplo n.º 6
0
 def base_pay_display(self):
     return currency(self.base_pay)
Ejemplo n.º 7
0
 def total_pay_display(self):
     if self.bonus_is_complete():
         return currency(self.total_pay())
     return u'{} (incomplete)'.format(currency(self.total_pay()))