コード例 #1
0
ファイル: tests.py プロジェクト: MoisesTedeschi/pythonbrasil8
 def test_generate_tutorial_transaction_raises_ValueError_when_no_tutorial_is_selected(self):
     subscription = Subscription.objects.create(
         type='tutorial',
         user=self.user,
     )
     with self.assertRaises(ValueError) as cm:
         Transaction.generate(subscription)
     exc = cm.exception
     self.assertEqual("No tutorials selected.", exc.args[0])
コード例 #2
0
 def test_generate_tutorial_transaction_raises_ValueError_when_no_tutorial_is_selected(
         self):
     subscription = Subscription.objects.create(
         type='tutorial',
         user=self.user,
     )
     with self.assertRaises(ValueError) as cm:
         Transaction.generate(subscription)
     exc = cm.exception
     self.assertEqual("No tutorials selected.", exc.args[0])
コード例 #3
0
ファイル: views.py プロジェクト: shreyarora12/pythonbrasil8
    def get(self, request, *args, **kwargs):
        profile = AccountProfile.objects.filter(user=request.user)
        if not profile or not profile[0].name:
            msg = ugettext(
                "In order to issue your registration to the conference, you need to complete your profile."
            )
            messages.error(request, msg, fail_silently=True)
            url = "%s?next=%s" % (reverse("edit-profile"), request.path)
            return HttpResponseRedirect(url)
        subscription = Subscription.objects.create(
            type='talk',
            user=request.user,
        )
        t = Transaction.generate(subscription)

        if not t:
            self._notify_staff(request.user)
            subscription.delete()
            url = "/dashboard/"
            messages.error(
                request,
                ugettext(
                    "Failed to generate a transaction within the payment gateway. Please contact the event staff to complete your registration."
                ),
                fail_silently=True)
        else:
            url = settings.PAGSEGURO_WEBCHECKOUT + t.code
        return HttpResponseRedirect(url)
コード例 #4
0
ファイル: views.py プロジェクト: romuloigor/pythonbrasil8
 def post(self, request):
     tutorials = []
     regexp = re.compile(r"tutorial-(\d{14})")
     for k, v in request.POST.iteritems():
         m = regexp.match(k)
         if m:
             tutorial = Session.objects.get(
                 pk=v, date=datetime.datetime.strptime(m.groups()[0], "%Y%m%d%H%M%S"), type="tutorial"
             )
             tutorials.append(tutorial)
     status = "pending"
     if request.user.subscription_set.filter(type="talk", status__in=("confirmed", "sponsor")).exists():
         status = "confirmed"
     subscription = Subscription.objects.create(user=request.user, type="tutorial", status=status)
     subscription.tutorials = tutorials
     subscription.save()
     if status == "confirmed":
         return response.TemplateResponse(
             request, "subscription/tutorials_confirmed.html", context={"subscription": subscription}
         )
     transaction = Transaction.generate(subscription)
     return response.TemplateResponse(
         request,
         "subscription/tutorials_success.html",
         context={"transaction": transaction, "subscription": subscription},
     )
コード例 #5
0
 def test_generate_talk_transaction(self):
     subscription = Subscription.objects.create(
         type='talk',
         user=self.user,
     )
     transaction = Transaction.generate(subscription)
     self.assertEqual(subscription, transaction.subscription)
     self.assertEqual("xpto123", transaction.code)
コード例 #6
0
ファイル: tests.py プロジェクト: MoisesTedeschi/pythonbrasil8
 def test_generate_talk_transaction(self):
     subscription = Subscription.objects.create(
         type='talk',
         user=self.user,
     )
     transaction = Transaction.generate(subscription)
     self.assertEqual(subscription, transaction.subscription)
     self.assertEqual("xpto123", transaction.code)
コード例 #7
0
 def test_generate_tutorial_transaction(self):
     subscription = Subscription.objects.create(
         type="tutorial",
         user=self.user,
     )
     subscription.tutorials.add(sched_models.Session.objects.get(pk=1))
     transaction = Transaction.generate(subscription)
     self.assertEqual(subscription, transaction.subscription)
     self.assertEqual("xpto123", transaction.code)
     self.assertEqual(35, transaction.price)
コード例 #8
0
ファイル: tests.py プロジェクト: MoisesTedeschi/pythonbrasil8
 def test_generate_tutorial_transaction(self):
     subscription = Subscription.objects.create(
         type="tutorial",
         user=self.user,
     )
     subscription.tutorials.add(sched_models.Session.objects.get(pk=1))
     transaction = Transaction.generate(subscription)
     self.assertEqual(subscription, transaction.subscription)
     self.assertEqual("xpto123", transaction.code)
     self.assertEqual(35, transaction.price)
コード例 #9
0
ファイル: views.py プロジェクト: shreyarora12/pythonbrasil8
 def post(self, request):
     tutorials = []
     regexp = re.compile(r"tutorial-(\d{14})")
     for k, v in request.POST.iteritems():
         m = regexp.match(k)
         if m:
             tutorial = Session.objects.get(
                 pk=v,
                 date=datetime.datetime.strptime(m.groups()[0],
                                                 "%Y%m%d%H%M%S"),
                 type="tutorial",
             )
             tutorials.append(tutorial)
     status = "pending"
     if request.user.subscription_set.filter(
             type="talk", status__in=("confirmed", "sponsor")).exists():
         status = "confirmed"
     subscription = Subscription.objects.create(
         user=request.user,
         type="tutorial",
         status=status,
     )
     subscription.tutorials = tutorials
     subscription.save()
     if status == "confirmed":
         return response.TemplateResponse(
             request,
             "subscription/tutorials_confirmed.html",
             context={"subscription": subscription},
         )
     transaction = Transaction.generate(subscription)
     return response.TemplateResponse(
         request,
         "subscription/tutorials_success.html",
         context={
             "transaction": transaction,
             "subscription": subscription,
         },
     )
コード例 #10
0
ファイル: views.py プロジェクト: romuloigor/pythonbrasil8
    def get(self, request, *args, **kwargs):
        profile = AccountProfile.objects.filter(user=request.user)
        if not profile or not profile[0].name:
            msg = ugettext("In order to issue your registration to the conference, you need to complete your profile.")
            messages.error(request, msg, fail_silently=True)
            url = "%s?next=%s" % (reverse("edit-profile"), request.path)
            return HttpResponseRedirect(url)
        subscription = Subscription.objects.create(type="talk", user=request.user)
        t = Transaction.generate(subscription)

        if not t:
            self._notify_staff(request.user)
            subscription.delete()
            url = "/dashboard/"
            messages.error(
                request,
                ugettext(
                    "Failed to generate a transaction within the payment gateway. Please contact the event staff to complete your registration."
                ),
                fail_silently=True,
            )
        else:
            url = settings.PAGSEGURO_WEBCHECKOUT + t.code
        return HttpResponseRedirect(url)
コード例 #11
0
 def test_get_checkout_url(self):
     t = Transaction(code="123")
     expected_url = settings.PAGSEGURO_WEBCHECKOUT + "123"
     self.assertEqual(expected_url, t.get_checkout_url())
コード例 #12
0
 def test_get_checkout_url(self):
     t = Transaction(code="123")
     expected_url = settings.PAGSEGURO_WEBCHECKOUT + "123"
     self.assertEqual(expected_url, t.get_checkout_url())