Set up stripe API key on application start

master
Drew DeVault 9 years ago
parent 3bcb966efc
commit 84d34e291a
  1. 5
      fosspay/app.py
  2. 1
      fosspay/objects.py
  3. 7
      templates/admin.html

@ -5,6 +5,7 @@ from jinja2 import FileSystemLoader, ChoiceLoader
import sys import sys
import os import os
import locale import locale
import stripe
from fosspay.config import _cfg, _cfgi from fosspay.config import _cfg, _cfgi
from fosspay.database import db, init_db from fosspay.database import db, init_db
@ -12,8 +13,6 @@ from fosspay.objects import User
from fosspay.common import * from fosspay.common import *
from fosspay.network import * from fosspay.network import *
import fosspay.stripe
from fosspay.blueprints.html import html from fosspay.blueprints.html import html
app = Flask(__name__) app = Flask(__name__)
@ -28,6 +27,8 @@ app.jinja_loader = ChoiceLoader([
FileSystemLoader("templates"), FileSystemLoader("templates"),
]) ])
stripe.api_key = _cfg("stripe-secret")
@login_manager.user_loader @login_manager.user_loader
def load_user(email): def load_user(email):
return User.query.filter(User.email == email).first() return User.query.filter(User.email == email).first()

@ -24,6 +24,7 @@ class User(Base):
created = Column(DateTime) created = Column(DateTime)
password_reset = Column(String(128)) password_reset = Column(String(128))
password_reset_expires = Column(DateTime) password_reset_expires = Column(DateTime)
stripe_customer = Column(String(256))
def set_password(self, password): def set_password(self, password):
self.password = bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt()).decode("utf-8") self.password = bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt()).decode("utf-8")

@ -12,6 +12,9 @@
Yeah, it's not pretty. Next steps: Yeah, it's not pretty. Next steps:
</p> </p>
<ol> <ol>
<li>
Set up a cron job to handle monthly donations. <a href="https://github.com/SirCmpwn/fosspay/wiki/Recurring-donations-cronjob">Relevant documentation</a>.
</li>
<li> <li>
Add some projects. Donors can tell you which project they want to support Add some projects. Donors can tell you which project they want to support
when they donate. when they donate.
@ -22,10 +25,10 @@
<code>overrides</code> directory and change it to suit your needs. <code>overrides</code> directory and change it to suit your needs.
</li> </li>
<li> <li>
<a href="https://drewdevault.com/donate?project=fosspay">Donate to fosspay upstream?</a> <a href="https://drewdevault.com/donate?project=fosspay">Donate to fosspay upstream</a>?
</li> </li>
<li> <li>
<a href="https://github.com/SirCmpwn/fosspay">Contribute code to fosspay upstream?</a> <a href="https://github.com/SirCmpwn/fosspay">Contribute code to fosspay upstream</a>?
</li> </li>
</ol> </ol>
</div> </div>

Loading…
Cancel
Save