Skip to content

Instantly share code, notes, and snippets.

@Porter97
Created January 22, 2020 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Porter97/f28ce03cae10e206f6df5261ed65bdea to your computer and use it in GitHub Desktop.
Save Porter97/f28ce03cae10e206f6df5261ed65bdea to your computer and use it in GitHub Desktop.
Role.insert_roles()
admin_role = Role.query.filter_by(name=’Administrator’).first()
default_role = Role.query.filter_by(default=True).first()
for u in User.query.all():
if u.role is None:
if u.email == app.config[‘OFFBRAND_ADMIN’]:
u.role = admin_role
else:
u.role = default_role
db.session.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment