GithubHelp home page GithubHelp logo

justdjango / dj-video-membership Goto Github PK

View Code? Open in Web Editor NEW
37.0 37.0 26.0 1.41 MB

Django Video Membership website

License: MIT License

Dockerfile 3.21% Shell 5.49% Python 56.43% CSS 2.16% JavaScript 0.03% HTML 32.25% SCSS 0.43%

dj-video-membership's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dj-video-membership's Issues

Adding Pricing auto-settlement in cmd "makesuper" for easier deployment.

Hi Matthew,

When trying to recreate the project on my own I had to go through python shell to manually create the pricing tiers. To avoid errors and waste of time I thougt it would be more efficient to add the pricing creation in the "makesuper" cmd. Here is the small correction I wrote.

class Command(BaseCommand):
    def handle(self, *args, **options):
        if not User.objects.filter(username="admin").exists():
            if settings.DEBUG:
                password = 'admin'
            else:
                password = randomStringwithDigitsAndSymbols()
                user = User.objects.create_superuser(
                    "admin", "[email protected]", password)

            if not Pricing.objects.filter(name='Free account').exists():
                free_account = Pricing.objects.create(
                    name="Free account",
                    slug="free-account",
                    stripe_price_id="price_123456",
                    price=0.00,
                    currency="eu"
                )
                free_account.save()


            free_trial_pricing = Pricing.objects.get(name='Free_account')
            subscription = Subscription.objects.create(
                user=user,
                pricing=free_trial_pricing
            )
            stripe_customer = stripe.Customer.create(
                email=user.email
            )
            stripe_subscription = stripe.Subscription.create(
                customer=stripe_customer["id"],
                items=[{'price': 'price_123456'}],  # my project needs people to have unlimited free account (no trialing)
            )
            subscription.status = stripe_subscription["status"]
            subscription.stripe_subscription_id = stripe_subscription["id"]
            subscription.save()
            user.stripe_customer_id = stripe_customer["id"]
            user.save()
        else:
            user = User.objects.get(username="admin")[...]

Feel free to use it. Thank you for your courses,
Gianni Vullo

Edit: I added and if statement before the pricing creation method to prevent databases bad interactions in case of running twice the commmand.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.