Beispiel #1
0
    def test_settings(self):
        doc = self.get_doc('/control/event/%s/%s/settings/' % (self.orga1.slug, self.event1.slug))
        doc.select("[name=date_to]")[0]['value'] = "2013-12-30 17:00:00"
        doc.select("[name=settings-max_items_per_order]")[0]['value'] = "12"
        print(extract_form_fields(doc.select('.container-fluid form')[0]))

        doc = self.post_doc('/control/event/%s/%s/settings/' % (self.orga1.slug, self.event1.slug),
                            extract_form_fields(doc.select('.container-fluid form')[0]))
        assert len(doc.select(".alert-success")) > 0
        assert doc.select("[name=date_to]")[0]['value'] == "2013-12-30 17:00:00"
        assert doc.select("[name=settings-max_items_per_order]")[0]['value'] == "12"
Beispiel #2
0
 def test_create(self):
     doc = self.get_doc('/control/event/%s/%s/categories/add' % (self.orga1.slug, self.event1.slug))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data['name_0'] = 'Entry tickets'
     doc = self.post_doc('/control/event/%s/%s/categories/add' % (self.orga1.slug, self.event1.slug), form_data)
     assert doc.select(".alert-success")
     self.assertIn("Entry tickets", doc.select("#page-wrapper table")[0].text)
Beispiel #3
0
 def test_create(self):
     doc = self.get_doc('/control/event/%s/%s/quotas/add' % (self.orga1.slug, self.event1.slug))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data['name'] = 'Full house'
     form_data['size'] = '500'
     doc = self.post_doc('/control/event/%s/%s/quotas/add' % (self.orga1.slug, self.event1.slug), form_data)
     assert doc.select(".alert-success")
     self.assertIn("Full house", doc.select("#page-wrapper table")[0].text)
Beispiel #4
0
 def test_create(self):
     doc = self.get_doc('/control/event/%s/%s/questions/add' % (self.orga1.slug, self.event1.slug))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data['question_0'] = 'What is your shoe size?'
     form_data['type'] = 'N'
     doc = self.post_doc('/control/event/%s/%s/questions/add' % (self.orga1.slug, self.event1.slug), form_data)
     assert doc.select(".alert-success")
     self.assertIn("shoe size", doc.select("#page-wrapper table")[0].text)
Beispiel #5
0
 def test_delete(self):
     c = Question.objects.create(event=self.event1, question="What is your shoe size?", type="N", required=True)
     doc = self.get_doc('/control/event/%s/%s/questions/%s/delete' % (self.orga1.slug, self.event1.slug, c.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     doc = self.post_doc('/control/event/%s/%s/questions/%s/delete' % (self.orga1.slug, self.event1.slug, c.id),
                         form_data)
     assert doc.select(".alert-success")
     self.assertNotIn("shoe size", doc.select("#page-wrapper")[0].text)
     assert not Question.objects.filter(id=c.id).exists()
Beispiel #6
0
 def _change_voucher(self, v, data, expected_failure=False):
     doc = self.get_doc('/control/event/%s/%s/vouchers/%s/' % (self.orga.slug, self.event.slug, v.pk))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data.update(data)
     doc = self.post_doc('/control/event/%s/%s/vouchers/%s/' % (self.orga.slug, self.event.slug, v.pk), form_data)
     if expected_failure:
         assert doc.select(".alert-danger")
     else:
         assert doc.select(".alert-success")
Beispiel #7
0
 def test_ticket_settings(self):
     doc = self.get_doc('/control/event/%s/%s/settings/tickets' % (self.orga1.slug, self.event1.slug))
     data = extract_form_fields(doc.select("form")[0])
     data['ticket_download'] = 'on'
     data['ticketoutput_testdummy__enabled'] = 'on'
     doc = self.post_doc('/control/event/%s/%s/settings/tickets' % (self.orga1.slug, self.event1.slug),
                         data, follow=True)
     self.event1.settings._flush()
     assert self.event1.settings.get('ticket_download', as_type=bool)
Beispiel #8
0
 def test_delete_default_rule(self):
     tr = self.event1.tax_rules.create(rate=19, name="VAT")
     self.event1.settings.tax_rate_default = tr
     doc = self.get_doc('/control/event/%s/%s/settings/tax/%s/delete' % (self.orga1.slug, self.event1.slug, tr.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     doc = self.post_doc('/control/event/%s/%s/settings/tax/%s/delete' % (self.orga1.slug, self.event1.slug, tr.id),
                         form_data)
     self.assertIn("VAT", doc.select("#page-wrapper")[0].text)
     assert self.event1.tax_rules.exists()
Beispiel #9
0
 def test_delete(self):
     c = ItemCategory.objects.create(event=self.event1, name="Entry tickets")
     doc = self.get_doc('/control/event/%s/%s/categories/%s/delete' % (self.orga1.slug, self.event1.slug, c.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     doc = self.post_doc('/control/event/%s/%s/categories/%s/delete' % (self.orga1.slug, self.event1.slug, c.id),
                         form_data)
     assert doc.select(".alert-success")
     self.assertNotIn("Entry tickets", doc.select("#page-wrapper")[0].text)
     assert not ItemCategory.objects.filter(id=c.id).exists()
Beispiel #10
0
 def test_delete(self):
     c = Quota.objects.create(event=self.event1, name="Full house", size=500)
     doc = self.get_doc('/control/event/%s/%s/quotas/%s/delete' % (self.orga1.slug, self.event1.slug, c.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     doc = self.post_doc('/control/event/%s/%s/quotas/%s/delete' % (self.orga1.slug, self.event1.slug, c.id),
                         form_data)
     assert doc.select(".alert-success")
     self.assertNotIn("Full house", doc.select("#page-wrapper")[0].text)
     assert not Quota.objects.filter(id=c.id).exists()
Beispiel #11
0
 def test_invoice_settings(self):
     doc = self.get_doc('/control/event/%s/%s/settings/invoice' % (self.orga1.slug, self.event1.slug))
     data = extract_form_fields(doc.select("form")[0])
     data['invoice_address_required'] = 'on'
     doc = self.post_doc('/control/event/%s/%s/settings/invoice' % (self.orga1.slug, self.event1.slug),
                         data, follow=True)
     assert doc.select('.alert-success')
     self.event1.settings._flush()
     assert self.event1.settings.get('invoice_address_required', as_type=bool)
Beispiel #12
0
 def test_create(self):
     doc = self.get_doc('/control/event/%s/%s/badges/add' % (self.orga1.slug, self.event1.slug))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data['name'] = 'Layout 1'
     doc = self.post_doc('/control/event/%s/%s/badges/add' % (self.orga1.slug, self.event1.slug), form_data)
     assert doc.select(".alert-success")
     self.assertIn("Layout 1", doc.select("#page-wrapper")[0].text)
     assert self.event1.badge_layouts.get(
         default=True, name='Layout 1'
     )
Beispiel #13
0
 def test_update(self):
     tr = self.event1.tax_rules.create(rate=19, name="VAT")
     doc = self.get_doc('/control/event/%s/%s/settings/tax/%s/' % (self.orga1.slug, self.event1.slug, tr.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data['rate'] = '20.00'
     doc = self.post_doc('/control/event/%s/%s/settings/tax/%s/' % (self.orga1.slug, self.event1.slug, tr.id),
                         form_data)
     assert doc.select(".alert-success")
     tr.refresh_from_db()
     assert tr.rate == Decimal('20.00')
Beispiel #14
0
    def test_organizer_settings(self):
        doc = self.get_doc('/control/organizer/%s/edit' % (self.orga1.slug,))
        doc.select("[name=name]")[0]['value'] = "CCC e.V."

        doc = self.post_doc('/control/organizer/%s/edit' % (self.orga1.slug,),
                            extract_form_fields(doc.select('.container-fluid form')[0]))
        assert len(doc.select(".alert-success")) > 0
        assert doc.select("[name=name]")[0]['value'] == "CCC e.V."
        self.orga1.refresh_from_db()
        assert self.orga1.name == "CCC e.V."
Beispiel #15
0
 def test_update(self):
     c = ItemCategory.objects.create(event=self.event1, name="Entry tickets")
     doc = self.get_doc('/control/event/%s/%s/categories/%s/' % (self.orga1.slug, self.event1.slug, c.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data['name_0'] = 'T-Shirts'
     doc = self.post_doc('/control/event/%s/%s/categories/%s/' % (self.orga1.slug, self.event1.slug, c.id),
                         form_data)
     assert doc.select(".alert-success")
     self.assertIn("T-Shirts", doc.select("#page-wrapper table")[0].text)
     self.assertNotIn("Entry tickets", doc.select("#page-wrapper table")[0].text)
     assert str(ItemCategory.objects.get(id=c.id).name) == 'T-Shirts'
Beispiel #16
0
 def test_display_voucher_code(self):
     count_before = self.event.vouchers.count()
     doc = self.get_doc('/control/event/%s/%s/vouchers/add' % (self.orga.slug, self.event.slug))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data.update({
         'itemvar': '%d' % self.ticket.pk
     })
     doc = self.post_doc('/control/event/%s/%s/vouchers/add' % (self.orga.slug, self.event.slug), form_data)
     v = Voucher.objects.latest('pk')
     assert v.code in doc.select(".alert-success")[0].text
     assert count_before + 1 == self.event.vouchers.count()
Beispiel #17
0
 def test_create(self):
     doc = self.get_doc('/control/event/%s/%s/settings/tax/add' % (self.orga1.slug, self.event1.slug))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data['name_0'] = 'VAT'
     form_data['rate'] = '19.00'
     form_data['price_includes_tax'] = 'on'
     doc = self.post_doc('/control/event/%s/%s/settings/tax/add' % (self.orga1.slug, self.event1.slug), form_data)
     assert doc.select(".alert-success")
     self.assertIn("VAT", doc.select("#page-wrapper table")[0].text)
     assert self.event1.tax_rules.get(
         rate=19, price_includes_tax=True, eu_reverse_charge=False
     )
Beispiel #18
0
    def test_email_settings(self):
        with mocker_context() as mocker:
            mocked = mocker.patch('pretix.base.email.CustomSMTPBackend.test')

            doc = self.get_doc('/control/event/%s/%s/settings/email' % (self.orga1.slug, self.event1.slug))
            data = extract_form_fields(doc.select("form")[0])
            data['test'] = '1'
            doc = self.post_doc('/control/event/%s/%s/settings/email' % (self.orga1.slug, self.event1.slug),
                                data, follow=True)
            assert doc.select('.alert-success')
            self.event1.settings._flush()
            assert mocked.called
Beispiel #19
0
 def test_delete(self):
     bl1 = self.event1.badge_layouts.create(name="Layout 1", default=True)
     bl2 = self.event1.badge_layouts.create(name="Layout 2")
     doc = self.get_doc('/control/event/%s/%s/badges/%s/delete' % (self.orga1.slug, self.event1.slug, bl1.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     doc = self.post_doc('/control/event/%s/%s/badges/%s/delete' % (self.orga1.slug, self.event1.slug, bl1.id),
                         form_data)
     assert doc.select(".alert-success")
     self.assertNotIn("Layout 1", doc.select("#page-wrapper")[0].text)
     assert self.event1.badge_layouts.count() == 1
     bl2.refresh_from_db()
     assert bl2.default
Beispiel #20
0
 def test_update_subevent(self):
     self.event1.has_subevents = True
     self.event1.save()
     se1 = self.event1.subevents.create(name="Foo", date_from=now())
     se2 = self.event1.subevents.create(name="Bar", date_from=now())
     c = Quota.objects.create(event=self.event1, name="Full house", size=500, subevent=se1)
     doc = self.get_doc('/control/event/%s/%s/quotas/%s/change' % (self.orga1.slug, self.event1.slug, c.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data['subevent'] = se2.pk
     self.post_doc('/control/event/%s/%s/quotas/%s/change' % (self.orga1.slug, self.event1.slug, c.id),
                   form_data)
     assert Quota.objects.get(id=c.id).subevent == se2
Beispiel #21
0
 def test_update(self):
     c = Question.objects.create(event=self.event1, question="What is your shoe size?", type="N", required=True)
     doc = self.get_doc('/control/event/%s/%s/questions/%s/change' % (self.orga1.slug, self.event1.slug, c.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data['question_0'] = 'How old are you?'
     doc = self.post_doc('/control/event/%s/%s/questions/%s/change' % (self.orga1.slug, self.event1.slug, c.id),
                         form_data)
     self.assertIn("How old", doc.select("#page-wrapper table")[0].text)
     self.assertNotIn("shoe size", doc.select("#page-wrapper table")[0].text)
     c = Question.objects.get(id=c.id)
     self.assertTrue(c.required)
     assert str(Question.objects.get(id=c.id).question) == 'How old are you?'
Beispiel #22
0
 def _create_bulk_vouchers(self, data, expected_failure=False):
     count_before = self.event.vouchers.count()
     doc = self.get_doc('/control/event/%s/%s/vouchers/bulk_add' % (self.orga.slug, self.event.slug))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data.update(data)
     doc = self.post_doc('/control/event/%s/%s/vouchers/bulk_add' % (self.orga.slug, self.event.slug), form_data)
     if expected_failure:
         assert doc.select(".alert-danger")
         assert count_before == self.event.vouchers.count()
     else:
         assert doc.select(".alert-success")
         assert count_before + len(form_data.get('codes').split("\n")) == self.event.vouchers.count()
Beispiel #23
0
    def test_organizer_display_settings(self):
        assert not self.orga1.settings.presale_css_checksum
        doc = self.get_doc('/control/organizer/%s/settings/display' % (self.orga1.slug,))
        doc.select("[name=primary_color]")[0]['value'] = "#33c33c"

        doc = self.post_doc('/control/organizer/%s/settings/display' % (self.orga1.slug,),
                            extract_form_fields(doc.select('.container-fluid form')[0]))
        assert len(doc.select(".alert-success")) > 0
        assert doc.select("[name=primary_color]")[0]['value'] == "#33c33c"
        self.orga1.settings.flush()
        assert self.orga1.settings.primary_color == "#33c33c"
        assert self.orga1.settings.presale_css_checksum
Beispiel #24
0
    def test_display_settings(self):
        with mocker_context() as mocker:
            mocked = mocker.patch('pretix.presale.style.regenerate_css.apply_async')

            doc = self.get_doc('/control/event/%s/%s/settings/display' % (self.orga1.slug, self.event1.slug))
            data = extract_form_fields(doc.select("form")[0])
            data['primary_color'] = '#FF0000'
            doc = self.post_doc('/control/event/%s/%s/settings/display' % (self.orga1.slug, self.event1.slug),
                                data, follow=True)
            assert doc.select('.alert-success')
            self.event1.settings._flush()
            assert self.event1.settings.get('primary_color') == '#FF0000'
            mocked.assert_any_call(args=(self.event1.pk,))
Beispiel #25
0
    def test_add_to_existing_quota(self):
        q = Quota.objects.create(event=self.event1, name="New Test Quota", size=50)

        doc = self.get_doc('/control/event/%s/%s/items/add' % (self.orga1.slug, self.event1.slug))
        form_data = extract_form_fields(doc.select('.container-fluid form')[0])
        form_data['name_0'] = 'Existing'
        form_data['default_price'] = '2.00'
        form_data['quota_option'] = 'existing'
        form_data['quota_add_existing'] = str(q.pk)
        doc = self.post_doc('/control/event/%s/%s/items/add' % (self.orga1.slug, self.event1.slug), form_data)

        i = Item.objects.get(name__icontains='Existing')

        assert doc.select(".alert-success")
        assert q.items.filter(pk=i.pk).exists()
Beispiel #26
0
 def test_update(self):
     c = Quota.objects.create(event=self.event1, name="Full house", size=500)
     item1 = Item.objects.create(event=self.event1, name="Standard", default_price=0)
     item2 = Item.objects.create(event=self.event1, name="Business", default_price=0)
     ItemVariation.objects.create(item=item2, value="Silver")
     ItemVariation.objects.create(item=item2, value="Gold")
     doc = self.get_doc('/control/event/%s/%s/quotas/%s/change' % (self.orga1.slug, self.event1.slug, c.id))
     doc.select('[name=item_%s]' % item1.id)[0]['checked'] = 'checked'
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data['size'] = '350'
     doc = self.post_doc('/control/event/%s/%s/quotas/%s/change' % (self.orga1.slug, self.event1.slug, c.id),
                         form_data)
     self.assertIn("350", doc.select("#page-wrapper table")[0].text)
     self.assertNotIn("500", doc.select("#page-wrapper table")[0].text)
     assert Quota.objects.get(id=c.id).size == 350
     assert item1 in Quota.objects.get(id=c.id).items.all()
Beispiel #27
0
 def test_update_choices(self):
     c = Question.objects.create(event=self.event1, question="What country are you from?", type="C", required=True)
     o1 = c.options.create(answer='Germany')
     doc = self.get_doc('/control/event/%s/%s/questions/%s/change' % (self.orga1.slug, self.event1.slug, c.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data['form-TOTAL_FORMS'] = '1'
     form_data['form-INITIAL_FORMS'] = '1'
     form_data['form-MIN_NUM_FORMS'] = '0'
     form_data['form-MAX_NUM_FORMS'] = '1'
     form_data['form-0-id'] = o1.pk
     form_data['form-0-answer_0'] = 'England'
     self.post_doc('/control/event/%s/%s/questions/%s/change' % (self.orga1.slug, self.event1.slug, c.id),
                   form_data)
     c.refresh_from_db()
     assert c.options.exists()
     assert str(c.options.first().answer) == 'England'
Beispiel #28
0
    def test_add_to_new_quota(self):
        doc = self.get_doc('/control/event/%s/%s/items/add' % (self.orga1.slug, self.event1.slug))
        form_data = extract_form_fields(doc.select('.container-fluid form')[0])
        form_data['name_0'] = 'New Item'
        form_data['default_price'] = '2.00'
        form_data['quota_option'] = 'new'
        form_data['quota_add_new_name'] = 'New Quota'
        form_data['quota_add_new_size'] = '200'
        doc = self.post_doc('/control/event/%s/%s/items/add' % (self.orga1.slug, self.event1.slug), form_data)

        assert doc.select(".alert-success")
        assert Quota.objects.filter(name__icontains='New Quota').exists()
        assert Item.objects.filter(name__icontains='New Item').exists()
        i = Item.objects.get(name__icontains='New Item')
        q = Quota.objects.get(name__icontains='New Quota')
        assert q.items.filter(pk=i.pk).exists()
Beispiel #29
0
 def test_delete_fee_existing(self):
     tr = self.event1.tax_rules.create(rate=19, name="VAT")
     o = self.event1.orders.create(
         code='FOO', event=self.event1, email='*****@*****.**',
         status=Order.STATUS_PENDING,
         datetime=now(), expires=now() + datetime.timedelta(days=10),
         total=14, locale='en',
     )
     o.fees.create(fee_type=OrderFee.FEE_TYPE_PAYMENT, value=Decimal('0.25'), tax_rate=Decimal('19.00'),
                   tax_value=Decimal('0.05'), tax_rule=tr)
     doc = self.get_doc('/control/event/%s/%s/settings/tax/%s/delete' % (self.orga1.slug, self.event1.slug, tr.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     doc = self.post_doc('/control/event/%s/%s/settings/tax/%s/delete' % (self.orga1.slug, self.event1.slug, tr.id),
                         form_data)
     self.assertIn("VAT", doc.select("#page-wrapper")[0].text)
     assert self.event1.tax_rules.exists()
Beispiel #30
0
 def test_delete_orderpos_existing(self):
     tr = self.event1.tax_rules.create(rate=19, name="VAT")
     i = self.event1.items.create(name="foo", default_price=12)
     o = self.event1.orders.create(
         code='FOO', event=self.event1, email='*****@*****.**',
         status=Order.STATUS_PENDING,
         datetime=now(), expires=now() + datetime.timedelta(days=10),
         total=12, locale='en'
     )
     o.positions.create(
         item=i, price=12, tax_rule=tr, tax_rate=19, tax_value=12 - 12 / 1.19
     )
     doc = self.get_doc('/control/event/%s/%s/settings/tax/%s/delete' % (self.orga1.slug, self.event1.slug, tr.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     doc = self.post_doc('/control/event/%s/%s/settings/tax/%s/delete' % (self.orga1.slug, self.event1.slug, tr.id),
                         form_data)
     self.assertIn("VAT", doc.select("#page-wrapper")[0].text)
     assert self.event1.tax_rules.exists()
Beispiel #31
0
    def test_add_to_existing_quota(self):
        with scopes_disabled():
            q = Quota.objects.create(event=self.event1,
                                     name="New Test Quota",
                                     size=50)

        doc = self.get_doc('/control/event/%s/%s/items/add' %
                           (self.orga1.slug, self.event1.slug))
        form_data = extract_form_fields(doc.select('.container-fluid form')[0])
        form_data['name_0'] = 'Existing'
        form_data['default_price'] = '2.00'
        form_data['quota_option'] = 'existing'
        form_data['quota_add_existing'] = str(q.pk)
        doc = self.post_doc(
            '/control/event/%s/%s/items/add' %
            (self.orga1.slug, self.event1.slug), form_data)

        with scopes_disabled():
            i = Item.objects.get(name__icontains='Existing')

            assert doc.select(".alert-success")
            assert q.items.filter(pk=i.pk).exists()
Beispiel #32
0
 def test_set_dependency_circular(self):
     with scopes_disabled():
         q1 = Question.objects.create(event=self.event1,
                                      question="What country are you from?",
                                      type="C",
                                      required=True)
         o1 = q1.options.create(answer='Germany')
         q2 = Question.objects.create(event=self.event1,
                                      question="What city are you from?",
                                      type="C",
                                      required=True,
                                      dependency_question=q1,
                                      dependency_value=o1.identifier)
     doc = self.get_doc('/control/event/%s/%s/questions/%s/change' %
                        (self.orga1.slug, self.event1.slug, q1.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data['dependency_question'] = q2.pk
     form_data['dependency_value'] = '1'
     doc = self.post_doc(
         '/control/event/%s/%s/questions/%s/change' %
         (self.orga1.slug, self.event1.slug, q1.id), form_data)
     assert not doc.select(".alert-success")
Beispiel #33
0
 def test_update(self):
     with scopes_disabled():
         c = Question.objects.create(event=self.event1,
                                     question="What is your shoe size?",
                                     type="N",
                                     required=True)
     doc = self.get_doc('/control/event/%s/%s/questions/%s/change' %
                        (self.orga1.slug, self.event1.slug, c.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data['items'] = self.item1.id
     form_data['question_0'] = 'How old are you?'
     doc = self.post_doc(
         '/control/event/%s/%s/questions/%s/change' %
         (self.orga1.slug, self.event1.slug, c.id), form_data)
     self.assertIn("How old", doc.select("#page-wrapper table")[0].text)
     self.assertNotIn("shoe size",
                      doc.select("#page-wrapper table")[0].text)
     with scopes_disabled():
         c = Question.objects.get(id=c.id)
         self.assertTrue(c.required)
         assert str(
             Question.objects.get(id=c.id).question) == 'How old are you?'
Beispiel #34
0
 def test_delete_variation(self):
     doc = self.get_doc('/control/event/%s/%s/items/%d/' %
                        (self.orga1.slug, self.event1.slug, self.item2.id))
     d = extract_form_fields(doc.select('.container-fluid form')[0])
     d.update({
         'variations-TOTAL_FORMS': '2',
         'variations-INITIAL_FORMS': '2',
         'variations-MIN_NUM_FORMS': '0',
         'variations-MAX_NUM_FORMS': '1000',
         'variations-0-id': str(self.var1.pk),
         'variations-0-value_0': 'Bronze',
         'variations-0-active': 'yes',
         'variations-1-id': str(self.var2.pk),
         'variations-1-value_0': 'Gold',
         'variations-1-active': 'yes',
         'variations-1-DELETE': 'yes',
     })
     self.client.post(
         '/control/event/%s/%s/items/%d/' %
         (self.orga1.slug, self.event1.slug, self.item2.id), d)
     with scopes_disabled():
         assert not self.item2.variations.filter(pk=self.var2.pk).exists()
Beispiel #35
0
 def test_set_dependency(self):
     q1 = Question.objects.create(event=self.event1,
                                  question="What country are you from?",
                                  type="C",
                                  required=True)
     q2 = Question.objects.create(event=self.event1,
                                  question="What city are you from?",
                                  type="T",
                                  required=True)
     o1 = q1.options.create(answer='Germany')
     doc = self.get_doc('/control/event/%s/%s/questions/%s/change' %
                        (self.orga1.slug, self.event1.slug, q2.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data['dependency_question'] = q1.pk
     form_data['dependency_value'] = o1.identifier
     doc = self.post_doc(
         '/control/event/%s/%s/questions/%s/change' %
         (self.orga1.slug, self.event1.slug, q2.id), form_data)
     assert doc.select(".alert-success")
     q2.refresh_from_db()
     assert q2.dependency_question == q1
     assert q2.dependency_value == o1.identifier
Beispiel #36
0
    def test_edit_bulk_day_unset(self):
        with scopes_disabled():
            self.subevent1.date_to = datetime.datetime(2013, 12, 26, 9, 0, 0, tzinfo=datetime.timezone.utc)
            self.subevent1.save()
            self.subevent2.date_to = datetime.datetime(2013, 12, 27, 11, 0, 0, tzinfo=datetime.timezone.utc)
            self.subevent2.save()

        doc = self.post_doc('/control/event/ccc/30c3/subevents/bulk_edit', {
            '__ALL': 'on',
        }, follow=True)
        fields = extract_form_fields(doc)
        assert not fields.get('bulkedit-date_to_day')
        fields.update({
            '_bulk': ['bulkeditdate_to_day'],
        })
        doc = self.post_doc('/control/event/ccc/30c3/subevents/bulk_edit', fields, follow=True)
        assert doc.select(".alert-success")
        with scopes_disabled():
            self.subevent1.refresh_from_db()
            self.subevent2.refresh_from_db()
            assert self.subevent1.date_to is None
            assert self.subevent2.date_to is None
Beispiel #37
0
    def test_edit_bulk_time_both_same_before(self):
        with scopes_disabled():
            self.subevent1.date_to = datetime.datetime(2013, 12, 26, 9, 0, 0, tzinfo=datetime.timezone.utc)
            self.subevent1.save()
            self.subevent2.date_to = datetime.datetime(2013, 12, 27, 9, 0, 0, tzinfo=datetime.timezone.utc)
            self.subevent2.save()

        doc = self.post_doc('/control/event/ccc/30c3/subevents/bulk_edit', {
            '__ALL': 'on',
        }, follow=True)
        fields = extract_form_fields(doc)
        assert fields.get('bulkedit-date_to_time') == '09:00:00'
        fields.update({
            '_bulk': ['bulkeditdate_to_time'],
            'bulkedit-date_to_time': '10:00:00',
        })
        doc = self.post_doc('/control/event/ccc/30c3/subevents/bulk_edit', fields, follow=True)
        assert doc.select(".alert-success")
        with scopes_disabled():
            self.subevent1.refresh_from_db()
            self.subevent2.refresh_from_db()
            assert self.subevent1.date_to == datetime.datetime(2013, 12, 26, 10, 0, 0, tzinfo=datetime.timezone.utc)
            assert self.subevent2.date_to == datetime.datetime(2013, 12, 27, 10, 0, 0, tzinfo=datetime.timezone.utc)
Beispiel #38
0
 def test_delete_order_existing(self):
     tr = self.event1.tax_rules.create(rate=19, name="VAT")
     self.event1.orders.create(code='FOO',
                               event=self.event1,
                               email='*****@*****.**',
                               status=Order.STATUS_PENDING,
                               datetime=now(),
                               expires=now() + datetime.timedelta(days=10),
                               total=14,
                               payment_provider='banktransfer',
                               locale='en',
                               payment_fee=0.3,
                               payment_fee_tax_rate=19,
                               payment_fee_tax_value=0.05,
                               payment_fee_tax_rule=tr)
     doc = self.get_doc('/control/event/%s/%s/settings/tax/%s/delete' %
                        (self.orga1.slug, self.event1.slug, tr.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     doc = self.post_doc(
         '/control/event/%s/%s/settings/tax/%s/delete' %
         (self.orga1.slug, self.event1.slug, tr.id), form_data)
     self.assertIn("VAT", doc.select("#page-wrapper")[0].text)
     assert self.event1.tax_rules.exists()
Beispiel #39
0
 def test_email_setup_simple_with_verification(self):
     doc = self.post_doc(
         '/control/organizer/%s/settings/email/setup' % self.orga1.slug,
         {
             'mode': 'simple',
             'simple-mail_from': '*****@*****.**',
         },
         follow=True
     )
     self.orga1.settings.flush()
     assert "mail_from" not in self.orga1.settings._cache()
     data = extract_form_fields(doc.select("form")[0])
     data['verification'] = self.client.session[
         f'sender_mail_verification_code_/control/organizer/{self.orga1.slug}/settings/email/[email protected]'
     ]
     doc = self.post_doc(
         '/control/organizer/%s/settings/email/setup' % self.orga1.slug,
         data,
         follow=True
     )
     assert doc.select('.alert-success')
     self.orga1.settings.flush()
     assert self.orga1.settings.mail_from == '*****@*****.**'
Beispiel #40
0
 def test_email_setup_no_verification_spf_success(self):
     self.monkeypatch.setattr("pretix.control.views.mailsetup.get_spf_record", OrganizerTest._fake_spf_record)
     doc = self.post_doc(
         '/control/organizer/%s/settings/email/setup' % self.orga1.slug,
         {
             'mode': 'simple',
             'simple-mail_from': '*****@*****.**',
         },
         follow=True
     )
     assert doc.select('.alert-success')
     self.orga1.settings.flush()
     # not yet saved
     assert "mail_from" not in self.orga1.settings._cache()
     data = extract_form_fields(doc.select("form")[0])
     doc = self.post_doc(
         '/control/organizer/%s/settings/email/setup' % self.orga1.slug,
         data,
         follow=True
     )
     assert doc.select('.alert-success')
     self.orga1.settings.flush()
     assert self.orga1.settings.mail_from == '*****@*****.**'
Beispiel #41
0
 def test_add_choices(self):
     with scopes_disabled():
         c = Question.objects.create(event=self.event1,
                                     question="What country are you from?",
                                     type="N",
                                     required=True)
     doc = self.get_doc('/control/event/%s/%s/questions/%s/change' %
                        (self.orga1.slug, self.event1.slug, c.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data['type'] = 'C'
     form_data['form-TOTAL_FORMS'] = '1'
     form_data['form-INITIAL_FORMS'] = '0'
     form_data['form-MIN_NUM_FORMS'] = '0'
     form_data['form-MAX_NUM_FORMS'] = '1'
     form_data['items'] = self.item1.id
     form_data['form-0-id'] = ''
     form_data['form-0-answer_0'] = 'Germany'
     self.post_doc(
         '/control/event/%s/%s/questions/%s/change' %
         (self.orga1.slug, self.event1.slug, c.id), form_data)
     with scopes_disabled():
         c = Question.objects.get(id=c.id)
         assert c.options.exists()
         assert str(c.options.first().answer) == 'Germany'
Beispiel #42
0
 def test_delete_choices(self):
     with scopes_disabled():
         c = Question.objects.create(event=self.event1,
                                     question="What country are you from?",
                                     type="C",
                                     required=True)
         o1 = c.options.create(answer='Germany')
     doc = self.get_doc('/control/event/%s/%s/questions/%s/change' %
                        (self.orga1.slug, self.event1.slug, c.id))
     form_data = extract_form_fields(doc.select('.container-fluid form')[0])
     form_data['form-TOTAL_FORMS'] = '1'
     form_data['form-INITIAL_FORMS'] = '1'
     form_data['form-MIN_NUM_FORMS'] = '0'
     form_data['form-MAX_NUM_FORMS'] = '1'
     form_data['items'] = self.item1.id
     form_data['form-0-id'] = o1.pk
     form_data['form-0-answer_0'] = 'England'
     form_data['form-0-DELETE'] = 'yes'
     self.post_doc(
         '/control/event/%s/%s/questions/%s/change' %
         (self.orga1.slug, self.event1.slug, c.id), form_data)
     c.refresh_from_db()
     with scopes_disabled():
         assert not c.options.exists()
Beispiel #43
0
    def test_organizer_display_settings(self):
        called = False

        def set_called(*args, **kwargs):
            nonlocal called
            called = True

        self.monkeypatch.setattr(
            "pretix.presale.style.regenerate_organizer_css.apply_async",
            set_called)
        assert not self.orga1.settings.presale_css_checksum
        doc = self.get_doc('/control/organizer/%s/edit' % (self.orga1.slug, ))
        doc.select("[name=settings-primary_color]")[0]['value'] = "#33c33c"

        with transaction.atomic():
            doc = self.post_doc(
                '/control/organizer/%s/edit' % (self.orga1.slug, ),
                extract_form_fields(doc.select('.container-fluid form')[0]))
            assert len(doc.select(".alert-success")) > 0
            assert doc.select(
                "[name=settings-primary_color]")[0]['value'] == "#33c33c"
        self.orga1.settings.flush()
        assert self.orga1.settings.primary_color == "#33c33c"
        assert called
Beispiel #44
0
    def test_manipulate_bundles(self):
        doc = self.get_doc('/control/event/%s/%s/items/%d/' %
                           (self.orga1.slug, self.event1.slug, self.item2.id))
        d = extract_form_fields(doc.select('.container-fluid form')[0])

        d.update({
            'bundles-TOTAL_FORMS': '1',
            'bundles-INITIAL_FORMS': '0',
            'bundles-MIN_NUM_FORMS': '0',
            'bundles-MAX_NUM_FORMS': '1000',
            'bundles-0-id': '',
            'bundles-0-itemvar': str(self.item1.pk),
            'bundles-0-count': '2',
            'bundles-0-designated_price': '',
        })
        self.client.post(
            '/control/event/%s/%s/items/%d/' %
            (self.orga1.slug, self.event1.slug, self.item2.id), d)
        with scopes_disabled():
            assert self.item2.bundles.exists()
            assert self.item2.bundles.first().bundled_item == self.item1
            assert self.item2.bundles.first().designated_price == Decimal(
                '0.000')
        d.update({
            'bundles-TOTAL_FORMS': '1',
            'bundles-INITIAL_FORMS': '1',
            'bundles-MIN_NUM_FORMS': '0',
            'bundles-MAX_NUM_FORMS': '1000',
            'bundles-0-id': str(self.item2.bundles.first().pk),
            'bundles-0-itemvar': str(self.item1.pk),
            'bundles-0-count': '2',
            'bundles-0-designated_price': '2.00',
            'bundles-0-DELETE': 'on',
        })
        self.client.post(
            '/control/event/%s/%s/items/%d/' %
            (self.orga1.slug, self.event1.slug, self.item2.id), d)
        with scopes_disabled():
            assert not self.item2.bundles.exists()

        # Do not allow self-reference
        d.update({
            'bundles-TOTAL_FORMS': '1',
            'bundles-INITIAL_FORMS': '0',
            'bundles-MIN_NUM_FORMS': '0',
            'bundles-MAX_NUM_FORMS': '1000',
            'bundles-0-id': '',
            'bundles-0-itemvar': str(self.item2.pk),
            'bundles-0-count': '2',
            'bundles-0-designated_price': '2.00',
        })
        self.client.post(
            '/control/event/%s/%s/items/%d/' %
            (self.orga1.slug, self.event1.slug, self.item2.id), d)
        with scopes_disabled():
            assert not self.item2.bundles.exists()

        # Do not allow multi-level bundles
        with scopes_disabled():
            self.item1.bundles.create(bundled_item=self.item1,
                                      count=1,
                                      designated_price=0)
        d.update({
            'bundles-TOTAL_FORMS': '1',
            'bundles-INITIAL_FORMS': '0',
            'bundles-MIN_NUM_FORMS': '0',
            'bundles-MAX_NUM_FORMS': '1000',
            'bundles-0-id': '',
            'bundles-0-itemvar': str(self.item1.pk),
            'bundles-0-count': '2',
            'bundles-0-designated_price': '2.00',
        })
        self.client.post(
            '/control/event/%s/%s/items/%d/' %
            (self.orga1.slug, self.event1.slug, self.item2.id), d)
        with scopes_disabled():
            assert not self.item2.bundles.exists()
Beispiel #45
0
    def test_edit_bulk_quotas_add_and_edit(self):
        doc = self.post_doc('/control/event/ccc/30c3/subevents/bulk_edit', {
            '__ALL': 'on',
        }, follow=True)
        fields = extract_form_fields(doc)
        fields.update({
            '_bulk': ['__quotas'],
            'quotas-TOTAL_FORMS': '2',
            'quotas-INITIAL_FORMS': '0',
            'quotas-MIN_NUM_FORMS': '0',
            'quotas-MAX_NUM_FORMS': '1000',
            'quotas-0-name': 'Q1',
            'quotas-0-size': '50',
            'quotas-0-itemvars': str(self.ticket.pk),
            'quotas-1-name': 'Q2',
            'quotas-1-size': '25',
            'quotas-1-itemvars': str(self.ticket.pk),
        })
        doc = self.post_doc('/control/event/ccc/30c3/subevents/bulk_edit', fields, follow=True)
        assert doc.select(".alert-success")
        with scopes_disabled():
            for se in [self.subevent1, self.subevent2]:
                q = se.quotas.first()
                assert q.name == 'Q1'
                assert q.size == 50
                assert list(q.items.all()) == [self.ticket]
                q = se.quotas.last()
                assert q.name == 'Q2'
                assert q.size == 25
                assert list(q.items.all()) == [self.ticket]

        doc = self.post_doc('/control/event/ccc/30c3/subevents/bulk_edit', {
            '__ALL': 'on',
        }, follow=True)
        fields = extract_form_fields(doc)
        fields.update({
            '_bulk': ['__quotas'],
            'quotas-0-size': '25',
            'quotas-1-size': '50',
        })
        doc = self.post_doc('/control/event/ccc/30c3/subevents/bulk_edit', fields, follow=True)
        assert doc.select(".alert-success")
        with scopes_disabled():
            for se in [self.subevent1, self.subevent2]:
                q = se.quotas.get(name='Q1')
                assert q.size == 25
                assert list(q.items.all()) == [self.ticket]
                q = se.quotas.get(name='Q2')
                assert q.size == 50
                assert list(q.items.all()) == [self.ticket]

        doc = self.post_doc('/control/event/ccc/30c3/subevents/bulk_edit', {
            '__ALL': 'on',
        }, follow=True)
        fields = extract_form_fields(doc)
        fields.update({
            '_bulk': ['__quotas'],
            'quotas-1-DELETE': 'on',
        })
        doc = self.post_doc('/control/event/ccc/30c3/subevents/bulk_edit', fields, follow=True)
        assert doc.select(".alert-success")
        with scopes_disabled():
            for se in [self.subevent1, self.subevent2]:
                assert se.quotas.count() == 1
 def setUp(self):
     super().setUp()
     self.user = User.objects.create_user('*****@*****.**', 'dummy')
     self.client.login(email='*****@*****.**', password='******')
     doc = self.get_doc('/control/settings')
     self.form_data = extract_form_fields(doc.select('.container-fluid form')[0])