示例#1
0
文件: ajax.py 项目: nsu/hookr
def make_report(request, hookup_pk):
    hookup = Hookup.objects.get(pk=hookup_pk)
    report = Report(owner=request.user, hookup=hookup)
    report.save()
    #if it saved successfully, check if report count is above threshold
    if report.pk is not None:
        all_reports = Report.objects.filter(hookup=hookup)
        #if it is, use the helper function to pay out dividends
        if len(all_reports)>=Hookup.REPORT_THRESHOLD:
            pay_dividends(hookup)
示例#2
0
文件: tests.py 项目: nsu/hookr
 def test_payout(self):
     prevpoints = self.user.points
     helpers.pay_dividends(self.hookup)
     self.user=HookrUser.objects.get(pk=self.user.pk)
     newpoints = self.user.points
     self.assertEqual(newpoints-prevpoints, 220000)