2024-07-22 17:12:03 +00:00
|
|
|
from datetime import timedelta
|
|
|
|
|
2024-10-09 11:12:09 +00:00
|
|
|
from dateutil.relativedelta import relativedelta
|
2024-09-20 12:08:29 +00:00
|
|
|
from django.conf import settings
|
2024-10-09 11:12:09 +00:00
|
|
|
from django.utils.timezone import localdate, now
|
2024-07-22 17:12:03 +00:00
|
|
|
from model_bakery import seq
|
|
|
|
from model_bakery.recipe import Recipe, related
|
|
|
|
|
2024-09-20 12:08:29 +00:00
|
|
|
from club.models import Membership
|
2024-11-30 19:30:17 +00:00
|
|
|
from core.models import Group, User
|
2024-07-22 17:12:03 +00:00
|
|
|
from subscription.models import Subscription
|
|
|
|
|
|
|
|
active_subscription = Recipe(
|
|
|
|
Subscription,
|
2024-10-09 11:12:09 +00:00
|
|
|
subscription_start=localdate() - timedelta(days=30),
|
|
|
|
subscription_end=localdate() + timedelta(days=30),
|
2024-07-22 17:12:03 +00:00
|
|
|
)
|
|
|
|
ended_subscription = Recipe(
|
|
|
|
Subscription,
|
2024-10-09 11:12:09 +00:00
|
|
|
subscription_start=localdate() - timedelta(days=60),
|
|
|
|
subscription_end=localdate() - timedelta(days=30),
|
2024-07-22 17:12:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
subscriber_user = Recipe(
|
|
|
|
User,
|
|
|
|
first_name="subscriber",
|
|
|
|
last_name=seq("user "),
|
|
|
|
subscriptions=related(active_subscription),
|
|
|
|
)
|
2024-09-20 12:08:29 +00:00
|
|
|
"""A user with an active subscription."""
|
|
|
|
|
2024-07-22 17:12:03 +00:00
|
|
|
old_subscriber_user = Recipe(
|
|
|
|
User,
|
|
|
|
first_name="old subscriber",
|
|
|
|
last_name=seq("user "),
|
|
|
|
subscriptions=related(ended_subscription),
|
|
|
|
)
|
2024-09-20 12:08:29 +00:00
|
|
|
"""A user with an ended subscription."""
|
|
|
|
|
2024-10-09 11:12:09 +00:00
|
|
|
__inactivity = localdate() - settings.SITH_ACCOUNT_INACTIVITY_DELTA
|
|
|
|
very_old_subscriber_user = old_subscriber_user.extend(
|
|
|
|
subscriptions=related(
|
|
|
|
ended_subscription.extend(
|
|
|
|
subscription_start=__inactivity - relativedelta(months=6, days=1),
|
|
|
|
subscription_end=__inactivity - relativedelta(days=1),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
"""A user which subscription ended enough time ago to be considered as inactive."""
|
|
|
|
|
2024-09-20 12:08:29 +00:00
|
|
|
ae_board_membership = Recipe(
|
|
|
|
Membership,
|
|
|
|
start_date=now() - timedelta(days=30),
|
|
|
|
club_id=settings.SITH_MAIN_CLUB_ID,
|
|
|
|
role=settings.SITH_CLUB_ROLES_ID["Board member"],
|
|
|
|
)
|
|
|
|
|
|
|
|
board_user = Recipe(
|
|
|
|
User,
|
|
|
|
first_name="AE",
|
|
|
|
last_name=seq("member "),
|
|
|
|
memberships=related(ae_board_membership),
|
2024-11-30 19:30:17 +00:00
|
|
|
groups=lambda: [Group.objects.get(club_board=settings.SITH_MAIN_CLUB_ID)],
|
2024-09-20 12:08:29 +00:00
|
|
|
)
|
|
|
|
"""A user which is in the board of the AE."""
|