From 10e8116d8350d4a17118c333d3ae47a965b1b55c Mon Sep 17 00:00:00 2001 From: mihasinkec Date: Sun, 6 Nov 2022 13:51:12 +0100 Subject: [PATCH] Added route prefix support. --- Dockerfile | 3 +- app.py | 217 ++++++++++++------------ config.ini | 1 + templates/solar-admin.html | 42 ++--- templates/solar-forgotpass.html | 16 +- templates/solar-login.html | 22 +-- templates/solar-manage-institution.html | 22 +-- templates/solar-oddaja.html | 34 ++-- templates/solar-pogodbe.html | 22 +-- templates/solar-register.html | 24 +-- templates/solar-resetpass.html | 10 +- templates/solar-zgodovina.html | 32 ++-- 12 files changed, 227 insertions(+), 218 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6198724..ca14a77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,5 @@ WORKDIR /usr/src/portal-webapp RUN apt-get update && apt-get -y install wkhtmltopdf && \ rm -rf /var/lib/apt/lists/* -RUN pip3 install --no-cache-dir pdfkit flask==1.1.4 flask-dropzone flask-log-request-id flask-login Flask-SQLAlchemy alembic flask-migrate==2.7.0 Flask-script psycopg2 gunicorn pdfkit Werkzeug==1.0.1 PyJWT - +RUN pip3 install --no-cache-dir pdfkit markupsafe==2.0.1 flask==1.1.4 flask-dropzone flask-log-request-id flask-login Flask-SQLAlchemy==2.5.1 alembic flask-migrate==2.7.0 Flask-script psycopg2 gunicorn pdfkit Werkzeug==1.0.1 PyJWT ENTRYPOINT ["./entrypoint.sh"] diff --git a/app.py b/app.py index e889e0e..351ff4c 100644 --- a/app.py +++ b/app.py @@ -27,6 +27,7 @@ config.read('config.ini') config = config['DEFAULT'] SERVER_NAME = config['SERVER_NAME'] +ROUTE_PREFIX = config['ROUTE_PREFIX'] MAIL_HOST = config['MAIL_HOST'] MAIL_LOGIN = config['MAIL_LOGIN'] MAIL_PASS = config['MAIL_PASS'] @@ -50,6 +51,8 @@ if not UPLOADS_DIR.exists: # Override configs with environment variables, if set if 'PORTALDS4DS1_SERVER_NAME' in os.environ: SERVER_NAME = os.environ['PORTALDS4DS1_SERVER_NAME'] +if 'PORTALDS4DS1_ROUTE_PREFIX' in os.environ: + ROUTE_PREFIX = os.environ['PORTALDS4DS1_ROUTE_PREFIX'] if 'PORTALDS4DS1_MAIL_HOST' in os.environ: MAIL_HOST = os.environ['PORTALDS4DS1_MAIL_HOST'] if 'PORTALDS4DS1_MAIL_LOGIN' in os.environ: @@ -80,7 +83,8 @@ if 'PORTALDS4DS1_SQL_CONN_STR' in os.environ: ###################### -app = Flask(__name__) +app = Flask(__name__, static_url_path = ROUTE_PREFIX + '/static') +#app = Flask(__name__) app.config.update( SERVER_NAME = SERVER_NAME, @@ -129,11 +133,11 @@ def redirect_url(default='/'): url_for(default) -@app.route('/') +@app.route(ROUTE_PREFIX + '/') def index(): if current_user.is_authenticated: - return redirect('/oddaja') - return redirect('/login') + return redirect(ROUTE_PREFIX + '/oddaja/') + return redirect(ROUTE_PREFIX + '/login/') @login_manager.user_loader @@ -142,17 +146,17 @@ def load_user(user_id): return user -@app.route('/login') +@app.route(ROUTE_PREFIX + '/login') def solar_login_get(): - return render_template('solar-login.html') + return render_template('solar-login.html', ROUTE_PREFIX=ROUTE_PREFIX) -@app.route('/register') +@app.route(ROUTE_PREFIX + '/register') def solar_register_get(): - return render_template('solar-register.html') + return render_template('solar-register.html', ROUTE_PREFIX=ROUTE_PREFIX) -@app.route('/login', methods=['POST']) +@app.route(ROUTE_PREFIX + '/login', methods=['POST']) def solar_login_post(): email = request.form.get('email') password = request.form.get('password') @@ -162,19 +166,19 @@ def solar_login_post(): if not user or not check_password_hash(user.pass_hash, password): flash('Napačni podatki za prijavo. Poskusite ponovno.') - return redirect('/login') + return redirect(ROUTE_PREFIX + '/login/') if not user.active: flash('Vaš uporabniški račun še ni bil aktiviran.') - return redirect('/login') + return redirect(ROUTE_PREFIX + '/login/') #portal.solar.add_user_session(user.id) login_user(user, remember=remember) - return redirect('/oddaja') + return redirect(ROUTE_PREFIX + '/oddaja/') -@app.route('/register', methods=['POST']) +@app.route(ROUTE_PREFIX + '/register', methods=['POST']) def solar_register_post(): name = request.form.get('name') email = request.form.get('email') @@ -187,38 +191,38 @@ def solar_register_post(): if user: flash('Uporabniški račun s tem emailom je že registriran.') - return redirect('/register') + return redirect(ROUTE_PREFIX + '/register/') if not name: flash('Prazno polje za ime.') - return redirect('/register') + return redirect(ROUTE_PREFIX + '/register/') if len(name) > 100: flash('Predolgo ime.') - return redirect('/register') + return redirect(ROUTE_PREFIX + '/register/') if not email: flash('Prazno polje za elektronsko pošto.') - return redirect('/register') + return redirect(ROUTE_PREFIX + '/register/') if len(email) > 100: flash('Predolgi email naslov') - return redirect('/register') + return redirect(ROUTE_PREFIX + '/register/') elif not re.search(portal.solar.REGEX_EMAIL, email): flash('Email napačnega formata.') - return redirect('/register') + return redirect(ROUTE_PREFIX + '/register/') if not password: flash('Prazno polje za geslo.') - return redirect('/register') + return redirect(ROUTE_PREFIX + '/register/') if len(password) < 8: flash('Geslo mora biti vsaj 8 znakov dolgo.') - return redirect('/register') + return redirect(ROUTE_PREFIX + '/register/') if len(password) > 100: flash('Predolgo geslo.') - return redirect('/register') + return redirect(ROUTE_PREFIX + '/register/') if institution_role not in ['coordinator', 'mentor', 'other']: flash('Neveljavna vloga v instituciji.') - return redirect('/register') + return redirect(ROUTE_PREFIX + '/register/') if not institution: institution_id = portal.solar.add_institution(institution_name, "") @@ -234,17 +238,17 @@ def solar_register_post(): portal.solar.send_admins_new_user_notification_mail(user_id, upload_handler_solar.config) flash('Podatki so bili poslani v potrditev. Ko bo registracija potrjena, boste o tem obveščeni po e-mailu.') - return redirect('/login') + return redirect(ROUTE_PREFIX + '/login/') -@app.route('/logout') +@app.route(ROUTE_PREFIX + '/logout') @login_required def logout(): logout_user() - return redirect('/login') + return redirect(ROUTE_PREFIX + '/login/') -@app.route('/') +@app.route(ROUTE_PREFIX + '/') @login_required def solar(text): is_admin = current_user.role == 'admin' @@ -259,6 +263,7 @@ def solar(text): if text.startswith('oddaja/') or text == 'oddaja': return render_template('solar-oddaja.html', + ROUTE_PREFIX=ROUTE_PREFIX, is_admin=is_admin, institution=current_user_institution, institution_contract=institution_contract, @@ -277,7 +282,8 @@ def solar(text): else: institution_names.append(institution.name) return render_template('solar-zgodovina.html', upload_history=upload_items, uploader_names=uploader_names, - institution_names=institution_names, is_admin=is_admin, is_institution_coordinator=current_user_institution_coordinator) + institution_names=institution_names, is_admin=is_admin, is_institution_coordinator=current_user_institution_coordinator, + ROUTE_PREFIX=ROUTE_PREFIX) elif text.startswith('pogodbe-institucije/') or text.startswith('pogodbe-ucencistarsi/'): # Check for download contract request. match = re.match('^pogodbe-(institucije|ucencistarsi)/([a-z0-9_]+\.pdf)$', text) @@ -321,7 +327,9 @@ def solar(text): else: contracts_students = portal.solar.get_institution_student_contracts(current_user_institution.id, current_user_obj.id) - return render_template('solar-pogodbe.html', contracts_students=contracts_students, + return render_template('solar-pogodbe.html', + ROUTE_PREFIX=ROUTE_PREFIX, + contracts_students=contracts_students, contract_school=contract_school, enable_upload_school_contract=enable_upload_school_contract, show_upload_form=show_upload_form, @@ -336,7 +344,7 @@ def solar(text): solar_institutions = portal.solar.get_all_institutions() uploads = portal.solar.get_all_upload_history(-1) if is_admin: - return render_template('solar-admin.html', users=users, + return render_template('solar-admin.html', ROUTE_PREFIX=ROUTE_PREFIX, users=users, institutions=solar_institutions, inactive_users=inactive_users, uploads=uploads) elif text.startswith('manage-institution/') or text == 'manage-institution': if portal.solar.is_institution_coordinator(current_user.id, current_user_institution.id): @@ -348,21 +356,22 @@ def solar(text): role_map[institution_user.id] = portal.solar.get_user_institution_role_str(institution_user.id, current_user_institution.id) return render_template('solar-manage-institution.html', + ROUTE_PREFIX=ROUTE_PREFIX, institution=current_user_institution, users=solar_users, institution_users=institution_users, role_map=role_map) return '', 404 -@app.route('/pogodbe', methods=['POST']) +@app.route(ROUTE_PREFIX + '/pogodbe', methods=['POST']) @login_required def solar_upload_contract(): msg = upload_handler_solar.handle_contract_upload(request, current_user.get_id()) flash(msg) - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) -@app.route('/adduser', methods=['POST']) +@app.route(ROUTE_PREFIX + '/adduser', methods=['POST']) @login_required def solar_add_user(): @@ -375,41 +384,41 @@ def solar_add_user(): if not name: flash('Prazno polje za ime.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) if len(name) > 100: flash('Predolgo ime.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) if not email: flash('Prazno polje za elektronsko pošto.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) if len(email) > 100: flash('Predolg email naslov.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) elif not re.search(portal.solar.REGEX_EMAIL, email): flash('Email napačnega formata.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) if not password: flash('Prazno polje za geslo.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) if len(password) > 100: flash('Predolgo geslo.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) user = portal.solar.get_user_obj_by_email(email) if user: #portal.solar.undo_remove_user(user.id) flash('Uporabnik s tem emailom je že vnešen v sistem.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) portal.solar.register_new_user(name, email, password) flash('Uporabnik je bil uspešno dodan.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) -@app.route('/activateuser', methods=['POST']) +@app.route(ROUTE_PREFIX + '/activateuser', methods=['POST']) @login_required def solar_activate_user(): if not portal.solar.is_admin(current_user.id): @@ -418,7 +427,7 @@ def solar_activate_user(): user_id = request.form.get('id') if not user_id: flash('Prazno polje za ID uporabnika.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) rowcount = portal.solar.activate_user(user_id) if rowcount == 0: @@ -427,35 +436,35 @@ def solar_activate_user(): portal.solar.send_user_activation_mail(user_id, upload_handler_solar.config) flash('Uporabnik je bil aktiviran.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) -@app.route('/forgotpass') +@app.route(ROUTE_PREFIX + '/forgotpass') def solar_forgotpass(): - return render_template('solar-forgotpass.html') + return render_template('solar-forgotpass.html', ROUTE_PREFIX=ROUTE_PREFIX) -@app.route('/sendresetpass', methods=['POST']) +@app.route(ROUTE_PREFIX + '/sendresetpass', methods=['POST']) def solar_sendresetpass(): email = request.form.get('email') portal.solar.send_resetpass_mail(email, upload_handler_solar.config) flash('Povezava za ponastavitev gesla je bila poslana na vpisani e-naslov.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) -@app.route('/resetpass/') +@app.route(ROUTE_PREFIX + '/resetpass/') def solar_resetpass(token): user = portal.solar.verify_reset_token(token, upload_handler_solar.config['APP_SECRET_KEY']) if not user: return '', 404 - return render_template('solar-resetpass.html', user=user, token=token) + return render_template('solar-resetpass.html',ROUTE_PREFIX=ROUTE_PREFIX, user=user, token=token) -@app.route('/resetpass/', methods=['POST']) +@app.route(ROUTE_PREFIX + '/resetpass/', methods=['POST']) def solar_resetpass_post(token): new_password = request.form.get('new_password') user = portal.solar.verify_reset_token(token, upload_handler_solar.config['APP_SECRET_KEY']) @@ -468,28 +477,28 @@ def solar_resetpass_post(token): return '', 404 flash('Ponastavitev gesla je bila uspešna.') - return redirect('/login') + return redirect(ROUTE_PREFIX + '/login/') -@app.route('/topuploads') +@app.route(ROUTE_PREFIX + '/topuploads') @login_required def solar_topuploads(): return jsonify(portal.solar.get_top_uploading_institutions()) -@app.route('/topuploads-institution/') +@app.route(ROUTE_PREFIX + '/topuploads-institution/') @login_required def solar_topuploads_institution(institution_id): return jsonify(portal.solar.get_top_uploading_users(institution_id)) -@app.route('/uploadstats-institution/') +@app.route(ROUTE_PREFIX + '/uploadstats-institution/') @login_required def solar_uploadstats_institution(institution_id): return jsonify(portal.solar.get_institution_upload_stats(institution_id)) -@app.route('/deluser', methods=['POST']) +@app.route(ROUTE_PREFIX + '/deluser', methods=['POST']) @login_required def solar_del_user(): if not portal.solar.is_admin(current_user.id): @@ -497,9 +506,9 @@ def solar_del_user(): user_id = request.form.get('user_id') portal.solar.remove_user(user_id) flash('Uporabnik je bil odstranjen.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) -@app.route('/addinstitution', methods=['POST']) +@app.route(ROUTE_PREFIX + '/addinstitution', methods=['POST']) @login_required def add_institution(): if not portal.solar.is_admin(current_user.id): @@ -510,21 +519,21 @@ def add_institution(): if not name: flash('Prazno polje za naziv.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) if len(name) > 100: flash('Predolgo ime.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) if not region in portal.solar.VALID_REGIONS: flash('Neveljavna vrednost za regijo.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) institution_id = portal.solar.add_institution(name, region) portal.solar.grant_institution_corpus_access(institution_id, "solar") # TODO: throw out flash('Institucija je bila dodana.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) -@app.route('/mergeinstitutions', methods=['POST']) +@app.route(ROUTE_PREFIX + '/mergeinstitutions', methods=['POST']) @login_required def merge_institutions(): if not portal.solar.is_admin(current_user.id): @@ -535,18 +544,18 @@ def merge_institutions(): if not id_from or not id_to: flash('Prazno polje.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) institution_from = portal.solar.get_institution_obj(id_from) institution_to = portal.solar.get_institution_obj(id_to) if not institution_from: flash('Institucija z ID "{}" ne obstaja.'.format(id_from)) - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) if not institution_to: flash('Institucija z ID "{}" ne obstaja.'.format(id_to)) - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) portal.solar.transfer_users_institution(institution_from.id, institution_to.id) @@ -555,9 +564,9 @@ def merge_institutions(): portal.solar.remove_institution(institution_from.id) flash('Instituciji uspešno združeni') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) -#@app.route('/addcooperationhistoryitem', methods=['POST']) +#@app.route(ROUTE_PREFIX + '/addcooperationhistoryitem', methods=['POST']) #@login_required #def add_cooperation_history_item(): # if not portal.solar.is_admin(current_user.id): @@ -574,26 +583,26 @@ def merge_institutions(): # # if not user: # flash('Uporabnik s tem ID-jem ne obstaja.') -# return redirect(redirect_url()) +# return redirect(ROUTE_PREFIX + redirect_url()) # # if not institution: # flash('Institucija s tem ID-jem ne obstaja.') -# return redirect(redirect_url()) +# return redirect(ROUTE_PREFIX + redirect_url()) # # if not role in ['coordinator', 'mentor', 'other']: # flash('Neveljavna vloga "{}".'.format(role)) -# return redirect(redirect_url()) +# return redirect(ROUTE_PREFIX + redirect_url()) # # if not school_year or not re.match('[0-9]{4}/[0-9]{2}', school_year): # flash('Šolsko leto mora biti formata "2021/22".') -# return redirect(redirect_url()) +# return redirect(ROUTE_PREFIX + redirect_url()) # # portal.solar.add_cooperation_history_item(user_id, institution_id, role, school_year, badge_text) # # flash('Vnos dodan.') -# return redirect(redirect_url()) +# return redirect(ROUTE_PREFIX + redirect_url()) -@app.route('/updateuploaditem', methods=['POST']) +@app.route(ROUTE_PREFIX + '/updateuploaditem', methods=['POST']) @login_required def update_upload_item(): if not portal.solar.is_admin(current_user.id): @@ -602,7 +611,7 @@ def update_upload_item(): err_msg = portal.solar.UploadHandlerSolar.check_form(request.form) if err_msg: flash(err_msg) - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) item_id = request.form.get('item-id') program = request.form.get('program') @@ -629,10 +638,10 @@ def update_upload_item(): return '', 404 flash('Vnos spremenjen.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) -#@app.route('/delcooperationhistoryitem', methods=['POST']) +#@app.route(ROUTE_PREFIX + '/delcooperationhistoryitem', methods=['POST']) #@login_required #def del_cooperation_history_item(): # if not portal.solar.is_admin(current_user.id): @@ -642,9 +651,9 @@ def update_upload_item(): # portal.solar.del_cooperation_history_item(entry_id) # # flash('Vnos odstranjen.') -# return redirect(redirect_url()) +# return redirect(ROUTE_PREFIX + redirect_url()) -@app.route('/changeinstitutiondata', methods=['POST']) +@app.route(ROUTE_PREFIX + '/changeinstitutiondata', methods=['POST']) @login_required def change_institution_data(): if not portal.solar.is_admin(current_user.id): @@ -656,21 +665,21 @@ def change_institution_data(): if not new_name: flash('Prazno polje za naziv.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) if len(new_name) > 100: flash('Predolgo ime.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) if not new_region in portal.solar.VALID_REGIONS: flash('Neveljavna vrednost za regijo.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) portal.solar.update_institution_data(institution_id, new_name, new_region) flash('Podatki institucije so bili spremenjeni.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) -@app.route('/changeuseremail', methods=['POST']) +@app.route(ROUTE_PREFIX + '/changeuseremail', methods=['POST']) @login_required def change_user_email(): if not portal.solar.is_admin(current_user.id): @@ -681,14 +690,14 @@ def change_user_email(): if not re.search(portal.solar.REGEX_EMAIL, email): flash('Email napačnega formata.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) portal.solar.update_user_email(user_id, email) flash('Email spremenjen.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) -@app.route('/changeuserrole-institution', methods=['POST']) +@app.route(ROUTE_PREFIX + '/changeuserrole-institution', methods=['POST']) @login_required def change_user_role_institution(): institution = portal.solar.get_user_institution(current_user.id) @@ -705,16 +714,16 @@ def change_user_role_institution(): if role not in ['coordinator', 'mentor', 'other']: flash('Neveljavna vloga.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) portal.solar.update_user_institution_role(user_id, institution.id, role) portal.solar.add_cooperation_history_item(user_id, institution.id, role) flash('Vloga v instituciji spremenjena.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) -@app.route('/changeuserrole', methods=['POST']) +@app.route(ROUTE_PREFIX + '/changeuserrole', methods=['POST']) @login_required def change_user_role(): institution = portal.solar.get_user_institution(current_user.id) @@ -726,14 +735,14 @@ def change_user_role(): if not role in ['admin', 'user']: flash('Neveljavna vloga.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) portal.solar.update_user_role(user_id, role) flash('Vloga spremenjena.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) -@app.route('/changeusername', methods=['POST']) +@app.route(ROUTE_PREFIX + '/changeusername', methods=['POST']) @login_required def change_user_name(): if not portal.solar.is_admin(current_user.id): @@ -745,9 +754,9 @@ def change_user_name(): portal.solar.update_user_name(user_id, name) flash('Ime in priimek spremenjena.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) -@app.route('/addusertoinstitution', methods=['POST']) +@app.route(ROUTE_PREFIX + '/addusertoinstitution', methods=['POST']) @login_required def add_user_institution_mapping(): institution_id = request.form.get('institution_id') @@ -766,39 +775,39 @@ def add_user_institution_mapping(): if portal.solar.get_user_institution(user_id): flash('Uporabnik je že dodeljen instituciji.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) portal.solar.add_user_to_institution(user_id, institution_id, role) portal.solar.add_cooperation_history_item(user_id, institution_id, role) flash('Uporabnik je bil dodeljen instituciji.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) -@app.route('/deluserfrominstitution', methods=['POST']) +@app.route(ROUTE_PREFIX + '/deluserfrominstitution', methods=['POST']) @login_required def del_user_institution_mapping(): user_id = request.form['user_id'] institution = portal.solar.get_user_institution(user_id) if not institution: flash('Uporabnik ni član nobene institucije.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) if not portal.solar.is_admin(current_user.id) \ and not portal.solar.is_institution_coordinator(current_user.id, institution.id): flash('Nimate ustreznih pravic za odstranitev uporabnika iz institucije.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) portal.solar.del_user_from_institution(user_id, institution.id) flash('Uporabnik je bil odstranjen iz institucije.') - return redirect(redirect_url()) + return redirect(ROUTE_PREFIX + redirect_url()) -@app.route('/upload', methods=['POST']) +@app.route(ROUTE_PREFIX + '/upload', methods=['POST']) def handle_upload(): if not current_user.is_authenticated: return '', 404 return upload_handler_solar.handle_upload(request, current_user.get_id()) -@app.route('/getuploadfile//', methods=['GET']) +@app.route(ROUTE_PREFIX + '/getuploadfile//', methods=['GET']) @login_required def get_upload_file(upload_id, file_hash): is_admin = current_user.role == 'admin' diff --git a/config.ini b/config.ini index 0021cad..bbb35cc 100644 --- a/config.ini +++ b/config.ini @@ -1,5 +1,6 @@ [DEFAULT] SERVER_NAME=localhost:5000 +ROUTE_PREFIX= SQL_CONN_STR=postgresql://portal:randompass123@localhost/portal MAIL_HOST=posta.cjvt.si MAIL_LOGIN=oddaja-besedil@cjvt.si diff --git a/templates/solar-admin.html b/templates/solar-admin.html index 70ad85a..1a83a81 100644 --- a/templates/solar-admin.html +++ b/templates/solar-admin.html @@ -3,10 +3,10 @@ Admin panel - Šolar - - - - + + + +