Skip to content

Commit

Permalink
Prefix FastSpring subscription_id with fs-
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Jul 17, 2024
1 parent 2afb427 commit 960fbd3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (c) 2024 Alexander Todorov <[email protected]>
#
# Licensed under GNU Affero General Public License v3 or later (AGPLv3+)
# https://www.gnu.org/licenses/agpl-3.0.html

from django.db import migrations


def forwards(apps, schema_editor): # pylint: disable=unused-argument
purchase_model = apps.get_model("tcms_github_marketplace", "Purchase")
for purchase in purchase_model.objects.filter(vendor="fastspring"):
try:
purchase.subscription = f"fs-{purchase.subscription}"
purchase.save()
except: # noqa, pylint: disable=bare-except
pass


def backwards(apps, schema_editor): # pylint: disable=unused-argument
purchase_model = apps.get_model("tcms_github_marketplace", "Purchase")
for purchase in purchase_model.objects.filter(vendor="fastspring"):
try:
purchase.subscription = purchase.subscription.lstrip("fs-")
purchase.save()
except: # noqa, pylint: disable=bare-except
pass


class Migration(migrations.Migration):
dependencies = [
("tcms_github_marketplace", "0009_github_subscription_id"),
]

operations = [
migrations.RunPython(forwards, backwards),
]
2 changes: 1 addition & 1 deletion tcms_github_marketplace/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def purchase_subscription(self, event):
if isinstance(subscription, dict):
subscription = subscription["id"]

return subscription
return f"fs-{subscription}"

def request_verify_signature(self, request):
return utils.verify_hmac(request)
Expand Down

0 comments on commit 960fbd3

Please sign in to comment.