Commit a0611c77 authored by Noe Nieto's avatar Noe Nieto 💬
Browse files

Create the Librem One subscription upon upgrade; liberty/host/middleware#88

parent eeadc8bb
Pipeline #53389 failed with stages
in 1 minute and 56 seconds
......@@ -51,3 +51,16 @@ def update_wc_username(jwt_token, ldh_username, recovery_email):
return r.status_code == 200
return False
def create_wc_subscription(jwt_token, wc_userid):
"""
Returns True for success, False for failure.
"""
with requests.Session() as s:
r = s.post(
url=f'{settings.WOO_URL}/wp-json/ldh/v1/user/{wc_userid}/subscription',
headers={'Authorization': f'Bearer {jwt_token}'}
)
import pdb; pdb.set_trace()
return r.status_code == 200
return False
......@@ -5,7 +5,7 @@ from django.views.generic.edit import FormView
from purist.models import AccountType, User
from .forms import WC_UpgradeForm
from .models import update_wc_username
from .models import update_wc_username, create_wc_subscription
class WC_UpgradeView(FormView):
template_name = 'registration/registration_form.html'
......@@ -27,4 +27,5 @@ class WC_UpgradeView(FormView):
ldh_username=form.cleaned_data['l1_username'],
recovery_email=form.cleaned_data['wc_email'],
)
create_wc_subscription(form.wc_jwt_token, form.wc_user_id)
return redirect(self.success_url)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment