Browse Source

Rename save_user_prompt to prompt_save_user

for consistency’s sake
Peter Justin 8 years ago
parent
commit
2b1672730e
2 changed files with 29 additions and 29 deletions
  1. 2 2
      flaskbb/cli/main.py
  2. 27 27
      flaskbb/cli/utils.py

+ 2 - 2
flaskbb/cli/main.py

@@ -27,7 +27,7 @@ from flask_migrate import upgrade as upgrade_database
 from flaskbb import create_app
 from flaskbb import create_app
 from flaskbb._compat import iteritems
 from flaskbb._compat import iteritems
 from flaskbb.extensions import db, whooshee, celery
 from flaskbb.extensions import db, whooshee, celery
-from flaskbb.cli.utils import (save_user_prompt, prompt_config_path,
+from flaskbb.cli.utils import (prompt_save_user, prompt_config_path,
                                write_config, get_version, FlaskBBCLIError,
                                write_config, get_version, FlaskBBCLIError,
                                EmailType)
                                EmailType)
 from flaskbb.utils.populate import (create_test_data, create_welcome_forum,
 from flaskbb.utils.populate import (create_test_data, create_welcome_forum,
@@ -110,7 +110,7 @@ def install(welcome, force, username, email, password, group):
     create_default_settings()
     create_default_settings()
 
 
     click.secho("[+] Creating admin user...", fg="cyan")
     click.secho("[+] Creating admin user...", fg="cyan")
-    save_user_prompt(username, email, password, group)
+    prompt_save_user(username, email, password, group)
 
 
     if welcome:
     if welcome:
         click.secho("[+] Creating welcome forum...", fg="cyan")
         click.secho("[+] Creating welcome forum...", fg="cyan")

+ 27 - 27
flaskbb/cli/utils.py

@@ -69,33 +69,6 @@ class EmailType(click.ParamType):
         return "email"
         return "email"
 
 
 
 
-def save_user_prompt(username, email, password, group, only_update=False):
-    if not username:
-        username = click.prompt(
-            click.style("Username", fg="magenta"), type=str,
-            default=os.environ.get("USER", "")
-        )
-    if not email:
-        email = click.prompt(
-            click.style("Email address", fg="magenta"), type=EmailType()
-        )
-    if not password:
-        password = click.prompt(
-            click.style("Password", fg="magenta"), hide_input=True,
-            confirmation_prompt=True
-        )
-    if not group:
-        group = click.prompt(
-            click.style("Group", fg="magenta"),
-            type=click.Choice(["admin", "super_mod", "mod", "member"]),
-            default="admin"
-        )
-
-    if only_update:
-        return update_user(username, password, email, group)
-    return create_user(username, password, email, group)
-
-
 def validate_plugin(plugin):
 def validate_plugin(plugin):
     """Checks if a plugin is installed.
     """Checks if a plugin is installed.
     TODO: Figure out how to use this in a callback. Doesn't work because
     TODO: Figure out how to use this in a callback. Doesn't work because
@@ -138,6 +111,33 @@ def get_version(ctx, param, value):
     ctx.exit()
     ctx.exit()
 
 
 
 
+def prompt_save_user(username, email, password, group, only_update=False):
+    if not username:
+        username = click.prompt(
+            click.style("Username", fg="magenta"), type=str,
+            default=os.environ.get("USER", "")
+        )
+    if not email:
+        email = click.prompt(
+            click.style("Email address", fg="magenta"), type=EmailType()
+        )
+    if not password:
+        password = click.prompt(
+            click.style("Password", fg="magenta"), hide_input=True,
+            confirmation_prompt=True
+        )
+    if not group:
+        group = click.prompt(
+            click.style("Group", fg="magenta"),
+            type=click.Choice(["admin", "super_mod", "mod", "member"]),
+            default="admin"
+        )
+
+    if only_update:
+        return update_user(username, password, email, group)
+    return create_user(username, password, email, group)
+
+
 def prompt_config_path(config_path):
 def prompt_config_path(config_path):
     """Asks for a config path. If the path exists it will ask the user
     """Asks for a config path. If the path exists it will ask the user
     for a new path until a he enters a path that doesn't exist.
     for a new path until a he enters a path that doesn't exist.