2024-02-29 13:25:50 +05:30
|
|
|
from django import forms
|
2024-07-22 21:08:56 +05:30
|
|
|
from accounts.models import IAmPrincipalType
|
2024-07-31 13:12:17 +05:30
|
|
|
from manage_subscriptions.models import (
|
|
|
|
|
PrincipalSubscription,
|
|
|
|
|
Subscription,
|
|
|
|
|
)
|
2024-02-29 13:25:50 +05:30
|
|
|
|
|
|
|
|
class SubscriptionForm(forms.ModelForm):
|
|
|
|
|
class Meta:
|
|
|
|
|
model = Subscription
|
|
|
|
|
fields = [
|
|
|
|
|
"title",
|
2024-08-20 16:57:19 +05:30
|
|
|
"short_description",
|
2024-08-25 19:11:49 +05:30
|
|
|
"long_description",
|
2024-08-20 16:57:19 +05:30
|
|
|
"interval",
|
|
|
|
|
"interval_count",
|
2024-04-10 14:53:30 +05:30
|
|
|
"high_amount",
|
2024-02-29 13:25:50 +05:30
|
|
|
"amount",
|
2024-04-07 16:45:22 +05:30
|
|
|
"principal_types",
|
2024-04-24 13:45:16 +05:30
|
|
|
"referral_percentage",
|
2024-06-04 16:12:52 +05:30
|
|
|
"active",
|
2024-06-27 17:24:52 +05:30
|
|
|
"is_free",
|
2024-07-22 21:08:56 +05:30
|
|
|
]
|
|
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
|
super(SubscriptionForm, self).__init__(*args, **kwargs)
|
|
|
|
|
event_user = IAmPrincipalType.objects.get(name="event_user")
|
|
|
|
|
event_manager = IAmPrincipalType.objects.get(name="event_manager")
|
|
|
|
|
self.fields["principal_types"].queryset = IAmPrincipalType.objects.filter(
|
|
|
|
|
id__in=[event_user.id, event_manager.id]
|
|
|
|
|
)
|
2024-02-29 13:25:50 +05:30
|
|
|
|
2024-08-25 22:57:32 +05:30
|
|
|
class SubscriptionUpdateForm(forms.ModelForm):
|
|
|
|
|
class Meta:
|
|
|
|
|
model = Subscription
|
|
|
|
|
fields = [
|
|
|
|
|
"title",
|
|
|
|
|
"short_description",
|
|
|
|
|
"long_description",
|
|
|
|
|
"referral_percentage",
|
|
|
|
|
"active",
|
|
|
|
|
"is_free",
|
|
|
|
|
]
|
2024-02-29 13:25:50 +05:30
|
|
|
|
|
|
|
|
class PrincipalSubscriptionForm(forms.ModelForm):
|
|
|
|
|
class Meta:
|
|
|
|
|
model = PrincipalSubscription
|
2024-08-21 23:24:47 +05:30
|
|
|
fields = [
|
|
|
|
|
"subscription",
|
|
|
|
|
"principal",
|
|
|
|
|
"status",
|
|
|
|
|
"start_date",
|
|
|
|
|
"end_date",
|
|
|
|
|
"grace_period_end_date",
|
|
|
|
|
"comments",
|
|
|
|
|
"coupon_code"
|
|
|
|
|
] # Includes all fields from the model
|
2024-02-29 13:25:50 +05:30
|
|
|
widgets = {
|
2024-03-15 15:57:09 +05:30
|
|
|
"start_date": forms.DateInput(attrs={"type": "date"}),
|
|
|
|
|
"end_date": forms.DateInput(attrs={"type": "date"}),
|
|
|
|
|
"grace_period_end_date": forms.DateInput(attrs={"type": "date"}),
|
2024-02-29 13:25:50 +05:30
|
|
|
}
|
2024-07-31 13:12:17 +05:30
|
|
|
|
|
|
|
|
|