Repository navigation
Add payment plan switching #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rechner
wants to merge
6
commits into
dev
Choose a base branch
from
rechner/add-switch-plan
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a64fda1
feat(billing): Add payment plan switching
rechner bff8361
Add SE translation
rechner 1138c13
refactor(frontend): Migrate to ES modules, fix compiler warnings
rechner ecd3ca2
feat(billing): Add payment plan switch tracking
rechner 91aeaaf
More test coverage for plan switching
rechner e1f731f
Merge branch 'dev' of github.com:PawprintPrototyping/MemberMatters in…
rechner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| from django.contrib import admin | ||
|
|
||
| from .models import PaymentPlanSwitchOperation | ||
|
|
||
|
|
||
| @admin.register(PaymentPlanSwitchOperation) | ||
| class PaymentPlanSwitchOperationAdmin(admin.ModelAdmin): | ||
| list_display = ( | ||
| "profile", | ||
| "current_plan", | ||
| "target_plan", | ||
| "status", | ||
| "attempt_count", | ||
| "updated_at", | ||
| ) | ||
| list_filter = ("status",) | ||
| search_fields = ( | ||
| "profile__user__email", | ||
| "stripe_subscription_id", | ||
| "idempotency_key", | ||
| ) | ||
| readonly_fields = ( | ||
| "profile", | ||
| "current_plan", | ||
| "target_plan", | ||
| "stripe_subscription_id", | ||
| "idempotency_key", | ||
| "status", | ||
| "attempt_count", | ||
| "last_error", | ||
| "created_at", | ||
| "updated_at", | ||
| ) | ||
|
|
||
| @admin.action(description="Discard selected failed plan switches") | ||
| def discard_failed_operations(self, request, queryset): | ||
| queryset.filter(status=PaymentPlanSwitchOperation.STATUS_FAILED).delete() | ||
|
|
||
| actions = ("discard_failed_operations",) | ||
|
|
||
| def has_delete_permission(self, request, obj=None): | ||
| return obj is None or obj.status == PaymentPlanSwitchOperation.STATUS_FAILED |
74 changes: 74 additions & 0 deletions
74
memberportal/api_billing/migrations/0002_paymentplanswitchoperation.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("api_admin_tools", "0013_paymentplan_description"), | ||
| ("api_billing", "0001_initial"), | ||
| ("constance", "0003_drop_pickle"), | ||
| ("profile", "0033_alter_inductionproviderstate_provider"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name="PaymentPlanSwitchOperation", | ||
| fields=[ | ||
| ( | ||
| "id", | ||
| models.AutoField( | ||
| auto_created=True, | ||
| primary_key=True, | ||
| serialize=False, | ||
| verbose_name="ID", | ||
| ), | ||
| ), | ||
| ("stripe_subscription_id", models.CharField(max_length=100)), | ||
| ("idempotency_key", models.CharField(max_length=255, unique=True)), | ||
| ( | ||
| "status", | ||
| models.CharField( | ||
| choices=[("pending", "Pending")], | ||
| default="pending", | ||
| max_length=16, | ||
| ), | ||
| ), | ||
| ("attempt_count", models.PositiveIntegerField(default=0)), | ||
| ("last_error", models.TextField(blank=True, default="")), | ||
| ("created_at", models.DateTimeField(auto_now_add=True)), | ||
| ("updated_at", models.DateTimeField(auto_now=True)), | ||
| ( | ||
| "current_plan", | ||
| models.ForeignKey( | ||
| on_delete=django.db.models.deletion.PROTECT, | ||
| related_name="switch_operations_from", | ||
| to="api_admin_tools.paymentplan", | ||
| ), | ||
| ), | ||
| ( | ||
| "profile", | ||
| models.OneToOneField( | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="payment_plan_switch_operation", | ||
| to="profile.profile", | ||
| ), | ||
| ), | ||
| ( | ||
| "target_plan", | ||
| models.ForeignKey( | ||
| on_delete=django.db.models.deletion.PROTECT, | ||
| related_name="switch_operations_to", | ||
| to="api_admin_tools.paymentplan", | ||
| ), | ||
| ), | ||
| ], | ||
| options={ | ||
| "indexes": [ | ||
| models.Index( | ||
| fields=["status", "updated_at"], | ||
| name="api_billing_status_55ab81_idx", | ||
| ) | ||
| ], | ||
| }, | ||
| ), | ||
| ] |
19 changes: 19 additions & 0 deletions
19
memberportal/api_billing/migrations/0003_paymentplanswitchoperation_failed.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("api_billing", "0002_paymentplanswitchoperation"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name="paymentplanswitchoperation", | ||
| name="status", | ||
| field=models.CharField( | ||
| choices=[("pending", "Pending"), ("failed", "Failed")], | ||
| default="pending", | ||
| max_length=16, | ||
| ), | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems strange and I have no idea what it is doing. Probably some django thing I am not familiar with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything in the
migrationsfolder is a Django ORM database migration. After you change the ORM model, you run./manage.py makemigrationand the corresponding database changes are automatically generated.