예제 #1
0
def set_default_user_plan(sender, instance, created, **kwargs):
    """
    Creates default plan for the new user but also extending an account for default grace period.
    """

    if created:
        UserPlan.create_for_user(instance)
예제 #2
0
def set_default_user_plan(sender, instance, created, **kwargs):
    """
    Creates default plan for the new user but also extending an account for default grace period.
    """

    if created:
        UserPlan.create_for_user(instance)
예제 #3
0
 def test_create_userplans(self):
     """ Test that create_for_users_without_plan method """
     u = User.objects.get(username='******')
     UserPlan.objects.all().delete()
     with self.assertRaises(UserPlan.DoesNotExist):
         u.userplan
     u.refresh_from_db()
     created_plans = UserPlan.create_for_users_without_plan()
     self.assertEqual(created_plans.count(), 2)
     default_plan = Plan.objects.get(pk=1)
     self.assertEqual(u.userplan.plan, default_plan)
예제 #4
0
 def test_create_userplans(self):
     """ Test that create_for_users_without_plan method """
     u = User.objects.get(username='******')
     UserPlan.objects.all().delete()
     with self.assertRaises(UserPlan.DoesNotExist):
         u.userplan
     u.refresh_from_db()
     created_plans = UserPlan.create_for_users_without_plan()
     self.assertEqual(created_plans.count(), 2)
     default_plan = Plan.objects.get(pk=1)
     self.assertEqual(u.userplan.plan, default_plan)
예제 #5
0
 def custom_signup(self, request, user):
     plan_pricing = self.validated_data['plan_pricing']
     UserPlan.objects.filter(user=user).delete()
     userplan = UserPlan(user=user,
                         plan=plan_pricing.plan,
                         active=False)
     if self._is_free(plan_pricing):
         userplan.active = True
     else:
         self._create_premium_subscription(user, plan_pricing)
     # save user plan
     userplan.full_clean()
     userplan.save()
예제 #6
0
def create_userplans(apps, schema_editor):
    from plans.models import UserPlan
    UserPlan.create_for_users_without_plan()
예제 #7
0
 def handle(self, *args, **options):  # pragma: no cover
     userplans = UserPlan.create_for_users_without_plan()
     self.stdout.write("%s user plans was created" % userplans.count())
def create_userplans(apps, schema_editor):
    from plans.models import UserPlan
    UserPlan.create_for_users_without_plan()