Skip to content

Commit

Permalink
convert single quotes to double quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
emregeldegul committed Mar 14, 2022
1 parent 5ad847f commit 0c3ac7a
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 80 deletions.
41 changes: 20 additions & 21 deletions app/forms/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,49 @@

class LoginForm(FlaskForm):
email = StringField(
'E-Mail',
"E-Mail",
validators=[DataRequired(), Email()],
render_kw={'placeholder': 'E-Mail', 'autofocus': True},
render_kw={"placeholder": "E-Mail", "autofocus": True},
)
password = PasswordField(
'Password',
"Password",
validators=[DataRequired()],
render_kw={'placeholder': 'Password'}
render_kw={"placeholder": "Password"}
)
remember_me = BooleanField('Remember Me')
submit = SubmitField('Login')
remember_me = BooleanField("Remember Me")
submit = SubmitField("Login")


class RegisterForm(FlaskForm):
first_name = StringField(
'First Name',
"First Name",
validators=[DataRequired(), Length(max=30)],
render_kw={'placeholder': 'First Name', 'autofocus': True}
render_kw={"placeholder": "First Name", "autofocus": True}
)
last_name = StringField(
'Last Name',
"Last Name",
validators=[DataRequired(), Length(max=30)],
render_kw={'placeholder': 'Last Name'}
render_kw={"placeholder": "Last Name"}
)
email = StringField(
'E-Mail',
"E-Mail",
validators=[DataRequired(), Email(), Length(max=70)],
render_kw={'placeholder': 'E-Mail'}
render_kw={"placeholder": "E-Mail"}
)
password = PasswordField(
'Password',
"Password",
validators=[DataRequired(), Length(min=6, max=20)],
render_kw={'placeholder': 'Password'}
render_kw={"placeholder": "Password"}
)
password_confirm = PasswordField(
'Password Confirm',
validators=[DataRequired(), EqualTo('password')],
render_kw={'placeholder': 'Password Confirm'}
"Password Confirm",
validators=[DataRequired(), EqualTo("password")],
render_kw={"placeholder": "Password Confirm"}
)
submit = SubmitField('Register')
submit = SubmitField("Register")

@staticmethod
def validate_email(self, email):
def validate_email(self, email): # noqa
user = User.query.filter_by(email=email.data).first()

if user:
raise ValidationError('This e-mail address cannot be used.')
raise ValidationError("This e-mail address cannot be used.")
35 changes: 17 additions & 18 deletions app/forms/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,46 @@

class EditProfileForm(FlaskForm):
email = StringField(
'E-Mail',
"E-Mail",
validators=[DataRequired(), Email(), Length(max=70)],
render_kw={'placeholder': 'E-Mail'}
render_kw={"placeholder": "E-Mail"}
)
name = StringField(
'Name',
"Name",
validators=[DataRequired(), Length(max=30)],
render_kw={'placeholder': 'Name', 'autofocus': True}
render_kw={"placeholder": "Name", "autofocus": True}
)
note = TextAreaField('Note')
submit = SubmitField('Save')
note = TextAreaField("Note")
submit = SubmitField("Save")

@staticmethod
def validate_email(self, email):
user = User.query.filter_by(email=email.data).first()

if user and user != current_user:
raise ValidationError('This e-mail address cannot be used')
raise ValidationError("This e-mail address cannot be used")


class ChangePasswordForm(FlaskForm):
old_password = PasswordField(
'Old Password',
"Old Password",
validators=[DataRequired()],
render_kw={'placeholder': 'Old Password'}
render_kw={"placeholder": "Old Password"}
)
new_password = PasswordField(
'New Password',
"New Password",
validators=[DataRequired(), Length(min=6, max=20)],
render_kw={'placeholder': 'New Password'}
render_kw={"placeholder": "New Password"}
)
password_confirm = PasswordField(
'New Password Confirm',
validators=[DataRequired(), EqualTo('new_password')],
render_kw={'placeholder': 'New Password Confirm'}
"New Password Confirm",
validators=[DataRequired(), EqualTo("new_password")],
render_kw={"placeholder": "New Password Confirm"}
)
submit = SubmitField('Change Password')
submit = SubmitField("Change Password")

@staticmethod
def validate_old_password(self, old_password):
def validate_old_password(self, old_password): # noqa
user = User.query.filter_by(email=current_user.email).first()

if not user.check_password(old_password.data):
raise ValidationError('Old password could not be confirmed')
raise ValidationError("Old password could not be confirmed")
32 changes: 16 additions & 16 deletions app/routes/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,37 @@
from app.models.user import User
from app.forms.auth import LoginForm, RegisterForm

auth = Blueprint('auth', __name__, url_prefix='/auth')
auth = Blueprint("auth", __name__, url_prefix="/auth")


@auth.route('/')
@auth.route('/index')
@auth.route("/")
@auth.route("/index")
def index():
return redirect(url_for('auth.login'))
return redirect(url_for("auth.login"))


@auth.route('/login', methods=['GET', 'POST'])
@auth.route("/login", methods=["GET", "POST"])
def login():
if current_user.is_authenticated:
return redirect(url_for('main.index'))
return redirect(url_for("main.index"))

form = LoginForm()

if form.validate_on_submit():
user = User.query.filter_by(email=form.email.data).first()
if user is not None and user.check_password(form.password.data):
login_user(user, remember=form.remember_me.data)
return redirect(url_for('main.index'))
return redirect(url_for("main.index"))
else:
flash('Login Failed', 'danger')
flash("Login Failed", "danger")

return render_template('views/auth/login.html', title='Login', form=form)
return render_template("views/auth/login.html", title="Login", form=form)


@auth.route('/register', methods=['GET', 'POST'])
@auth.route("/register", methods=["GET", "POST"])
def register():
if current_user.is_authenticated:
return redirect(url_for('main.index'))
return redirect(url_for("main.index"))

form = RegisterForm()

Expand All @@ -48,13 +48,13 @@ def register():

login_user(user)

return redirect(url_for('main.index'))
return redirect(url_for("main.index"))

return render_template('views/auth/register.html', title='Register', form=form)
return render_template("views/auth/register.html", title="Register", form=form)


@auth.route('/logout')
@auth.route("/logout")
def logout():
logout_user()
flash('Logged Out', 'success')
return redirect(url_for('auth.login'))
flash("Logged Out", "success")
return redirect(url_for("auth.login"))
8 changes: 4 additions & 4 deletions app/routes/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from flask import Blueprint, render_template

main = Blueprint('main', __name__, url_prefix='/')
main = Blueprint("main", __name__, url_prefix="/")


@main.route('/')
@main.route('/index')
@main.route("/")
@main.route("/index")
def index():
return render_template('views/main/index.html', title='Home')
return render_template("views/main/index.html", title="Home")
14 changes: 7 additions & 7 deletions app/routes/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from app.models.user import User
from app.forms.profile import EditProfileForm, ChangePasswordForm

profile = Blueprint('profile', __name__, url_prefix='/profile')
profile = Blueprint("profile", __name__, url_prefix="/profile")


@profile.route('/index', methods=['GET', 'POST'])
@profile.route("/index", methods=["GET", "POST"])
@login_required
def index():
form = EditProfileForm()
Expand All @@ -20,16 +20,16 @@ def index():
user.note = form.note.data
user.save()

flash('Profile Successfully Updated', 'success')
flash("Profile Successfully Updated", "success")

form.name.data = current_user.name
form.email.data = current_user.email
form.note.data = current_user.note

return render_template('views/profile/index.html', title='Edit Profile', form=form)
return render_template("views/profile/index.html", title="Edit Profile", form=form)


@profile.route('/password', methods=['GET', 'POST'])
@profile.route("/password", methods=["GET", "POST"])
@login_required
def password():
form = ChangePasswordForm()
Expand All @@ -40,6 +40,6 @@ def password():
user.generate_password_hash(form.new_password.data)
user.save()

flash('Password Successfully Updated', 'success')
flash("Password Successfully Updated", "success")

return render_template('views/profile/password.html', title='Edit Password', form=form)
return render_template("views/profile/password.html", title="Edit Password", form=form)
2 changes: 1 addition & 1 deletion app/templates/assets/403.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'assets/base.html' %}
{% extends "assets/base.html" %}

{% set title = "Unauthorized" %}

Expand Down
2 changes: 1 addition & 1 deletion app/templates/assets/404.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'assets/base.html' %}
{% extends "assets/base.html" %}

{% set title = "Page Not Found" %}

Expand Down
2 changes: 1 addition & 1 deletion app/templates/assets/500.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'assets/base.html' %}
{% extends "assets/base.html" %}

{% set title = "International Server Error" %}

Expand Down
12 changes: 6 additions & 6 deletions app/templates/assets/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<header>
<!-- Fixed navbar -->
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand" href="{{ url_for('main.index') }}">Demongo</a>
<a class="navbar-brand" href="{{ url_for("main.index") }}">Demongo</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse"
aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
Expand All @@ -44,20 +44,20 @@
<a class="nav-link" disabled href="">{{ current_user.name }}</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('profile.index') }}">Profile</a>
<a class="nav-link" href="{{ url_for("profile.index") }}">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('profile.password') }}">Password</a>
<a class="nav-link" href="{{ url_for("profile.password") }}">Password</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('auth.logout') }}">Logout</a>
<a class="nav-link" href="{{ url_for("auth.logout") }}">Logout</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{{ url_for('auth.login') }}">Login</a>
<a class="nav-link" href="{{ url_for("auth.login") }}">Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('auth.register') }}">Register</a>
<a class="nav-link" href="{{ url_for("auth.register") }}">Register</a>
</li>
{% endif %}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/views/auth/login.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'assets/base.html' %}
{% extends "assets/base.html" %}

{% block content %}
<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion app/templates/views/auth/register.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'assets/base.html' %}
{% extends "assets/base.html" %}

{% block content %}
<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion app/templates/views/main/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'assets/base.html' %}
{% extends "assets/base.html" %}

{% block content %}
<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion app/templates/views/profile/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'assets/base.html' %}
{% extends "assets/base.html" %}

{% block content %}
<main role="main" class="container">
Expand Down
2 changes: 1 addition & 1 deletion app/templates/views/profile/password.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'assets/base.html' %}
{% extends "assets/base.html" %}

{% block content %}
<main role="main" class="container">
Expand Down

0 comments on commit 0c3ac7a

Please sign in to comment.