notification setting
This commit is contained in:
parent
89664580b3
commit
84eb10232c
|
@ -81,6 +81,21 @@
|
|||
<button class="btn btn-outline-primary">Update Preference</button>
|
||||
</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>
|
||||
<h3 class="mb-0">Export Data</h3>
|
||||
<div class="small-text mb-3">
|
||||
|
|
|
@ -115,6 +115,15 @@ def setting():
|
|||
elif request.form.get("form-name") == "change-password":
|
||||
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":
|
||||
User.delete(current_user.id)
|
||||
db.session.commit()
|
||||
|
|
|
@ -106,6 +106,7 @@ class User(db.Model, ModelMixin, UserMixin):
|
|||
default=AliasGeneratorEnum.word.value,
|
||||
server_default=str(AliasGeneratorEnum.word.value),
|
||||
)
|
||||
notification = db.Column(db.Boolean, default=True, nullable=False, server_default=str(True))
|
||||
|
||||
activated = db.Column(db.Boolean, default=False, nullable=False)
|
||||
|
||||
|
|
Loading…
Reference in a new issue