2

I am trying to implement the concept of "Plans" (free, pro, enterprise, etc.) when a user signs up for my site.

I am beginning Python & Django. I've gotten django-userena installed and working. Now, I am trying to extend the behavior to allow a user to select a "Plan" when signing up for the site.

I believe the plan would be stored in a subclass of UserenaBaseProfile, but not sure... maybe plan choice should not be part of the profile.

What is the best way to implement the concept of "plans" in a Django app using Userena (or not using Userena!).

DBD
  • 23,075
  • 12
  • 60
  • 84
Cliff Helsel
  • 920
  • 1
  • 12
  • 26

2 Answers2

2

You can create a Plan model which holds all the plan details. After that create a UserPlan Model with the following fields.

user = models.OneToOneField(UserenaBaseProfile)
plan = models.ForeignKey(Plan)
// other fields like validity and audit related fields

It is easier to separate the user's plans details from the core models.

Siva Arunachalam
  • 7,582
  • 15
  • 79
  • 132
0

I would make the plan levels into permissions.

If they need to be assigned to a particular object, you can use django-guardian to add them to the class for that object:

class Whatever(ExtendedGuardedModel, BaseModel):

    name = models.CharField(max_length=200)

    class Meta(BaseModel.Meta):
        permissions = (
            ("free", "Free level of access"),
            ("pro", "Pro level of access"),
            ("enterprise", "Enterprise level of access"),
        )

Then when you need to check the plan level of an account, you just use the typical way of checking permissions, except look for "free", "pro" etc.

Foo Party
  • 596
  • 1
  • 4
  • 13