Skip to content
This repository has been archived by the owner on Jan 4, 2021. It is now read-only.

Commit

Permalink
Changed creation script
Browse files Browse the repository at this point in the history
  • Loading branch information
yamatt committed Apr 7, 2013
1 parent 5c178e2 commit 9f950ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ This is a blog I built to run in Python using the Flask micro-web framework.

# Setup
Copy the `settings.py.defaults` file to `settings.py` and open it to set your preferences.
**OChange the `SECRET_KEY` to be anything non-guessable.**
**Change the `SECRET_KEY` to be anything non-guessable.**

The easiest way to get started is to first create a database with an administrator account. Run `create_admin.py` to setup the database like so:
The easiest way to get started is to first create a database with an administrator account. Run `create_db.py` to setup the database like so:

./create_admin.py matt
./create_db.py Administrator

Where matt is the username. It can be your own name if you prefer.
Where matt is the username for the administrative account you want to known by. It can be your own name if you prefer. You will then be asked to set up a password for this account.

Run the app do:
To run the blog do:

./main.py

Expand Down
6 changes: 5 additions & 1 deletion create_admin.py → create_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@

database = DatabaseInterface(settings.DATABASE_ENGINE, settings.DATABASE_CONNECTION_STRING)

def create_database():
database.engine.create()

def create_admin(username, password, full_name="Administrator", e_mail=""):
hashed_password = database.models.User.hash_password(password)
user = database.models.User(username, full_name, e_mail, hashed_password, AuthorisationLevels.ADMIN)
Expand All @@ -45,14 +48,15 @@ def user_exists(username):
print "You must specify a username as the first argument."
exit(1)
else:
create_database()
username = sys.argv[1]
if user_exists(username):
print "This username already exists. Another one must be chosen."
exit(1)
if len(sys.argv) > 2:
password = sys.argv[2]
else:
password = getpass("User's password: ")
password = getpass("{0}'s password: ".format(username))
password_confirm = getpass("Confirm password: ")
if password != password_confirm:
print "Passwords do not match. Please try again."
Expand Down

0 comments on commit 9f950ed

Please sign in to comment.