User edit email fix

This commit is contained in:
Jan Broer 2015-08-02 21:43:33 +02:00
parent aef608aa10
commit 0b5b3b8424
3 changed files with 10 additions and 10 deletions

View File

@ -5,7 +5,7 @@
<form role="form" method="POST">
<div class="form-group">
<label for="email">e-mail</label>
<input type="email" class="form-control" name="email" id="email" value="{{content.email}}">
<input type="email" class="form-control" name="email" id="email" value="{{ content.email if content.email != None }}">
</div>
<div class="form-group">
<label for="password">password</label>
@ -13,16 +13,16 @@
</div>
<div class="form-group">
<label for="kindle_mail">Kindle E-Mail</label>
<input type="text" class="form-control" name="kindle_mail" id="kindle_mail" value="{{content.kindle_mail}}">
<input type="text" class="form-control" name="kindle_mail" id="kindle_mail" value="{{ content.kindle_mail if content.kindle_mail != None }}">
</div>
{% if g.user and g.user.role %}
<div class="form-group">
<label for="user_role">is admin</label>
<input type="text" class="form-control" name="user_role" id="user_role" value="{{content.role}}">
<label for="user_role">Admin user? 0 or 1</label>
<input type="text" class="form-control" name="user_role" id="user_role" value="{{ content.role if content.role != None }}">
</div>
<div class="form-group">
<label for="nickname">nickname</label>
<input type="text" class="form-control" name="nickname" id="nickname" value="{{content.nickname}}">
<input type="text" class="form-control" name="nickname" id="nickname" value="{{ content.nickname if content.nickname != None }}">
</div>
<div class="checkbox">
<label>

View File

@ -21,7 +21,7 @@ class User(Base):
id = Column(Integer, primary_key = True)
nickname = Column(String(64), unique = True)
email = Column(String(120), unique = True)
email = Column(String(120), unique = True, default = "")
role = Column(SmallInteger, default = ROLE_USER)
password = Column(String)
kindle_mail = Column(String(120), default="")

View File

@ -324,16 +324,16 @@ def logout():
def send_to_kindle(book_id):
settings = ub.get_mail_settings()
if settings.get("mail_server", "mail.example.com") == "mail.example.com":
flash("please configure your email account settings first...", category="error")
flash("Please configure the SMTP email account first...", category="error")
elif current_user.kindle_mail:
x = helper.send_mail(book_id, current_user.kindle_mail)
if x:
flash("mail successfully send to %s" % current_user.kindle_mail, category="success")
flash("Mail successfully send to %s" % current_user.kindle_mail, category="success")
helper.update_download(book_id, int(current_user.id))
else:
flash("there was an error sending this book", category="error")
flash("There was an error sending this book", category="error")
else:
flash("please set a kindle mail first...", category="error")
flash("Please set a kindle mail first...", category="error")
return redirect(request.environ["HTTP_REFERER"])
@app.route("/shelf/add/<int:shelf_id>/<int:book_id>")