refator(subscription): update functionality, list view, subscription design
This commit is contained in:
@@ -11,6 +11,7 @@ class SubscriptionForm(forms.ModelForm):
|
||||
fields = [
|
||||
"title",
|
||||
"short_description",
|
||||
"long_description",
|
||||
"interval",
|
||||
"interval_count",
|
||||
"high_amount",
|
||||
@@ -20,6 +21,7 @@ class SubscriptionForm(forms.ModelForm):
|
||||
"active",
|
||||
"is_free",
|
||||
]
|
||||
exclude = []
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SubscriptionForm, self).__init__(*args, **kwargs)
|
||||
@@ -29,6 +31,23 @@ class SubscriptionForm(forms.ModelForm):
|
||||
id__in=[event_user.id, event_manager.id]
|
||||
)
|
||||
|
||||
if self.instance:
|
||||
# If there is an instance (i.e. we're editing an existing subscription)
|
||||
|
||||
# Use a dictionary comprehension to create a new dictionary of fields
|
||||
# that excludes the readonly fields
|
||||
self.fields = {
|
||||
field_name: field
|
||||
for field_name, field in self.fields.items()
|
||||
if field_name not in [
|
||||
"interval",
|
||||
"interval_count",
|
||||
"amount",
|
||||
"high_amount",
|
||||
"principal_types",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
class PrincipalSubscriptionForm(forms.ModelForm):
|
||||
class Meta:
|
||||
|
||||
Reference in New Issue
Block a user