Commit 00d8495f authored by Birin Sanchez's avatar Birin Sanchez
Browse files

Add PLUS AccountType


Signed-off-by: Birin Sanchez's avatarBirin Sanchez <birin.sanchez@puri.sm>
parent 6d6c885a
Pipeline #53597 failed with stages
in 1 minute and 51 seconds
......@@ -39,3 +39,11 @@
ids:
- 62887
- 54393
-
name: PLUS
services:
- Chat
- Social
- Mail
ids:
- 3331
......@@ -103,3 +103,16 @@
domain: example.com
upgrades:
downgrades:
12371:
title: Librem One Plus (monthly)
short_title: Plus (monthly)
type: PLUS
period: monthly
domain: example.com
upgrades:
- 12351
- 12347
- 12348
- 12349
downgrades:
......@@ -89,7 +89,10 @@ def forced_update(user):
srv_to_enable | srv_to_reenable,
sub.next_payment_date)
user.account_type = sub.account_type
if sub.account_type == AccountType.BASIC:
if (
sub.account_type == AccountType.BASIC
or sub.account_type == AccountType.PLUS
):
user.quota = settings.STORAGE_QUOTA_BASIC
else:
user.quota = settings.STORAGE_QUOTA_OTHERS
......
......@@ -333,6 +333,8 @@ class Subscription():
account_type = AccountType.BASIC
elif 'INVITED' == sub_acc_type:
account_type = AccountType.INVITED
elif 'PLUS' == sub_acc_type:
account_type = AccountType.PLUS
sub_period = sub_bundle.get('period', None)
try:
......
......@@ -30,6 +30,7 @@ class AccountType(ChoicesEnum):
INVITED = 3, 'Invited'
GROUP = 4, 'Family pack'
PAYGS = 5, 'Pay As You Go Storage'
PLUS = 6, 'Plus'
@classmethod
def from_str(cls, value):
......
......@@ -3,10 +3,13 @@ from django.urls import reverse_lazy
from django.views.generic.edit import FormView
from purist.models import AccountType, User
from limitmonitor.subscription import SubscriptionManager, SubscriptionStatus
from limitmonitor.common import forced_update
from .forms import WC_UpgradeForm
from .models import update_wc_username, create_wc_subscription
class WC_UpgradeView(FormView):
template_name = 'registration/registration_form.html'
form_class = WC_UpgradeForm
......@@ -19,13 +22,23 @@ class WC_UpgradeView(FormView):
password=form.cleaned_data['wc_password'],
wcid=form.wc_user_id
)
user.account_type = AccountType.BASIC
user.account_type = AccountType.UNDEFINED
user.save()
# Creating Subscription through middleware
sub = SubscriptionManager.create_subscription(
user, account_type=AccountType.PLUS, paid=True,
status=SubscriptionStatus.ACTIVE
)
if sub:
forced_update(user)
update_wc_username(
jwt_token=form.wc_jwt_token,
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)
# Creating subscription through WC
# create_wc_subscription(form.wc_jwt_token, form.wc_user_id)
# forced_update(user)
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