コード例 #1
0
ファイル: view_tests.py プロジェクト: CarlOfHoly/onlineweb4
    def test_attend_with_payment_creates_paymentdelay(self, mocked_submit):
        mocked_submit.return_value = RecaptchaResponse(is_valid=True)
        event = G(Event)
        G(
            AttendanceEvent,
            event=event,
            registration_start=timezone.now() - timedelta(days=1),
            registration_end=timezone.now() + timedelta(days=1),
        )
        self.event_payment = generate_payment(event,
                                              payment_type=3,
                                              delay=timedelta(days=2))
        G(PaymentPrice, price=200, payment=self.event_payment)
        url = reverse("attend_event", args=(event.id, ))

        form_params = {"g-recaptcha-response": "PASSED"}
        G(
            Membership,
            username=self.user.ntnu_username,
            expiration_date=timezone.now() + timedelta(days=1),
        )
        MarkRuleSet.accept_mark_rules(self.user)

        self.client.post(url, form_params, follow=True)

        self.assertTrue(PaymentDelay.objects.filter(user=self.user).exists())
コード例 #2
0
ファイル: view_tests.py プロジェクト: tor0405/onlineweb4
    def test_attend_twice(self, mocked_submit):
        mocked_submit.return_value = RecaptchaResponse(is_valid=True)
        event = G(Event)
        G(
            AttendanceEvent,
            event=event,
            registration_start=timezone.now() - timedelta(days=1),
            registration_end=timezone.now() + timedelta(days=1),
        )
        url = reverse("attend_event", args=(event.id, ))

        form_params = {"g-recaptcha-response": "PASSED"}
        G(
            Membership,
            username=self.user.ntnu_username,
            expiration_date=timezone.now() + timedelta(days=1),
        )
        MarkRuleSet.accept_mark_rules(self.user)

        self.client.post(url, form_params, follow=True)
        response = self.client.post(url, form_params, follow=True)

        self.assertRedirects(response, event.get_absolute_url())
        self.assertInMessages("Du er allerede meldt på dette arrangementet.",
                              response)
コード例 #3
0
ファイル: view_tests.py プロジェクト: CarlOfHoly/onlineweb4
    def test_attend_invalid_captcha(self, mocked_submit):
        mocked_submit.return_value = RecaptchaResponse(is_valid=False)
        url = reverse("attend_event", args=(self.event.id, ))
        form_params = {"g-recaptcha-response": "WRONG"}
        G(
            Membership,
            username=self.user.ntnu_username,
            expiration_date=timezone.now() + timedelta(days=1),
        )
        MarkRuleSet.accept_mark_rules(self.user)

        response = self.client.post(url, form_params, follow=True)

        self.assertRedirects(response, self.event.get_absolute_url())
        self.assertInMessages("Du klarte ikke captchaen! Er du en bot?",
                              response)
コード例 #4
0
ファイル: views.py プロジェクト: tokongs/onlineweb4
def update_mark_rules(request):
    if request.is_ajax():
        if request.method == "POST":
            accepted = request.POST.get("rules_accepted") == "true"
            if accepted:
                return_status = json.dumps(
                    {"message": _("Du har valgt å akseptere prikkereglene.")})
                MarkRuleSet.accept_mark_rules(request.user)
            else:
                return_status = json.dumps({
                    "message":
                    _("Du kan ikke endre din godkjenning av prikkereglene.")
                })
                return HttpResponse(status=403, content=return_status)
            return HttpResponse(status=212, content=return_status)
    return HttpResponse(status=405)
コード例 #5
0
    def clean(self):
        super(CaptchaForm, self).clean()
        cleaned_data = self.cleaned_data

        if "mark_rules" in self.fields:
            if "mark_rules" in cleaned_data:
                mark_rules = cleaned_data["mark_rules"]

                if mark_rules:
                    MarkRuleSet.accept_mark_rules(self.user)

        if "phone_number" in self.fields:
            if "phone_number" in cleaned_data:
                phone_number = cleaned_data["phone_number"]

                if phone_number:
                    self.user.phone_number = phone_number
                    self.user.save()

        return cleaned_data
コード例 #6
0
ファイル: view_tests.py プロジェクト: tokongs/onlineweb4
    def test_attend_before_registration_start(self, mocked_submit):
        mocked_submit.return_value = RecaptchaResponse(is_valid=True)
        event = G(Event)
        G(
            AttendanceEvent,
            event=event,
            registration_start=timezone.now() + timedelta(days=1),
            registration_end=timezone.now() + timedelta(days=2),
        )
        url = reverse("attend_event", args=(event.id, ))

        form_params = {"g-recaptcha-response": "PASSED"}
        G(
            AllowedUsername,
            username=self.user.ntnu_username,
            expiration_date=timezone.now() + timedelta(days=1),
        )
        MarkRuleSet.accept_mark_rules(self.user)

        response = self.client.post(url, form_params, follow=True)

        self.assertRedirects(response, event.get_absolute_url())
        self.assertInMessages("Påmeldingen har ikke åpnet enda.", response)
コード例 #7
0
ファイル: tests.py プロジェクト: tokongs/onlineweb4
    def test_creating_new_mark_rules_sets_accepted_to_false(self):
        MarkRuleSet.accept_mark_rules(self.user)
        self.assertTrue(self.user.mark_rules_accepted)

        G(MarkRuleSet, valid_from_date=timezone.now())
        self.assertFalse(self.user.mark_rules_accepted)
コード例 #8
0
ファイル: tests.py プロジェクト: tokongs/onlineweb4
    def test_accepting_mark_rules_sets_them_as_accepted(self):
        MarkRuleSet.accept_mark_rules(self.user)

        self.assertTrue(self.user.mark_rules_accepted)