diff --git a/main.py b/main.py index d645b40..46f0e08 100644 --- a/main.py +++ b/main.py @@ -45,7 +45,6 @@ with open('incepted.config', 'r', encoding='utf-8') as file: file = loads(file) key = file["encrypt_key"] app.config['SECRET_KEY'] = key -app.debug = True logging.basicConfig(level=logging.INFO, filename="logfiles/main.log", format="%(asctime)s %(levelname)s %(message)s", encoding='utf-8') csrf = CSRFProtect(app) @@ -95,7 +94,7 @@ def admin_user(login_usr): user.email = form.email.data data_session.commit() return redirect(f'/admin/user/{str(login_usr)}') - return render_template('profile.html', title=user.login, form=form, message='', user=user) + return render_template('profile.html', title=user.login, form=form, message='', user=user, admin=True) else: abort(403) abort(404) @@ -234,7 +233,8 @@ def edit_quest(id_project, id_task): current_project = data_session.query(Projects).filter(Projects.id == id_project).first() current_task = data_session.query(Quests).filter(Quests.id == id_task).first() if current_project and current_task and current_task.project == current_project.id and ( - current_task.creator == current_user.id or current_project.creator == current_user.id): + current_task.creator == current_user.id or current_project.creator == current_user.id) \ + or current_user.role == 1: form = Task() if request.method == 'GET': form.name.data = current_task.name @@ -276,7 +276,8 @@ def delete_file(id_project, id_file): current_file = data_session.query(Files).filter(Files.id == id_file).first() if current_project and current_file: if current_user.id in map(lambda x: x[0], data_session.query(StaffProjects.user).filter( - StaffProjects.project == current_project.id).all()) or current_user.id == current_project.creator: + StaffProjects.project == current_project.id).all()) or current_user.id == current_project.creator \ + or current_user.role == 1: current_proof = data_session.query(FileProof).filter(FileProof.file == id_file).all() os.remove(current_file.path) data_session.delete(current_file) @@ -306,7 +307,7 @@ def task_project(id_project, id_task): data_session = db_session.create_session() current_project = data_session.query(Projects).filter(Projects.id == id_project).first() current_task = data_session.query(Quests).filter(Quests.id == id_task).first() - if current_project and current_task and current_task.project == current_project.id: + if current_project and current_task and current_task.project == current_project.id or current_user.role == 1: form = AnswerTask() current_answer = data_session.query(Answer).filter(Answer.quest == current_task.id).first() list_files = None @@ -410,7 +411,7 @@ def edit_project(id_project): current_project = data_session.query(Projects).filter(Projects.id == id_project).first() if current_project: staff = data_session.query(StaffProjects).filter(StaffProjects.project == current_project.id).all() - if current_user.id == current_project.creator: + if current_user.id == current_project.creator or current_user.role == 1: list_users = list( map(lambda x: get_user_data(x), data_session.query(User).filter(User.id != current_user.id, User.activated == 1).all())) @@ -472,7 +473,8 @@ def project(id_project): current_project = data_session.query(Projects).filter(Projects.id == id_project).first() if current_project: staff = data_session.query(StaffProjects).filter(StaffProjects.project == current_project.id).all() - if current_user.id == current_project.creator or current_user.id in list(map(lambda x: x.user, staff)): + if current_user.id == current_project.creator or current_user.id in list( + map(lambda x: x.user, staff)) or current_user.role == 1: staff = list(map(lambda x: get_user_data(x), data_session.query(User).filter( User.id.in_(list(map(lambda x: x.user, staff)))).all())) if staff else [] quests = data_session.query(Quests).filter(Quests.project == current_project.id).all() @@ -685,7 +687,7 @@ def profile(): user = data_session.query(User).filter(User.id == current_user.id).first() if not user: return render_template('profile.html', title='Профиль', form=form, - message='Ошибка, пользователь ненайден', user=current_user) + message='Ошибка, пользователь ненайден', user=current_user, admin=False) os.remove(current_user.photo) user.photo = 'static/images/none_logo.png' data_session.commit() @@ -693,7 +695,7 @@ def profile(): user = data_session.query(User).filter(User.id == current_user.id).first() if not user: return render_template('profile.html', title='Профиль', form=form, - message='Ошибка, пользователь ненайден', user=current_user) + message='Ошибка, пользователь ненайден', user=current_user, admin=False) if form.email.data != current_user.email: token = s.dumps(form.email.data) link_conf = url_for('confirmation', token=token, _external=True) @@ -711,7 +713,7 @@ def profile(): user.birthday = form.birthday.data data_session.commit() return redirect('/profile') - return render_template('profile.html', title='Профиль', form=form, message='', user=current_user) + return render_template('profile.html', title='Профиль', form=form, message='', user=current_user, admin=False) else: return redirect('/login') diff --git a/requirements.txt b/requirements.txt index 9a2be68..a11b276 100644 Binary files a/requirements.txt and b/requirements.txt differ diff --git a/static/css/profile.css b/static/css/profile.css index 56b2f2a..36d0584 100644 --- a/static/css/profile.css +++ b/static/css/profile.css @@ -92,6 +92,10 @@ form { vertical-align: middle; font-size: 1.5vw; } +.profile_button:hover { + color: #ffffff; + text-decoration: none; +} #delete_button { margin-top: 45px; } @@ -166,4 +170,7 @@ form { } .about { border-radius: 2vw !important; +} +.profile_button_text { + color: #ffffff; } \ No newline at end of file diff --git a/static/css/user_view.css b/static/css/user_view.css index 26b3449..5bead1e 100644 --- a/static/css/user_view.css +++ b/static/css/user_view.css @@ -217,4 +217,47 @@ } .link_to_user:hover { text-decoration: none; +} +.open_project_block { + width: 20%; + height: 90%; + display: flex; + align-items: center; + justify-content: center; + flex-direction: column; + flex-wrap: nowrap; +} +.open_button { + background-color: #ffffff; + color: #000000; + width: 15vw; + height: 4.5vw; + vertical-align: middle; + border-radius: 5vw; + display: flex; + align-items: center; + justify-content: center; +} +.open_button:hover { + text-decoration: none; + color: #000000; +} +.open_button_text { + font-size: 1.5vw; + margin-top: 15px; + display: flex; + align-items: center; + justify-content: center; +} +.open_button, .open_button_link { + display: flex; + align-items: center; + justify-content: center; + width: 15vw; + height: 4.5vw; + color: #000000; +} +.open_button_link:hover { + text-decoration: none; + color: #000000; } \ No newline at end of file diff --git a/templates/profile.html b/templates/profile.html index 38d4e9a..497bced 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -77,11 +77,19 @@
diff --git a/templates/project.html b/templates/project.html index 261dd93..9f0cb54 100644 --- a/templates/project.html +++ b/templates/project.html @@ -8,7 +8,7 @@