24 lines
663 B
Python
24 lines
663 B
Python
|
import argparse
|
||
|
from uuid import uuid4
|
||
|
from hashlib import md5
|
||
|
from app import models
|
||
|
|
||
|
__author__ = 'vanzhiganov'
|
||
|
|
||
|
|
||
|
parser = argparse.ArgumentParser(description='')
|
||
|
parser.add_argument('--email', dest="email")
|
||
|
parser.add_argument('--password', dest="password")
|
||
|
|
||
|
args = parser.parse_args()
|
||
|
|
||
|
admin_id = uuid4()
|
||
|
# todo: validate admin email
|
||
|
admin_email = args.email
|
||
|
admin_password = md5(args.password).hexdigest()
|
||
|
|
||
|
if models.Admins.select().where(models.Admins.email == args.email).count() == 0:
|
||
|
models.Admins.create(id=admin_id, email=admin_email, password=admin_password, status=1)
|
||
|
else:
|
||
|
print "Admin account with email '%s' already exists." % admin_email
|