2024-02-29 13:25:50 +05:30
|
|
|
from django import forms
|
|
|
|
|
from manage_subscriptions.models import PrincipalSubscription, Subscription, Plan
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PlanForm(forms.ModelForm):
|
|
|
|
|
class Meta:
|
|
|
|
|
model = Plan
|
|
|
|
|
fields = ["title", "days"] # Include all fields you want from the model
|
|
|
|
|
|
|
|
|
|
# You can add custom validation for Plan fields here if needed
|
|
|
|
|
# Example:
|
|
|
|
|
# def clean_title(self):
|
|
|
|
|
# title = self.cleaned_data.get('title')
|
|
|
|
|
# # Add your validation logic here
|
|
|
|
|
# return title
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SubscriptionForm(forms.ModelForm):
|
|
|
|
|
class Meta:
|
|
|
|
|
model = Subscription
|
|
|
|
|
fields = [
|
|
|
|
|
"title",
|
|
|
|
|
"plan",
|
|
|
|
|
"amount",
|
|
|
|
|
] # Include all fields you want from the model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PrincipalSubscriptionForm(forms.ModelForm):
|
|
|
|
|
class Meta:
|
|
|
|
|
model = PrincipalSubscription
|
|
|
|
|
fields = "__all__" # Includes all fields from the model
|
|
|
|
|
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"}),
|
|
|
|
|
"cancelled_date_time": forms.DateTimeInput(attrs={"type": "datetime"}),
|
2024-02-29 13:25:50 +05:30
|
|
|
}
|