Skip to content

Commit

Permalink
Implement organizer onboarding process | Validate condition to public…
Browse files Browse the repository at this point in the history
… Event (#429)

* Implement billing settings form for organizer

* Fix flake8 in pipeline

* implement create and save payment_information

* Fix isort, flake8 in pipeline

* implement payment-information-v1

* src/pretix/control/views/organizer_views/organizer_view.py

* Code refactoring

* Code refactoring

* Remove payment_information attribute

* Implement tax validation

* Update code

* Update code

* Fix flake8 in pipeline

* Add pyvat package

* Fix flake8 in pipeline

* Latest code

* Fix flake8 in pipeline

* Add logger error

* Fix flake8 in pipeline

* Fix conflict pretix base migration

* Update pretix base migration

* Add logging information and modify error logging

* Add comment,save tax_id, show error and sucess message

* Validate to public Event

* fix UT

---------

Co-authored-by: odkhang <[email protected]>
  • Loading branch information
lcduong and odkhang authored Nov 20, 2024
1 parent f927a2a commit c688a83
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
23 changes: 22 additions & 1 deletion src/pretix/base/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from pretix.helpers.thumb import get_thumbnail

from ..settings import settings_hierarkey
from .organizer import Organizer, Team
from .organizer import Organizer, OrganizerBillingModel, Team


class EventMixin:
Expand Down Expand Up @@ -1191,6 +1191,27 @@ def live_issues(self):
)
)

billing_obj = OrganizerBillingModel.objects.filter(organizer=self.organizer).first()

if not billing_obj or not billing_obj.stripe_payment_method_id:
issues.append(
(
"<a {a_attr}>"
+ gettext('You need to fill the billing information.')
+ "</a>"
).format(
a_attr='href="%s#tab-0-1-open"'
% (
reverse(
"control:organizer.settings.billing",
kwargs={
"organizer": self.organizer.slug,
},
),
),
)
)

responses = event_live_issues.send(self)
for receiver, response in sorted(responses, key=lambda r: str(r[0])):
if response:
Expand Down
21 changes: 21 additions & 0 deletions src/tests/api/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from pretix.base.models import Device, Event, Organizer, Team, User
from pretix.base.models.devices import generate_api_token
from pretix.base.models.organizer import OrganizerBillingModel


@pytest.fixture
Expand All @@ -21,6 +22,26 @@ def organizer():
return Organizer.objects.create(name='Dummy', slug='dummy')


@pytest.fixture
@scopes_disabled()
def organizer_billing(organizer):
return OrganizerBillingModel.objects.create(
organizer=organizer,
primary_contact_name="John Doe",
primary_contact_email="[email protected]",
company_or_organization_name="Eventyay",
address_line_1="123 Main Street",
city="San Francisco",
zip_code="94105",
country="US",
preferred_language="en",
tax_id="123456789",
stripe_customer_id="cus_123456789",
stripe_payment_method_id="pm_123456789",
stripe_setup_intent_id="seti_123456789"
)


@pytest.fixture
@scopes_disabled()
def meta_prop(organizer):
Expand Down
2 changes: 1 addition & 1 deletion src/tests/api/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ def test_event_update_live_no_payment_method(token_client, organizer, event, ite


@pytest.mark.django_db
def test_event_update_live_free_product(token_client, organizer, event, free_item, free_quota):
def test_event_update_live_free_product(token_client, organizer, event, free_item, free_quota, organizer_billing):
resp = token_client.patch(
'/api/v1/organizers/{}/events/{}/'.format(organizer.slug, event.slug),
{
Expand Down
16 changes: 16 additions & 0 deletions src/tests/control/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from tests.base import SoupTest, extract_form_fields

from pretix.base.models import Event, Order, Organizer, Team, User
from pretix.base.models.organizer import OrganizerBillingModel
from pretix.testutils.mock import mocker_context


Expand All @@ -20,6 +21,21 @@ def setUp(self):
self.user = User.objects.create_user('[email protected]', 'dummy')
self.orga1 = Organizer.objects.create(name='CCC', slug='ccc')
self.orga2 = Organizer.objects.create(name='MRM', slug='mrm')
self.orgabilling1 = OrganizerBillingModel.objects.create(
organizer=self.orga1,
primary_contact_name="John Doe",
primary_contact_email="[email protected]",
company_or_organization_name="Eventyay",
address_line_1="123 Main Street",
city="San Francisco",
zip_code="94105",
country="US",
preferred_language="en",
tax_id="123456789",
stripe_customer_id="cus_123456789",
stripe_payment_method_id="pm_123456789",
stripe_setup_intent_id="seti_123456789"
)
self.event1 = Event.objects.create(
organizer=self.orga1, name='30C3', slug='30c3',
date_from=datetime.datetime(2013, 12, 26, tzinfo=datetime.timezone.utc),
Expand Down

0 comments on commit c688a83

Please sign in to comment.