Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Noe Nieto
Keel - LDH Middleware
Commits
a0611c77
Commit
a0611c77
authored
Mar 04, 2020
by
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
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
wcmigration/models.py
View file @
a0611c77
...
...
@@ -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
wcmigration/views.py
View file @
a0611c77
...
...
@@ -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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment