Skip to content

Commit

Permalink
Fixed trial being disabled after registering through the BestellWizard
Browse files Browse the repository at this point in the history
  • Loading branch information
Theophile-Madet committed Jun 18, 2024
1 parent 309fd7d commit 2e6aae2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
7 changes: 3 additions & 4 deletions tapir/wirgarten/forms/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ def save(
),
withdrawal_consent_ts=now,
trial_end_date_override=existing_trial_end_date,
trial_disabled=existing_trial_end_date is None,
**self.build_solidarity_fields(),
)

Expand Down Expand Up @@ -532,8 +531,9 @@ def is_valid(self):

if has_harvest_shares:
self.validate_harvest_shares_consent()
self.validate_pickup_location()
self.validate_pickup_location_capacity()
if self.member_id:
self.validate_pickup_location()
self.validate_pickup_location_capacity()
self.validate_total_capacity()
self.validate_solidarity_price()

Expand Down Expand Up @@ -800,7 +800,6 @@ def save(
consent_ts=now if self.product_type.contract_link else None,
withdrawal_consent_ts=now,
trial_end_date_override=existing_trial_end_date,
trial_disabled=existing_trial_end_date is None,
)
)

Expand Down
5 changes: 4 additions & 1 deletion tapir/wirgarten/service/delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dateutil.relativedelta import relativedelta

from tapir.configuration.parameter import get_parameter_value
from tapir.wirgarten.constants import EVEN_WEEKS, ODD_WEEKS, WEEKLY
from tapir.wirgarten.constants import EVEN_WEEKS, ODD_WEEKS, WEEKLY, NO_DELIVERY
from tapir.wirgarten.models import (
GrowingPeriod,
Member,
Expand Down Expand Up @@ -79,6 +79,9 @@ def get_next_delivery_date_for_product_type(
if reference_date is None:
reference_date = get_today()

if product_type.delivery_cycle == NO_DELIVERY[0]:
return reference_date

next_delivery_date = get_next_delivery_date(reference_date)
_, week_num, _ = next_delivery_date.isocalendar()
even_week = week_num % 2 == 0
Expand Down
2 changes: 1 addition & 1 deletion tapir/wirgarten/service/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from typing import List

from dateutil.relativedelta import relativedelta
from django.conf import settings
from django.db import transaction
from tapir_mail.triggers.transactional_trigger import TransactionalTrigger

from django.conf import settings
from tapir.accounts.models import TapirUser
from tapir.configuration.parameter import get_parameter_value
from tapir.wirgarten.models import (
Expand Down
6 changes: 3 additions & 3 deletions tapir/wirgarten/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Meta:
model = ProductPrice

product = factory.SubFactory(ProductFactory)
price = factory.Faker("random_float", min=30, max=150)
price = factory.Faker("pyfloat", min_value=30, max_value=150)
valid_from = TODAY


Expand All @@ -109,7 +109,7 @@ class Meta:

period = factory.SubFactory(GrowingPeriodFactory)
product_type = factory.SubFactory(ProductTypeFactory)
capacity = factory.Faker("random_float", min=1000, max=5000)
capacity = factory.Faker("pyfloat", min_value=1000, max_value=5000)


class SubscriptionFactory(factory.django.DjangoModelFactory):
Expand All @@ -125,7 +125,7 @@ class Meta:
mandate_ref = factory.SubFactory(
MandateReferenceFactory, member=factory.SelfAttribute("..member")
)
solidarity_price = factory.Faker("random_float", min=-0.25, max=0.25)
solidarity_price = factory.Faker("pyfloat", min_value=-0.25, max_value=0.25)


class PickupLocationFactory(factory.django.DjangoModelFactory):
Expand Down
2 changes: 1 addition & 1 deletion tapir/wirgarten_site/registration/forms/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from tapir.configuration.parameter import get_parameter_value
from tapir.wirgarten.constants import DeliveryCycleDict
from tapir.wirgarten.forms.subscription import BASE_PRODUCT_FIELD_PREFIX
from tapir.wirgarten.models import HarvestShareProduct, Product, ProductType
from tapir.wirgarten.models import Product, ProductType
from tapir.wirgarten.parameters import Parameter
from tapir.wirgarten.service.delivery import get_next_delivery_date_for_product_type
from tapir.wirgarten.service.products import get_product_price
Expand Down

0 comments on commit 2e6aae2

Please sign in to comment.