开发者

Building a user subscription application

开发者 https://www.devze.com 2022-12-27 08:41 出处:网络
I\'m trying to come up with the best way to handle user subscription and management for our magazine website. What I want to happen is a user purchases a subscription and they are granted online acces

I'm trying to come up with the best way to handle user subscription and management for our magazine website. What I want to happen is a user purchases a subscription and they are granted online access of a certain membership role for a certain amount of time depending on how many years they subscribed for. I would also like the system to be able to send out emails when a subscription is almost up.

I've seen some third party projects to help accomplish this but I'd prefer to write this from scratch as I want total control over how it works.

Any suggestions would be helpful.

The main thing I can't figure out is how to have an expiring membership. You must keep track of when the user signed up and how long until they should开发者_运维百科 expire.


You just need to keep track of their expiration date, not their join date. If the expiration date is in the future, they're active. Otherwise, they aren't. From that, you could implement a custom decorator similar to @login_required to check for this stuff.

http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/decorators.py#L33

As for emails, you should just create a management command which will look for any user whose expiration date is 3 days from now, and then take that list of users and email them. This management command should be run on a cron job.

0

精彩评论

暂无评论...
验证码 换一张
取 消