Merge branch 'master' into Develop
This commit is contained in:
38
cps/admin.py
38
cps/admin.py
@ -197,10 +197,10 @@ def update_view_configuration():
|
||||
return view_configuration()
|
||||
|
||||
|
||||
@admi.route("/ajax/editdomain", methods=['POST'])
|
||||
@admi.route("/ajax/editdomain/<int:allow>", methods=['POST'])
|
||||
@login_required
|
||||
@admin_required
|
||||
def edit_domain():
|
||||
def edit_domain(allow):
|
||||
# POST /post
|
||||
# name: 'username', //name of field (column in db)
|
||||
# pk: 1 //primary key (record id)
|
||||
@ -213,14 +213,14 @@ def edit_domain():
|
||||
return ""
|
||||
|
||||
|
||||
@admi.route("/ajax/adddomain", methods=['POST'])
|
||||
@admi.route("/ajax/adddomain/<int:allow>", methods=['POST'])
|
||||
@login_required
|
||||
@admin_required
|
||||
def add_domain():
|
||||
def add_domain(allow):
|
||||
domain_name = request.form.to_dict()['domainname'].replace('*', '%').replace('?', '_').lower()
|
||||
check = ub.session.query(ub.Registration).filter(ub.Registration.domain == domain_name).first()
|
||||
check = ub.session.query(ub.Registration).filter(ub.Registration.domain == domain_name).filter(ub.Registration.allow == allow).first()
|
||||
if not check:
|
||||
new_domain = ub.Registration(domain=domain_name)
|
||||
new_domain = ub.Registration(domain=domain_name, allow=allow)
|
||||
ub.session.add(new_domain)
|
||||
ub.session.commit()
|
||||
return ""
|
||||
@ -234,18 +234,18 @@ def delete_domain():
|
||||
ub.session.query(ub.Registration).filter(ub.Registration.id == domain_id).delete()
|
||||
ub.session.commit()
|
||||
# If last domain was deleted, add all domains by default
|
||||
if not ub.session.query(ub.Registration).count():
|
||||
new_domain = ub.Registration(domain="%.%")
|
||||
if not ub.session.query(ub.Registration).filter(ub.Registration.allow==1).count():
|
||||
new_domain = ub.Registration(domain="%.%",allow=1)
|
||||
ub.session.add(new_domain)
|
||||
ub.session.commit()
|
||||
return ""
|
||||
|
||||
|
||||
@admi.route("/ajax/domainlist")
|
||||
@admi.route("/ajax/domainlist/<int:allow>")
|
||||
@login_required
|
||||
@admin_required
|
||||
def list_domain():
|
||||
answer = ub.session.query(ub.Registration).all()
|
||||
def list_domain(allow):
|
||||
answer = ub.session.query(ub.Registration).filter(ub.Registration.allow == allow).all()
|
||||
json_dumps = json.dumps([{"domain": r.domain.replace('%', '*').replace('_', '?'), "id": r.id} for r in answer])
|
||||
js = json.dumps(json_dumps.replace('"', "'")).lstrip('"').strip('"')
|
||||
response = make_response(js.replace("'", '"'))
|
||||
@ -635,6 +635,7 @@ def edit_user(user_id):
|
||||
else:
|
||||
flash(_(u"Found an existing account for this e-mail address."), category="error")
|
||||
return render_title_template("user_edit.html", translations=translations, languages=languages,
|
||||
mail_configured = config.get_mail_server_configured(),
|
||||
new_user=0, content=content, downloads=downloads, registered_oauth=oauth_check,
|
||||
title=_(u"Edit User %(nick)s", nick=content.nickname), page="edituser")
|
||||
if "nickname" in to_save and to_save["nickname"] != content.nickname:
|
||||
@ -646,11 +647,11 @@ def edit_user(user_id):
|
||||
return render_title_template("user_edit.html",
|
||||
translations=translations,
|
||||
languages=languages,
|
||||
mail_configured=config.get_mail_server_configured(),
|
||||
new_user=0, content=content,
|
||||
downloads=downloads,
|
||||
registered_oauth=oauth_check,
|
||||
title=_(u"Edit User %(nick)s",
|
||||
nick=content.nickname),
|
||||
title=_(u"Edit User %(nick)s", nick=content.nickname),
|
||||
page="edituser")
|
||||
|
||||
if "kindle_mail" in to_save and to_save["kindle_mail"] != content.kindle_mail:
|
||||
@ -663,21 +664,27 @@ def edit_user(user_id):
|
||||
flash(_(u"An unknown error occured."), category="error")
|
||||
return render_title_template("user_edit.html", translations=translations, languages=languages, new_user=0,
|
||||
content=content, downloads=downloads, registered_oauth=oauth_check,
|
||||
mail_configured=config.get_mail_server_configured(),
|
||||
title=_(u"Edit User %(nick)s", nick=content.nickname), page="edituser")
|
||||
|
||||
|
||||
@admi.route("/admin/resetpassword/<int:user_id>")
|
||||
@login_required
|
||||
@admin_required
|
||||
def reset_password(user_id):
|
||||
def reset_user_password(user_id):
|
||||
if not config.config_public_reg:
|
||||
abort(404)
|
||||
if current_user is not None and current_user.is_authenticated:
|
||||
ret, message = reset_password(user_id)
|
||||
if ret == 1:
|
||||
log.debug(u"Password for user %(user)s reset", user=message)
|
||||
flash(_(u"Password for user %(user)s reset", user=message), category="success")
|
||||
else:
|
||||
elif ret == 0:
|
||||
log.error(u"An unknown error occurred. Please try again later.")
|
||||
flash(_(u"An unknown error occurred. Please try again later."), category="error")
|
||||
else:
|
||||
log.error(u"Please configure the SMTP mail settings first...")
|
||||
flash(_(u"Please configure the SMTP mail settings first..."), category="error")
|
||||
return redirect(url_for('admin.admin'))
|
||||
|
||||
|
||||
@ -711,6 +718,7 @@ def send_logfile(logtype):
|
||||
@admi.route("/get_update_status", methods=['GET'])
|
||||
@login_required_if_no_ano
|
||||
def get_update_status():
|
||||
log.info(u"Update status requested")
|
||||
return updater_thread.get_available_updates(request.method, locale=get_locale())
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user