Merge pull request #12 from simple-login/email-notification
Email notification
This commit is contained in:
commit
43a96201ed
|
@ -88,6 +88,21 @@
|
||||||
<button class="btn btn-outline-primary">Update Preference</button>
|
<button class="btn btn-outline-primary">Update Preference</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h3 class="mb-0">Notifications</h3>
|
||||||
|
<div class="small-text mb-3">Do you want to receive our newsletter?</div>
|
||||||
|
<form method="post">
|
||||||
|
<input type="hidden" name="form-name" value="notification-preference">
|
||||||
|
<div class="form-inline mb-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="checkbox" id="notification" name="notification" {% if current_user.notification %} checked {% endif %} class="form-check-input">
|
||||||
|
<label for="notification">I want to receive your newsletter</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-outline-primary">Submit</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
<h3 class="mb-0">Export Data</h3>
|
<h3 class="mb-0">Export Data</h3>
|
||||||
<div class="small-text mb-3">
|
<div class="small-text mb-3">
|
||||||
|
|
|
@ -115,6 +115,15 @@ def setting():
|
||||||
elif request.form.get("form-name") == "change-password":
|
elif request.form.get("form-name") == "change-password":
|
||||||
send_reset_password_email(current_user)
|
send_reset_password_email(current_user)
|
||||||
|
|
||||||
|
elif request.form.get("form-name") == "notification-preference":
|
||||||
|
choose = request.form.get("notification")
|
||||||
|
if choose == "on":
|
||||||
|
current_user.notification = True
|
||||||
|
else:
|
||||||
|
current_user.notification = False
|
||||||
|
db.session.commit()
|
||||||
|
flash("Your notification preference has been updated", "success")
|
||||||
|
|
||||||
elif request.form.get("form-name") == "delete-account":
|
elif request.form.get("form-name") == "delete-account":
|
||||||
User.delete(current_user.id)
|
User.delete(current_user.id)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
|
@ -106,6 +106,9 @@ class User(db.Model, ModelMixin, UserMixin):
|
||||||
default=AliasGeneratorEnum.word.value,
|
default=AliasGeneratorEnum.word.value,
|
||||||
server_default=str(AliasGeneratorEnum.word.value),
|
server_default=str(AliasGeneratorEnum.word.value),
|
||||||
)
|
)
|
||||||
|
notification = db.Column(
|
||||||
|
db.Boolean, default=True, nullable=False, server_default="1"
|
||||||
|
)
|
||||||
|
|
||||||
activated = db.Column(db.Boolean, default=False, nullable=False)
|
activated = db.Column(db.Boolean, default=False, nullable=False)
|
||||||
|
|
||||||
|
|
29
migrations/versions/2019_123000_a8b996f0be40_.py
Normal file
29
migrations/versions/2019_123000_a8b996f0be40_.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: a8b996f0be40
|
||||||
|
Revises: 696e17c13b8b
|
||||||
|
Create Date: 2019-12-30 00:22:25.114359
|
||||||
|
|
||||||
|
"""
|
||||||
|
import sqlalchemy_utils
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = 'a8b996f0be40'
|
||||||
|
down_revision = '696e17c13b8b'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.add_column('users', sa.Column('notification', sa.Boolean(), server_default='1', nullable=False))
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_column('users', 'notification')
|
||||||
|
# ### end Alembic commands ###
|
Loading…
Reference in a new issue