Skip to content

Commit 631137b

Browse files
committed
Rename form fields.
1 parent 3d6519e commit 631137b

File tree

7 files changed

+43
-43
lines changed

7 files changed

+43
-43
lines changed

flask_session_tutorial/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def create_app():
2424
from . import auth
2525
from .assets import compile_static_assets
2626

27-
app.register_blueprint(routes.main)
28-
app.register_blueprint(auth.auth)
27+
app.register_blueprint(routes.main_blueprint)
28+
app.register_blueprint(auth.auth_blueprint)
2929

3030
# Create static asset bundles
3131
compile_static_assets(app)

flask_session_tutorial/assets.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def compile_javascript(app: Flask):
4444
Environment.auto_build = True
4545
Environment.debug = False
4646
# JavaScript Bundle
47-
js_bundle = Bundle("src/js/main.js", filters="jsmin", output="dist/js/main.min.js")
47+
js_bundle = Bundle(
48+
"src/js/main.js",
49+
filters="jsmin", output="dist/js/main.min.js")
4850
# Register assets
4951
assets.register("js_all", js_bundle)
5052
# Build assets in development mode

flask_session_tutorial/auth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
from flask_session_tutorial.models import User, db
1010

1111
# Blueprint Configuration
12-
auth = Blueprint(
12+
auth_blueprint = Blueprint(
1313
"auth",
1414
__name__,
1515
template_folder="templates",
1616
static_folder="static"
1717
)
1818

1919

20-
@auth.route("/signup", methods=["GET", "POST"])
20+
@auth_blueprint.route("/signup", methods=["GET", "POST"])
2121
def signup() -> Response:
2222
"""
2323
Sign-up form to create new user accounts.
@@ -46,7 +46,7 @@ def signup() -> Response:
4646
)
4747

4848

49-
@auth.route("/login", methods=["GET", "POST"])
49+
@auth_blueprint.route("/login", methods=["GET", "POST"])
5050
def login() -> Response:
5151
"""
5252
Log-in page for registered users.

flask_session_tutorial/forms.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
class SignupForm(FlaskForm):
88
"""User Sign-up Form."""
9-
109
user_name = StringField("Name", validators=[DataRequired()])
1110
user_email = StringField(
1211
"Email",
@@ -36,7 +35,6 @@ class SignupForm(FlaskForm):
3635

3736
class LoginForm(FlaskForm):
3837
"""User Log-in Form for existing users."""
39-
40-
email = StringField("Email", validators=[DataRequired(), Email(message="Enter a valid email.")])
41-
password = PasswordField("Password", validators=[DataRequired()])
42-
submit = SubmitField("Log In")
38+
user_email = StringField("Email", validators=[DataRequired(), Email(message="Enter a valid email.")])
39+
user_password = PasswordField("Password", validators=[DataRequired()])
40+
submit_button = SubmitField("Log In")

flask_session_tutorial/routes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
from flask_login import current_user, login_required, logout_user
44

55
# Blueprint Configuration
6-
main = Blueprint(
6+
main_blueprint = Blueprint(
77
"main",
88
__name__,
99
template_folder="templates",
1010
static_folder="static"
1111
)
1212

1313

14-
@main.route("/", methods=["GET"])
14+
@main_blueprint.route("/", methods=["GET"])
1515
@login_required
1616
def dashboard() -> Response:
1717
"""
@@ -29,7 +29,7 @@ def dashboard() -> Response:
2929
)
3030

3131

32-
@main.route("/session", methods=["GET"])
32+
@main_blueprint.route("/session", methods=["GET"])
3333
@login_required
3434
def session_view() -> Response:
3535
"""
@@ -45,7 +45,7 @@ def session_view() -> Response:
4545
)
4646

4747

48-
@main.route("/logout")
48+
@main_blueprint.route("/logout")
4949
@login_required
5050
def logout() -> Response:
5151
"""

flask_session_tutorial/templates/login.jinja2

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,27 @@
1818
<form method="POST" action="/login">
1919
{{ form.csrf_token }}
2020
<fieldset class="email">
21-
{{ form.email.label }}
22-
{{ form.email(placeholder='[email protected]') }}
23-
{% if form.email.errors %}
21+
{{ form.user_email.label }}
22+
{{ form.user_email(placeholder='[email protected]') }}
23+
{% if form.user_email.errors %}
2424
<ul class="errors">
25-
{% for error in form.email.errors %}
25+
{% for error in form.user_email.errors %}
2626
<li>{{ error }}</li>{% endfor %}
2727
</ul>
2828
{% endif %}
2929
</fieldset>
3030
<fieldset class="password">
31-
{{ form.password.label }}
32-
{{ form.password }}
33-
{% if form.email.errors %}
31+
{{ form.user_password.label }}
32+
{{ form.user_password }}
33+
{% if form.user_password.errors %}
3434
<ul class="errors">
35-
{% for error in form.password.errors %}
35+
{% for error in form.user_password.errors %}
3636
<li>{{ error }}</li>{% endfor %}
3737
</ul>
3838
{% endif %}
3939
</fieldset>
4040
<div class="submit-button">
41-
{{ form.submit }}
41+
{{ form.submit_button }}
4242
</div>
4343
<div class="login-signup">
4444
<span>Don't have an account? <a href="{{ url_for('auth.signup') }}">Sign up.</a></span>

flask_session_tutorial/templates/signup.jinja2

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,51 +17,51 @@
1717
<form method="POST" action="/signup">
1818
{{ form.csrf_token }}
1919
<fieldset class="name">
20-
{{ form.name.label }}
21-
{{ form.name(placeholder='John Smith') }}
22-
{% if form.name.errors %}
20+
{{ form.user_name.label }}
21+
{{ form.user_name(placeholder='John Smith') }}
22+
{% if form.user_name.errors %}
2323
<ul class="errors">
24-
{% for error in form.email.errors %}
24+
{% for error in form.user_email.errors %}
2525
<li>{{ error }}</li>{% endfor %}
2626
</ul>
2727
{% endif %}
2828
</fieldset>
2929
<fieldset class="email">
30-
{{ form.email.label }}
31-
{{ form.email(placeholder='[email protected]') }}
32-
{% if form.email.errors %}
30+
{{ form.user_email.label }}
31+
{{ form.user_email(placeholder='[email protected]') }}
32+
{% if form.user_email.errors %}
3333
<ul class="errors">
34-
{% for error in form.email.errors %}
34+
{% for error in form.user_email.errors %}
3535
<li>{{ error }}</li>{% endfor %}
3636
</ul>
3737
{% endif %}
3838
</fieldset>
3939
<fieldset class="password">
40-
{{ form.password.label }}
41-
{{ form.password }}
42-
{% if form.password.errors %}
40+
{{ form.user_password.label }}
41+
{{ form.user_password }}
42+
{% if form.user_password.errors %}
4343
<ul class="errors">
44-
{% for error in form.password.errors %}
44+
{% for error in form.user_password.errors %}
4545
<li>{{ error }}</li>{% endfor %}
4646
</ul>
4747
{% endif %}
4848
</fieldset>
4949
<fieldset class="confirm">
50-
{{ form.confirm.label }}
51-
{{ form.confirm }}
52-
{% if form.confirm.errors %}
50+
{{ form.user_password_confirm.label }}
51+
{{ form.user_password_confirm }}
52+
{% if form.user_password_confirm.errors %}
5353
<ul class="errors">
54-
{% for error in form.confirm.errors %}
54+
{% for error in form.user_password_confirm.errors %}
5555
<li>{{ error }}</li>{% endfor %}
5656
</ul>
5757
{% endif %}
5858
</fieldset>
5959
<fieldset class="website">
60-
{{ form.website.label }}
61-
{{ form.website(placeholder='http://example.com') }}
60+
{{ form.user_metadata_website.label }}
61+
{{ form.user_metadata_website(placeholder='http://example.com') }}
6262
</fieldset>
6363
<div class="submit-button">
64-
{{ form.submit }}
64+
{{ form.submit_button }}
6565
</div>
6666
</form>
6767
<div class="login-signup">

0 commit comments

Comments
 (0)