Skip to content

Commit

Permalink
fix: migrations, django admin
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstankiewicz committed Oct 31, 2024
1 parent acb9a7f commit ede4645
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 10 deletions.
9 changes: 4 additions & 5 deletions license_manager/apps/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def get_subscription_for_auto_applied_licenses(self, obj):
subscription_plan = obj.auto_applicable_subscription
return subscription_plan.uuid if subscription_plan else None

def has_custom_license_expiration_messaging_v2(self, obj):
def get_has_custom_license_expiration_messaging_v2(self, obj):
custom_subscription_expiration_messaging = obj.custom_subscription_expiration_messaging
if custom_subscription_expiration_messaging:
return custom_subscription_expiration_messaging.has_custom_license_expiration_messaging
Expand All @@ -383,20 +383,19 @@ def get_modal_header_text_v2(self, obj):
return custom_subscription_expiration_messaging.modal_header_text
return None


def expired_subscription_modal_messaging_v2(self, obj):
def get_expired_subscription_modal_messaging_v2(self, obj):
custom_subscription_expiration_messaging = obj.custom_subscription_expiration_messaging
if custom_subscription_expiration_messaging:
return custom_subscription_expiration_messaging.expired_subscription_modal_messaging
return None

def button_label_in_modal_v2(self, obj):
def get_button_label_in_modal_v2(self, obj):
custom_subscription_expiration_messaging = obj.custom_subscription_expiration_messaging
if custom_subscription_expiration_messaging:
return custom_subscription_expiration_messaging.button_label_in_modal
return None

def url_for_button_in_modal_v2(self, obj):
def get_url_for_button_in_modal_v2(self, obj):
custom_subscription_expiration_messaging = obj.custom_subscription_expiration_messaging
if custom_subscription_expiration_messaging:
return custom_subscription_expiration_messaging.url_for_button_in_modal
Expand Down
13 changes: 8 additions & 5 deletions license_manager/apps/subscriptions/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
)
from license_manager.apps.subscriptions.models import (
CustomerAgreement,
CustomSubscriptionExpirationMessaging,
License,
LicenseEvent,
LicenseTransferJob,
Expand Down Expand Up @@ -402,6 +403,13 @@ def save_model(self, request, obj, form, change):
obj.provision_licenses()


@admin.register(CustomSubscriptionExpirationMessaging)
class CustomSubscriptionExpirationMessagingAdmin(DjangoQLSearchMixin, admin.ModelAdmin):
list_display = (
'customer_agreement',
'has_custom_license_expiration_messaging',
)

@admin.register(CustomerAgreement)
class CustomerAgreementAdmin(admin.ModelAdmin):
form = CustomerAgreementAdminForm
Expand All @@ -418,11 +426,6 @@ class CustomerAgreementAdmin(admin.ModelAdmin):
'license_duration_before_purge',
'disable_onboarding_notifications',
'enable_auto_applied_subscriptions_with_universal_link',
'has_custom_license_expiration_messaging',
'modal_header_text',
'expired_subscription_modal_messaging',
'button_label_in_modal',
'url_for_button_in_modal',
)
custom_fields = ('subscription_for_auto_applied_licenses',)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Generated by Django 4.2.16 on 2024-10-31 13:23

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import simple_history.models


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('subscriptions', '0073_remove_customeragreement_hyper_link_text_for_expired_modal_and_more'),
]

operations = [
migrations.CreateModel(
name='HistoricalCustomSubscriptionExpirationMessaging',
fields=[
('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
('has_custom_license_expiration_messaging', models.BooleanField(default=False, help_text='Indicates if the customer has a unique license expiration experience, instead of the standard one.')),
('modal_header_text', models.CharField(blank=True, help_text='The bold text that will appear as the header in the expiration modal.', max_length=512, null=True)),
('expired_subscription_modal_messaging', models.TextField(blank=True, help_text='The content of a modal that will appear to learners upon subscription expiration. This text can be used for custom guidance per customer.', null=True)),
('button_label_in_modal', models.CharField(blank=True, help_text='The text that will appear as on the button in the expiration modal', max_length=255, null=True)),
('url_for_button_in_modal', models.CharField(blank=True, help_text='The URL that should underly the sole button in the expiration modal', max_length=512, null=True)),
('history_id', models.AutoField(primary_key=True, serialize=False)),
('history_date', models.DateTimeField()),
('history_change_reason', models.CharField(max_length=100, null=True)),
('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
('customer_agreement', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='subscriptions.customeragreement')),
('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'historical custom subscription expiration messaging',
'verbose_name_plural': 'historical custom subscription expiration messagings',
'ordering': ('-history_date', '-history_id'),
'get_latest_by': ('history_date', 'history_id'),
},
bases=(simple_history.models.HistoricalChanges, models.Model),
),
migrations.CreateModel(
name='CustomSubscriptionExpirationMessaging',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('has_custom_license_expiration_messaging', models.BooleanField(default=False, help_text='Indicates if the customer has a unique license expiration experience, instead of the standard one.')),
('modal_header_text', models.CharField(blank=True, help_text='The bold text that will appear as the header in the expiration modal.', max_length=512, null=True)),
('expired_subscription_modal_messaging', models.TextField(blank=True, help_text='The content of a modal that will appear to learners upon subscription expiration. This text can be used for custom guidance per customer.', null=True)),
('button_label_in_modal', models.CharField(blank=True, help_text='The text that will appear as on the button in the expiration modal', max_length=255, null=True)),
('url_for_button_in_modal', models.CharField(blank=True, help_text='The URL that should underly the sole button in the expiration modal', max_length=512, null=True)),
('customer_agreement', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='custom_subscription_expiration_messaging', to='subscriptions.customeragreement')),
],
),
]

0 comments on commit ede4645

Please sign in to comment.