fix db for server

This commit is contained in:
pluja 2020-09-04 17:47:41 +02:00
parent e66729485e
commit eeacc51ec2
2 changed files with 8 additions and 6 deletions

View File

@ -9,12 +9,12 @@ followers = db.Table('followers',
)
channel_association = db.Table('channel_association',
db.Column('channel_id', db.String, db.ForeignKey('channel.id')),
db.Column('channel_id', db.String(30), db.ForeignKey('channel.id')),
db.Column('user_id', db.Integer, db.ForeignKey('user.id'))
) # Association: CHANNEL --followed by--> [USERS]
twitter_association = db.Table('twitter_association',
db.Column('account_id', db.String, db.ForeignKey('twitterAccount.id')),
db.Column('account_id', db.String(30), db.ForeignKey('twitterAccount.id')),
db.Column('user_id', db.Integer, db.ForeignKey('user.id'))
) # Association: ACCOUNT --followed by--> [USERS]

View File

@ -486,14 +486,16 @@ def allowed_file(filename):
@app.route('/register', methods=['GET', 'POST'])
def register():
count = db.session.query(User).count()
if current_user.is_authenticated:
return redirect(url_for('index'))
REGISTRATIONS = True
if count >= config['maxInstanceUsers'] or config['maxInstanceUsers'] == 0:
REGISTRATIONS = False
try:
count = db.session.query(User).count()
if count >= config['maxInstanceUsers'] or config['maxInstanceUsers'] == 0:
REGISTRATIONS = False
except:
REGISTRATIONS = True
form = RegistrationForm()
if form.validate_on_submit():
if User.query.filter_by(username=form.username.data).first():