Skip to content

Commit

Permalink
change somethings
Browse files Browse the repository at this point in the history
  • Loading branch information
emregeldegul committed Feb 4, 2022
1 parent eec9b77 commit 5ad847f
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 55 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright [2022] Yunus Emre Geldegül

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ from app.models.abstract import BaseModel


class Order(BaseModel):
id = db.Column(db.Integer, primary_key=True)
number = db.Column(db.String(50), nullable=False, unique=True)
...

Expand Down
11 changes: 8 additions & 3 deletions app/forms/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ class LoginForm(FlaskForm):


class RegisterForm(FlaskForm):
name = StringField(
'Name',
first_name = StringField(
'First Name',
validators=[DataRequired(), Length(max=30)],
render_kw={'placeholder': 'Name', 'autofocus': True}
render_kw={'placeholder': 'First Name', 'autofocus': True}
)
last_name = StringField(
'Last Name',
validators=[DataRequired(), Length(max=30)],
render_kw={'placeholder': 'Last Name'}
)
email = StringField(
'E-Mail',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from settings import settings


class MailService:
class MailHelper:
def __init__(self):
self.sender = settings.MAIL_USERNAME

Expand Down
1 change: 1 addition & 0 deletions app/models/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class BaseModel(db.Model):
__abstract__ = True

id = db.Column(db.Integer, primary_key=True)
created_at = db.Column(db.DateTime, nullable=False, default=db.func.now(), server_default=db.func.now())
updated_at = db.Column(db.DateTime, nullable=False, default=db.func.now(), server_default=db.func.now(), onupdate=db.func.now()) # noqa

Expand Down
7 changes: 4 additions & 3 deletions app/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ def load_user(id):


class User(BaseModel, UserMixin):
id = db.Column(db.Integer, primary_key=True)
first_name = db.Column(db.String(50), nullable=False)
last_name = db.Column(db.String(50), nullable=False)
full_name = db.column_property(first_name + " " + last_name)
email = db.Column(db.String(70), nullable=False, unique=True)
password = db.Column(db.String(32), nullable=False)
name = db.Column(db.String(30), nullable=True)
password = db.Column(db.String(102), nullable=False)
note = db.Column(db.Text, nullable=True)

def __repr__(self):
Expand Down
3 changes: 2 additions & 1 deletion app/routes/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ def register():

if form.validate_on_submit():
user = User()
user.first_name = form.first_name.data
user.last_name = form.last_name.data
user.email = form.email.data
user.name = form.name.data
user.generate_password_hash(form.password.data)
user.save()

Expand Down
4 changes: 2 additions & 2 deletions app/templates/assets/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

<title>
{% if title is defined %}
{{ title }} | Demongo
{{ title }} | {{ config["TITLE"] }}
{% else %}
{{ site_name }}
{{ config["TITLE"] }} | {{ config["BRIEF"] }}
{% endif %}
</title>

Expand Down
45 changes: 29 additions & 16 deletions app/templates/views/auth/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,37 @@
<main role="main" class="container">
<h1 class="mt-5">{{ title }}</h1>
<hr>
{{ error(form) }}
{{ alert() }}
<div class="row">
<div class="col-md-12">
{{ error(form) }}
{{ alert() }}
</div>
</div>
<form method="POST" action="">
{{ form.csrf_token() }}
<div class="form-group">
{{ form.email.label() }}
{{ form.email(class="form-control") }}
</div>
<div class="form-group">
{{ form.password.label() }}
{{ form.password(class="form-control") }}
</div>
<div class="form-group form-check">
{{ form.remember_me(class="form-check-input") }}
{{ form.remember_me.label(class="form-check-label") }}
</div>
<div class="form-group">
{{ form.submit(class="btn btn-primary") }}
<div class="row">
<div class="col-md-12">
<div class="form-group">
{{ form.email.label() }}
{{ form.email(class="form-control") }}
</div>

</div>
<div class="col-md-12">
<div class="form-group">
{{ form.password.label() }}
{{ form.password(class="form-control") }}
</div>
</div>
<div class="col-md-12">
<div class="form-group form-check">
{{ form.remember_me(class="form-check-input") }}
{{ form.remember_me.label(class="form-check-label") }}
</div>
<div class="form-group text-right">
{{ form.submit(class="btn btn-primary") }}
</div>
</div>
</div>
</form>
</main>
Expand Down
60 changes: 40 additions & 20 deletions app/templates/views/auth/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,48 @@
<main role="main" class="container">
<h1 class="mt-5">{{ title }}</h1>
<hr>
{{ error(form) }}
{{ alert() }}
<div class="row">
<div class="col-md-12">
{{ error(form) }}
{{ alert() }}
</div>
</div>
<form method="POST" action="">
{{ form.csrf_token() }}
<div class="form-group">
{{ form.name.label() }}
{{ form.name(class="form-control") }}
</div>
<div class="form-group">
{{ form.email.label() }}
{{ form.email(class="form-control") }}
</div>
<div class="form-group">
{{ form.password.label() }}
{{ form.password(class="form-control") }}
</div>
<div class="form-group">
{{ form.password_confirm.label() }}
{{ form.password_confirm(class="form-control") }}
</div>
<div class="form-group">
{{ form.submit(class="btn btn-primary") }}
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ form.first_name.label() }}
{{ form.first_name(class="form-control") }}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ form.last_name.label() }}
{{ form.last_name(class="form-control") }}
</div>
</div>
<div class="col-md-12">
<div class="form-group">
{{ form.email.label() }}
{{ form.email(class="form-control") }}
</div>
</div>
<div class="col-md-6">
{{ form.password.label() }}
{{ form.password(class="form-control") }}
</div>
<div class="col-md-6">
<div class="form-group">
{{ form.password_confirm.label() }}
{{ form.password_confirm(class="form-control") }}
</div>
</div>
<div class="col-md-12">
<div class="form-group text-right">
{{ form.submit(class="btn btn-primary") }}
</div>
</div>
</div>
</form>
</main>
Expand Down
20 changes: 13 additions & 7 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ class Settings:
basedir = path.abspath(path.dirname(__file__))
load_dotenv(path.join(basedir, '.env'))

# Flask Settings
SECRET_KEY = getenv("SECRET_KEY", urandom(24))
PORT = getenv("PORT", 80)
DEBUG = getenv("DEBUG", False)
TESTING = getenv("TESTING", False)
ENV = getenv("ENV", "production")

# APP Settings
TITLE = getenv("TITLE", "Demongo")
BRIEF = getenv("BRIEF", "A Simple Structure For the Flask Framework")
SITE_URL = getenv("SITE_URL", "localhost")

SECRET_KEY = getenv("SECRET_KEY") or urandom(24)
PORT = getenv("PORT") or 80
DEBUG = getenv("DEBUG") or False
TESTING = getenv("TESTING") or False
ENV = getenv("ENV") or "production"
SQLALCHEMY_DATABASE_URI = getenv("SQLALCHEMY_DATABASE_URI") or "sqlite:///" + path.join(basedir, "demongo.db")
SQLALCHEMY_TRACK_MODIFICATIONS = False
# Database Settings
SQLALCHEMY_DATABASE_URI = getenv("SQLALCHEMY_DATABASE_URI", "sqlite:///" + path.join(basedir, "demongo.db"))
SQLALCHEMY_TRACK_MODIFICATIONS = getenv("SQLALCHEMY_TRACK_MODIFICATIONS", False)

# Mail Settings
MAIL_SERVER = getenv("MAIL_SERVER", "smtp.googlemail.com")
MAIL_PORT = getenv("MAIL_SERVER", 587)
MAIL_USE_TLS = True
Expand Down

0 comments on commit 5ad847f

Please sign in to comment.