Ejemplo n.º 1
0
    def __call__(self, request):
        url = resolve(request.path_info)

        organiser_slug = url.kwargs.get('organiser')
        if organiser_slug:
            request.organiser = get_object_or_404(Organiser,
                                                  slug__iexact=organiser_slug)
            if hasattr(request, 'organiser') and request.organiser:
                request.is_orga = False
                if not request.user.is_anonymous:
                    has_perms = Team.objects.filter(
                        organiser=request.organiser,
                        members__in=[request.user],
                        can_change_organiser_settings=True,
                    ).exists()
                    request.is_orga = request.user.is_administrator or has_perms

        event_slug = url.kwargs.get('event')
        if event_slug:
            with scopes_disabled():
                request.event = get_object_or_404(
                    Event.objects.prefetch_related('schedules', 'submissions'),
                    slug__iexact=event_slug)
        event = getattr(request, 'event', None)

        self._set_orga_events(request)
        self._select_locale(request)
        is_exempt = (url.url_name == 'export' if 'agenda' in url.namespaces
                     else request.path.startswith('/api/'))

        if 'orga' in url.namespaces or ('plugins' in url.namespaces
                                        and request.path.startswith('/orga')):
            url = self._handle_orga_url(request, url)
            if url:
                return redirect(url)
        elif (event and request.event.settings.custom_domain
              and not request.uses_custom_domain and not is_exempt):
            return redirect(
                urljoin(request.event.settings.custom_domain,
                        request.get_full_path()))
        if event:
            with scope(event=event):
                return self.get_response(request)
        return self.get_response(request)
Ejemplo n.º 2
0
def test_wle_change_to_unavailable_item(token_client, organizer, event, item,
                                        wle, quota):
    with scopes_disabled():
        i = event.items.create(name="Budget Ticket", default_price=23)
        v = i.variations.create(value="S")
        q = event.quotas.create(name="Budget Ticket", size=0)
    q.items.add(i)
    q.variations.add(v)
    change_wle(token_client,
               organizer,
               event,
               wle,
               data={
                   'item': i.pk,
                   'variation': v.pk
               },
               expected_failure=False)
    assert wle.item == i
    assert wle.variation == v
Ejemplo n.º 3
0
def test_change_name(env, client):
    with scopes_disabled():
        customer = env[0].customers.create(email='*****@*****.**', is_verified=True)
        customer.set_password('foo')
        customer.save()

    r = client.post('/bigevents/account/login', {
        'email': '*****@*****.**',
        'password': '******',
    })
    assert r.status_code == 302

    r = client.post(f'/bigevents/account/change', {
        'name_parts_0': 'John Doe',
        'email': '*****@*****.**',
    })
    assert r.status_code == 302
    customer.refresh_from_db()
    assert customer.name == 'John Doe'
Ejemplo n.º 4
0
def create_or_update_store_course_sections():
    store_course_section_objects = []
    with scopes_disabled():
        for store_course in StoreCourse.objects.filter(
                course__course_provider__name='Mindedge'):
            for section in store_course.course.sections.all():
                try:
                    scs = StoreCourseSection.objects.get(
                        store_course=store_course, section=section)
                except StoreCourseSection.DoesNotExist:
                    scs = StoreCourseSection.objects.create(
                        store_course=store_course,
                        section=section,
                        is_published=True,
                        fee=section.fee,
                        seat_capacity=section.seat_capacity)

                store_course_section_objects.append(scs)
    return store_course_section_objects
Ejemplo n.º 5
0
def send_notification(logentry_id: int, action_type: str, user_id: int,
                      method: str):
    logentry = LogEntry.all.get(id=logentry_id)
    if logentry.event:
        sm = lambda: scope(organizer=logentry.event.organizer)  # noqa
    else:
        sm = lambda: scopes_disabled()  # noqa
    with sm():
        user = User.objects.get(id=user_id)
        types = get_all_notification_types(logentry.event)
        notification_type = types.get(action_type)
        if not notification_type:
            return  # Ignore, e.g. plugin not active for this event

        with language(user.locale):
            notification = notification_type.build_notification(logentry)

            if method == "mail":
                send_notification_mail(notification, user)
Ejemplo n.º 6
0
 def test_edit_bulk_price(self):
     sei1 = SubEventItem.objects.create(subevent=self.subevent1, item=self.ticket, price=Decimal('4.00'))
     sei2 = SubEventItem.objects.create(subevent=self.subevent2, item=self.ticket, price=Decimal('4.00'))
     doc = self.post_doc('/control/event/ccc/30c3/subevents/bulk_edit', {
         '__ALL': 'on',
     }, follow=True)
     fields = extract_form_fields(doc)
     assert fields.get('item-{}-price'.format(self.ticket.id)) == '4.00'
     fields.update({
         '_bulk': ['item-{}price'.format(self.ticket.id)],
         'item-{}-price'.format(self.ticket.id): '5.00',
     })
     doc = self.post_doc('/control/event/ccc/30c3/subevents/bulk_edit', fields, follow=True)
     assert doc.select(".alert-success")
     with scopes_disabled():
         sei1.refresh_from_db()
         sei2.refresh_from_db()
         assert sei1.price == Decimal('5.00')
         assert sei2.price == Decimal('5.00')
Ejemplo n.º 7
0
def index(request):
    with scopes_disabled():
        if not request.user.is_authenticated:
            if User.objects.count(
            ) < 1 and 'django.contrib.auth.backends.RemoteUserBackend' not in settings.AUTHENTICATION_BACKENDS:
                return HttpResponseRedirect(reverse_lazy('view_setup'))
            return HttpResponseRedirect(reverse_lazy('view_search'))

    try:
        page_map = {
            UserPreference.SEARCH: reverse_lazy('view_search'),
            UserPreference.PLAN: reverse_lazy('view_plan'),
            UserPreference.BOOKS: reverse_lazy('view_books'),
        }

        return HttpResponseRedirect(
            page_map.get(request.user.userpreference.default_page))
    except UserPreference.DoesNotExist:
        return HttpResponseRedirect(reverse('view_search'))
Ejemplo n.º 8
0
def test_underpaid(env, job):
    djmail.outbox = []
    process_banktransfers(job, [{
        'payer': 'Karla Kundin',
        'reference': 'Bestellung DUMMY1Z3AS',
        'date': '2016-01-26',
        'amount': '22.50'
    }])
    env[2].refresh_from_db()
    assert env[2].status == Order.STATUS_PENDING
    with scopes_disabled():
        p = env[2].payments.last()
        assert p.amount == Decimal('22.50')
        assert p.state == OrderPayment.PAYMENT_STATE_CONFIRMED
        assert env[2].pending_sum == Decimal('0.50')

    assert len(djmail.outbox) == 1
    assert djmail.outbox[
        0].subject == 'Your order received an incomplete payment: 1Z3AS'
Ejemplo n.º 9
0
def test_sendmail_subevents(logged_in_client, sendmail_url, event, order, pos):
    event.has_subevents = True
    event.save()
    with scopes_disabled():
        se1 = event.subevents.create(name='Subevent FOO', date_from=now())
        se2 = event.subevents.create(name='Bar', date_from=now())
        op = order.positions.last()
    op.subevent = se1
    op.save()

    djmail.outbox = []
    response = logged_in_client.post(sendmail_url, {
        'sendto': 'na',
        'action': 'send',
        'recipients': 'orders',
        'items': pos.item_id,
        'subject_0': 'Test subject',
        'message_0': 'This is a test file for sending mails.',
        'subevent': se1.pk,
    },
                                     follow=True)
    assert response.status_code == 200
    assert 'alert-success' in response.rendered_content
    assert len(djmail.outbox) == 1

    djmail.outbox = []
    response = logged_in_client.post(sendmail_url, {
        'sendto': 'na',
        'action': 'send',
        'recipients': 'orders',
        'items': pos.item_id,
        'subject_0': 'Test subject',
        'message_0': 'This is a test file for sending mails.',
        'subevent': se2.pk,
    },
                                     follow=True)
    assert len(djmail.outbox) == 0

    url = sendmail_url + 'history/'
    response = logged_in_client.get(url)

    assert response.status_code == 200
    assert 'Subevent FOO' in response.rendered_content
Ejemplo n.º 10
0
def test_event_get_unexported(mail_setup):
    """This test gets a list of all unexported entries
        - 5 are in the past and should be exported
        - 1 is due today
        - 2 are due in the next days
        - 2 aren't part of the export window which is defined by the prenotification days parameter
    """
    with scopes_disabled():
        event, os, ps = mail_setup
        event.settings.payment_sepadebit_prenotification_days = 2
        event.save()

        request = RequestFactory().get('/')
        request.event = event
        view = EventExportListView()
        view.setup(request)

        ue = view.get_unexported()
        assert len(ue) == 8
Ejemplo n.º 11
0
def test_change_to_item_of_other_event(token_client, organizer, event, item):
    with scopes_disabled():
        e2 = Event.objects.create(
            organizer=organizer,
            name='Dummy2',
            slug='dummy2',
            date_from=datetime.datetime(2017, 12, 27, 10, 0, 0, tzinfo=UTC),
            plugins='pretix.plugins.banktransfer,pretix.plugins.ticketoutputpdf'
        )
        ticket2 = e2.items.create(name='Late-bird ticket', default_price=23)
        v = event.vouchers.create(item=item)
    change_voucher(token_client,
                   organizer,
                   event,
                   v,
                   data={'item': ticket2.pk},
                   expected_failure=True)
    v.refresh_from_db()
    assert v.item == item
Ejemplo n.º 12
0
def test_shopping_food_share(u1_s1, u2_s1, food, space_1):
    with scope(space=space_1):
        user1 = auth.get_user(u1_s1)
        user2 = auth.get_user(u2_s1)
        food2 = FoodFactory(space=space_1)
    r = u1_s1.put(reverse(SHOPPING_FOOD_URL, args={food.id}))
    r = u2_s1.put(reverse(SHOPPING_FOOD_URL, args={food2.id}))
    sl_1 = json.loads(u1_s1.get(reverse(SHOPPING_LIST_URL)).content)
    sl_2 = json.loads(u2_s1.get(reverse(SHOPPING_LIST_URL)).content)
    assert len(sl_1) == 1
    assert len(sl_2) == 1
    sl_1[0]['created_by']['id'] == user1.id
    sl_2[0]['created_by']['id'] == user2.id

    with scopes_disabled():
        user1.userpreference.shopping_share.add(user2)
        user1.userpreference.save()
    assert len(json.loads(u1_s1.get(reverse(SHOPPING_LIST_URL)).content)) == 1
    assert len(json.loads(u2_s1.get(reverse(SHOPPING_LIST_URL)).content)) == 2
Ejemplo n.º 13
0
def test_ics_subevents_attributes(env, client):
    e0 = Event.objects.create(organizer=env[0],
                              name='DS2017',
                              slug='DS2017',
                              date_from=datetime(now().year + 1,
                                                 9,
                                                 1,
                                                 tzinfo=UTC),
                              live=True,
                              is_public=True)
    e = Event.objects.create(organizer=env[0],
                             name='MRMCD2017',
                             slug='2017',
                             date_from=datetime(now().year + 1,
                                                9,
                                                1,
                                                tzinfo=UTC),
                             live=True,
                             is_public=True,
                             has_subevents=True)
    with scopes_disabled():
        se1 = e.subevents.create(date_from=now(), name='SE1', active=True)

    prop = env[0].meta_properties.create(name='loc', default='HH')
    e0.meta_values.create(value='MA', property=prop)
    propval = se1.meta_values.create(value='HD', property=prop)
    r = client.get('/mrmcd/events/ical/?attr[loc]=HD')
    assert b'SE1' in r.content
    assert b'DS2017' not in r.content
    r = client.get('/mrmcd/events/ical/?attr[loc]=MA')
    assert b'SE1' not in r.content
    assert b'DS2017' in r.content

    r = client.get('/mrmcd/events/ical/?attr[loc]=HH')
    assert b'SE1' not in r.content
    propval.delete()
    r = client.get('/mrmcd/events/ical/?attr[loc]=HH')
    assert b'SE1' in r.content
    e.meta_values.create(value='B', property=prop)
    r = client.get('/mrmcd/events/ical/?attr[loc]=HH')
    assert b'SE1' not in r.content
    r = client.get('/mrmcd/events/ical/?attr[loc]=B')
    assert b'SE1' in r.content
Ejemplo n.º 14
0
def test_create_multiple_vouchers(token_client, organizer, event, item):
    resp = token_client.post(
        '/api/v1/organizers/{}/events/{}/vouchers/batch_create/'.format(
            organizer.slug, event.slug),
        data=[{
            'code': 'ABCDEFGHI',
            'max_usages': 1,
            'valid_until': None,
            'block_quota': False,
            'allow_ignore_quota': False,
            'price_mode': 'set',
            'value': '12.00',
            'item': item.pk,
            'variation': None,
            'quota': None,
            'tag': 'Foo',
            'comment': '',
            'subevent': None
        }, {
            'code': 'JKLMNOPQR',
            'max_usages': 1,
            'valid_until': None,
            'block_quota': True,
            'allow_ignore_quota': False,
            'price_mode': 'set',
            'value': '12.00',
            'item': item.pk,
            'variation': None,
            'quota': None,
            'tag': 'Foo',
            'comment': '',
            'subevent': None
        }],
        format='json')
    assert resp.status_code == 201
    with scopes_disabled():
        assert Voucher.objects.count() == 2
        assert resp.data[0]['code'] == 'ABCDEFGHI'
        v1 = Voucher.objects.get(code='ABCDEFGHI')
        assert not v1.block_quota
        assert resp.data[1]['code'] == 'JKLMNOPQR'
        v2 = Voucher.objects.get(code='JKLMNOPQR')
        assert v2.block_quota
Ejemplo n.º 15
0
def test_event_update_seating(token_client, organizer, event, item,
                              seatingplan):
    resp = token_client.patch('/api/v1/organizers/{}/events/{}/'.format(
        organizer.slug, event.slug), {
            "seating_plan": seatingplan.pk,
            "seat_category_mapping": {
                "Stalls": item.pk
            }
        },
                              format='json')
    assert resp.status_code == 200
    event.refresh_from_db()
    assert event.seating_plan == seatingplan
    with scopes_disabled():
        assert event.seats.count() == 3
        assert event.seats.filter(product=item).count() == 3
        m = event.seat_category_mappings.get()
    assert m.layout_category == 'Stalls'
    assert m.product == item
Ejemplo n.º 16
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()
Ejemplo n.º 17
0
def test_delete(u1_s1, u1_s2, obj_1):
    r = u1_s2.delete(
        reverse(
            DETAIL_URL,
            args={obj_1.id}
        )
    )
    assert r.status_code == 404

    r = u1_s1.delete(
        reverse(
            DETAIL_URL,
            args={obj_1.id}
        )
    )

    assert r.status_code == 204
    with scopes_disabled():
        assert RecipeBook.objects.count() == 0
def set_default_search_vector(apps, schema_editor):
    if settings.DATABASES['default']['ENGINE'] not in [
            'django.db.backends.postgresql_psycopg2',
            'django.db.backends.postgresql'
    ]:
        return
    language = DICTIONARY.get(translation.get_language(), 'simple')
    with scopes_disabled():
        # TODO this approach doesn't work terribly well if multiple languages are in use
        # I'm also uncertain about forcing unaccent here
        Recipe.objects.all().update(
            name_search_vector=SearchVector('name__unaccent',
                                            weight='A',
                                            config=language),
            desc_search_vector=SearchVector('description__unaccent',
                                            weight='B',
                                            config=language))
        Step.objects.all().update(
            search_vector=SearchVector('instruction__unaccent', weight='B'))
Ejemplo n.º 19
0
def task_periodic_schedule_export(event_slug):
    with scopes_disabled():
        event = (Event.objects.filter(slug=event_slug).prefetch_related(
            '_settings_objects', 'submissions__slots').first())
    with scope(event=event):
        zip_path = get_export_zip_path(event)
        last_time = event.cache.get('last_schedule_rebuild')
        _now = now()
        if not event.settings.export_html_on_schedule_release:
            event.cache.delete('rebuild_schedule_export')
            return
        if last_time and _now - last_time < timedelta(hours=1):
            return
        should_rebuild_schedule = event.cache.get(
            'rebuild_schedule_export') or not zip_path.exists()
        if should_rebuild_schedule:
            event.cache.delete('rebuild_schedule_export')
            event.cache.set('last_schedule_rebuild', _now, None)
            export_schedule_html.apply_async(kwargs={'event_id': event.id})
Ejemplo n.º 20
0
def test_change_variation_of_blocking_voucher_quota_free(
        token_client, organizer, event):
    with scopes_disabled():
        shirt = event.items.create(name='Shirt', default_price=23)
        vs = shirt.variations.create(value='S')
        vm = shirt.variations.create(value='M')
        qs = event.quotas.create(name='S', size=2)
        qs.variations.add(vs)
        qm = event.quotas.create(name='M', size=2)
        qm.variations.add(vm)
        v = event.vouchers.create(item=shirt, variation=vs, block_quota=True)
    change_voucher(
        token_client,
        organizer,
        event,
        v,
        data={'variation': vm.pk},
    )
    assert v.variation == vm
Ejemplo n.º 21
0
 def test_set_dependency_to_non_choice(self):
     with scopes_disabled():
         q1 = Question.objects.create(event=self.event1,
                                      question="What country are you from?",
                                      type="N",
                                      required=True)
         q2 = Question.objects.create(event=self.event1,
                                      question="What city are you from?",
                                      type="T",
                                      required=True)
     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_values'] = '1'
     doc = self.post_doc(
         '/control/event/%s/%s/questions/%s/change' %
         (self.orga1.slug, self.event1.slug, q2.id), form_data)
     assert not doc.select(".alert-success")
Ejemplo n.º 22
0
def test_delete(u1_s1, u1_s2, recipe_1_s1):
    with scopes_disabled():
        r = u1_s2.delete(
            reverse(
                DETAIL_URL,
                args={recipe_1_s1.id}
            )
        )
        assert r.status_code == 404

        r = u1_s1.delete(
            reverse(
                DETAIL_URL,
                args={recipe_1_s1.id}
            )
        )

        assert r.status_code == 204
        assert not Recipe.objects.filter(pk=recipe_1_s1.id).exists()
Ejemplo n.º 23
0
def upsert_certificate(pg_provider, certificate_obj):
    try:
        price = certificate_obj.price['amount']
        external_image_url = certificate_obj.default_image['original']
    except KeyError:
        price = 0
        external_image_url = ''

    with scopes_disabled():
        certificates = Certificate.objects.filter(
            content_db_reference=str(certificate_obj.id))

        if certificates.exists():
            certificates.update(course_provider=pg_provider,
                                title=certificate_obj.title,
                                slug=certificate_obj.slug,
                                content_db_reference=str(certificate_obj.id),
                                external_image_url=external_image_url,
                                price=price)
            certificate = certificates.first()
        else:
            certificate = Certificate.objects.create(
                course_provider=pg_provider,
                title=certificate_obj.title,
                slug=certificate_obj.slug,
                content_db_reference=str(certificate_obj.id),
                external_image_url=external_image_url,
                price=price,
                content_ready=True)

        for course_obj in certificate_obj.courses:
            course = get_course(course_obj.id)
            if not course:
                continue

            certificate_courses = CertificateCourse.objects.filter(
                certificate=certificate, course=course)
            if not certificate_courses.exists():
                CertificateCourse.objects.create(certificate=certificate,
                                                 course=course)

        return certificate
Ejemplo n.º 24
0
def test_create_multiple_vouchers_duplicate_seat(token_client, organizer,
                                                 event, item, seat1,
                                                 seatingplan):
    resp = token_client.post(
        '/api/v1/organizers/{}/events/{}/vouchers/batch_create/'.format(
            organizer.slug, event.slug),
        data=[{
            'code': 'ABCDEFGHI',
            'max_usages': 1,
            'valid_until': None,
            'block_quota': False,
            'allow_ignore_quota': False,
            'price_mode': 'set',
            'value': '12.00',
            'item': item.pk,
            'variation': None,
            'quota': None,
            'tag': 'Foo',
            'comment': '',
            'subevent': None,
            'seat': 'A1',
        }, {
            'code': 'ABCDEFGHI',
            'max_usages': 1,
            'valid_until': None,
            'block_quota': True,
            'allow_ignore_quota': False,
            'price_mode': 'set',
            'value': '12.00',
            'item': item.pk,
            'variation': None,
            'quota': None,
            'tag': 'Foo',
            'comment': '',
            'subevent': None,
            'seat': 'A1',
        }],
        format='json')
    assert resp.status_code == 400
    assert resp.data == [{}, {'code': ['Duplicate seat ID in request.']}]
    with scopes_disabled():
        assert Voucher.objects.count() == 0
Ejemplo n.º 25
0
    def test_orders_questions_required(self):
        self.event.settings.set('attendee_names_asked', False)
        self.event.settings.set('attendee_names_required', False)
        self.question.required = True
        self.question.save()

        response = self.client.get('/%s/%s/order/%s/%s/modify' %
                                   (self.orga.slug, self.event.slug,
                                    self.order.code, self.order.secret))
        doc = BeautifulSoup(response.rendered_content, "lxml")
        self.assertEqual(
            len(
                doc.select('input[name="%s-question_%s"]' %
                           (self.ticket_pos.id, self.question.id))), 1)

        # Not all required fields filled out, expect failure
        response = self.client.post(
            '/%s/%s/order/%s/%s/modify' % (self.orga.slug, self.event.slug,
                                           self.order.code, self.order.secret),
            {
                '%s-question_%s' % (self.ticket_pos.id, self.question.id): '',
            },
            follow=True)
        doc = BeautifulSoup(response.rendered_content, "lxml")
        self.assertGreaterEqual(len(doc.select('.has-error')), 1)

        response = self.client.post(
            '/%s/%s/order/%s/%s/modify' % (self.orga.slug, self.event.slug,
                                           self.order.code, self.order.secret),
            {
                '%s-question_%s' % (self.ticket_pos.id, self.question.id):
                'ABC',
            },
            follow=True)
        self.assertRedirects(response,
                             '/%s/%s/order/%s/%s/' %
                             (self.orga.slug, self.event.slug, self.order.code,
                              self.order.secret),
                             target_status_code=200)
        with scopes_disabled():
            assert self.ticket_pos.answers.get(
                question=self.question).answer == 'ABC'
Ejemplo n.º 26
0
def test_webhook_global(env, client, monkeypatch):
    order = env[1]
    order.status = Order.STATUS_PENDING
    order.save()
    with scopes_disabled():
        order.payments.update(state=OrderPayment.PAYMENT_STATE_PENDING)

    charge = get_test_charge(env[1])
    monkeypatch.setattr("paypalrestsdk.Sale.find", lambda *args: charge)
    monkeypatch.setattr("pretix.plugins.paypal.payment.Paypal.init_api",
                        lambda *args: None)
    ReferencedPayPalObject.objects.create(
        order=order, reference="PAY-5YK922393D847794YKER7MUI")

    client.post('/_paypal/webhook/',
                json.dumps({
                    "id": "WH-2WR32451HC0233532-67976317FL4543714",
                    "create_time": "2014-10-23T17:23:52Z",
                    "resource_type": "sale",
                    "event_type": "PAYMENT.SALE.COMPLETED",
                    "summary":
                    "A successful sale payment was made for $ 0.48 USD",
                    "resource": {
                        "amount": {
                            "total": "-0.01",
                            "currency": "USD"
                        },
                        "id": "36C38912MN9658832",
                        "parent_payment": "PAY-5YK922393D847794YKER7MUI",
                        "update_time": "2014-10-31T15:41:51Z",
                        "state": "completed",
                        "create_time": "2014-10-31T15:41:51Z",
                        "links": [],
                        "sale_id": "9T0916710M1105906"
                    },
                    "links": [],
                    "event_version": "1.0"
                }),
                content_type='application_json')

    order.refresh_from_db()
    assert order.status == Order.STATUS_PAID
Ejemplo n.º 27
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")
        with scopes_disabled():
            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()
Ejemplo n.º 28
0
def test_event_model_slug_uniqueness():
    with scopes_disabled():
        Event.objects.create(name='Event',
                             slug='slog',
                             is_public=True,
                             email='*****@*****.**',
                             locale_array='en,de',
                             locale='en',
                             date_from=datetime.date.today(),
                             date_to=datetime.date.today())
        assert Event.objects.count() == 1
        with pytest.raises(IntegrityError):
            Event.objects.create(name='Event',
                                 slug='slog',
                                 is_public=True,
                                 email='*****@*****.**',
                                 locale_array='en,de',
                                 locale='en',
                                 date_from=datetime.date.today(),
                                 date_to=datetime.date.today()).clean_fields()
Ejemplo n.º 29
0
def cached_invoice_address(request):
    from .cart import cart_session

    if not hasattr(request, '_checkout_flow_invoice_address'):
        if not request.session.session_key:
            # do not create a session, if we don't have a session we also don't have an invoice address ;)
            request._checkout_flow_invoice_address = InvoiceAddress()
            return request._checkout_flow_invoice_address
        cs = cart_session(request)
        iapk = cs.get('invoice_address')
        if not iapk:
            request._checkout_flow_invoice_address = InvoiceAddress()
        else:
            try:
                with scopes_disabled():
                    request._checkout_flow_invoice_address = InvoiceAddress.objects.get(
                        pk=iapk, order__isnull=True)
            except InvoiceAddress.DoesNotExist:
                request._checkout_flow_invoice_address = InvoiceAddress()
    return request._checkout_flow_invoice_address
Ejemplo n.º 30
0
    def test_subevent_blocking_quota_free(self):
        with scopes_disabled():
            self.event.has_subevents = True
            self.event.save()
            se1 = self.event.subevents.create(name="Foo", date_from=now())
            se2 = self.event.subevents.create(name="Bar", date_from=now())

            self.quota_tickets.subevent = se1
            self.quota_tickets.save()
            q2 = Quota.objects.create(event=self.event,
                                      name='Tickets',
                                      size=0,
                                      subevent=se2)
            q2.items.add(self.ticket)

        self._create_voucher({
            'itemvar': '%d' % self.ticket.pk,
            'block_quota': 'on',
            'subevent': se1.pk
        })