diff --git a/app/routes.py b/app/routes.py index 54bca41..227a2bc 100644 --- a/app/routes.py +++ b/app/routes.py @@ -22,13 +22,16 @@ import bleach import urllib import json import re - ########################## #### Config variables #### ########################## -NITTERINSTANCE = "https://nitter.net/" # Must be https://.../ +config = json.load(open('yotter-config.json')) +########################## +#### Config variables #### +########################## +NITTERINSTANCE = config['nitterInstance'] # Must be https://.../ YOUTUBERSS = "https://www.youtube.com/feeds/videos.xml?channel_id=" -REGISTRATIONS = True +REGISTRATIONS = config['registrations'] ########################## #### Global variables #### @@ -457,15 +460,21 @@ def allowed_file(filename): @app.route('/register', methods=['GET', 'POST']) def register(): + global REGISTRATIONS + count = db.session.query(User).count() if current_user.is_authenticated: return redirect(url_for('index')) + if count >= config['maxInstanceUsers']: + REGISTRATIONS = False + form = RegistrationForm() if form.validate_on_submit(): if User.query.filter_by(username=form.username.data).first(): flash("This username is taken! Try with another.") return redirect(request.referrer) + user = User(username=form.username.data) user.set_password(form.password.data) db.session.add(user) diff --git a/app/templates/_closed_registrations.html b/app/templates/_closed_registrations.html index b29d202..367d594 100644 --- a/app/templates/_closed_registrations.html +++ b/app/templates/_closed_registrations.html @@ -1,6 +1,6 @@
- Closed registrations image + Closed registrations image
diff --git a/yotter-config.json b/yotter-config.json new file mode 100644 index 0000000..1c0a6dd --- /dev/null +++ b/yotter-config.json @@ -0,0 +1,6 @@ +{ + "nitterInstance": "https://nitter.net/", + "registrations": true, + "maxInstanceUsers": 1, + "proxyAll": true +} \ No newline at end of file