From 5a4e848ab0003b0551627ba191d750bc0196d306 Mon Sep 17 00:00:00 2001 From: ASlugin Date: Fri, 29 Sep 2023 23:02:19 +0300 Subject: [PATCH 1/6] Fix choosing only stil working supervisor --- src/flask_se_practice.py | 28 ++++++++++--------- .../practice/student/preparation.html | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/flask_se_practice.py b/src/flask_se_practice.py index 6e721c5d..d76c0e8f 100644 --- a/src/flask_se_practice.py +++ b/src/flask_se_practice.py @@ -110,7 +110,7 @@ def practice_index(): return render_template( PracticeStudentTemplates.MAIN.value, - thesises=get_list_of_thesises(), + thesises=get_list_of_theses(), notifications=notifications, notifications_not_viewed=notifications_not_viewed, type_notifications=type_notifications, @@ -120,7 +120,7 @@ def practice_index(): @login_required def practice_guide(): return render_template( - PracticeStudentTemplates.GUIDE.value, thesises=get_list_of_thesises() + PracticeStudentTemplates.GUIDE.value, thesises=get_list_of_theses() ) @@ -153,7 +153,7 @@ def practice_new_thesis(): return render_template( PracticeStudentTemplates.NEW_PRACTICE.value, - thesises=get_list_of_thesises(), + thesises=get_list_of_theses(), user=current_user, review_filter=form, form=form, @@ -207,6 +207,7 @@ def practice_choosing_topic(current_thesis): form.staff.choices.append((0, "Выберите научного руководителя")) for supervisor in ( Staff.query.join(Users, Staff.user_id == Users.id) + .filter(Staff.still_working) .order_by(asc(Users.last_name)) .all() ): @@ -214,7 +215,7 @@ def practice_choosing_topic(current_thesis): return render_template( PracticeStudentTemplates.CHOOSING_TOPIC.value, - thesises=get_list_of_thesises(), + thesises=get_list_of_theses(), form=form, practice=current_thesis, deadline=deadline, @@ -263,6 +264,7 @@ def practice_edit_theme(current_thesis): for supervisor in ( Staff.query.join(Users, Staff.user_id == Users.id) .filter(Staff.id != current_thesis.supervisor_id) + .filter(Staff.still_working) .order_by(asc(Users.last_name)) .all() ): @@ -270,7 +272,7 @@ def practice_edit_theme(current_thesis): return render_template( PracticeStudentTemplates.EDIT_TOPIC.value, - thesises=get_list_of_thesises(), + thesises=get_list_of_theses(), form=form, practice=current_thesis, ) @@ -352,7 +354,7 @@ def practice_goals_tasks(current_thesis): return render_template( PracticeStudentTemplates.GOALS_TASKS.value, - thesises=get_list_of_thesises(), + thesises=get_list_of_theses(), practice=current_thesis, ) @@ -376,7 +378,7 @@ def practice_workflow(current_thesis): ) return render_template( PracticeStudentTemplates.WORKFLOW.value, - thesises=get_list_of_thesises(), + thesises=get_list_of_theses(), practice=current_thesis, reports=reports, ) @@ -431,7 +433,7 @@ def practice_add_new_report(current_thesis): add_thesis_report_form = UserAddReport() return render_template( PracticeStudentTemplates.NEW_REPORT.value, - thesises=get_list_of_thesises(), + thesises=get_list_of_theses(), practice=current_thesis, form=add_thesis_report_form, user=current_user, @@ -668,7 +670,7 @@ def practice_preparation(current_thesis): elif "delete_reviewer_review_button" in request.form: current_thesis.reviewer_review_uri = None db.session.commit() - elif "delete_supevisor_review_button" in request.form: + elif "delete_supervisor_review_button" in request.form: current_thesis.supervisor_review_uri = None db.session.commit() elif "delete_code_link_button" in request.form: @@ -686,7 +688,7 @@ def practice_preparation(current_thesis): return render_template( PracticeStudentTemplates.PREPARATION.value, - thesises=get_list_of_thesises(), + thesises=get_list_of_theses(), practice=current_thesis, deadline=deadline, remaining_time_submit=get_remaining_time(deadline, "submit_work_for_review"), @@ -699,7 +701,7 @@ def practice_preparation(current_thesis): def practice_thesis_defense(current_thesis): return render_template( PracticeStudentTemplates.DEFENSE.value, - thesises=get_list_of_thesises(), + thesises=get_list_of_theses(), practice=current_thesis, ) @@ -747,14 +749,14 @@ def practice_data_for_practice(current_thesis): return render_template( PracticeStudentTemplates.SETTINGS.value, - thesises=get_list_of_thesises(), + thesises=get_list_of_theses(), user=current_user, form=form, practice=current_thesis, ) -def get_list_of_thesises() -> List[CurrentThesis]: +def get_list_of_theses() -> List[CurrentThesis]: return [thesis for thesis in current_user.current_thesises if not thesis.deleted] diff --git a/src/templates/practice/student/preparation.html b/src/templates/practice/student/preparation.html index f29e8e66..b7d41bcd 100644 --- a/src/templates/practice/student/preparation.html +++ b/src/templates/practice/student/preparation.html @@ -212,7 +212,7 @@ From 91bc9cde3081cc45deec4bb88856b88437038678 Mon Sep 17 00:00:00 2001 From: ASlugin Date: Fri, 29 Sep 2023 23:11:37 +0300 Subject: [PATCH 2/6] Fix sending notification to supervisor --- src/flask_se_practice.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/flask_se_practice.py b/src/flask_se_practice.py index d76c0e8f..c5657656 100644 --- a/src/flask_se_practice.py +++ b/src/flask_se_practice.py @@ -177,8 +177,12 @@ def practice_choosing_topic(current_thesis): current_thesis.title = topic current_thesis.supervisor_id = supervisor_id db.session.commit() + + supervisor_user_id = ( + Staff.query.filter_by(id=supervisor_id).first().user_id + ) add_mail_notification( - supervisor_id, + supervisor_user_id, "Добавлена новая учебная практика/ВКР", render_template( NotificationTemplates.NEW_PRACTICE_TO_SUPERVISOR.value, @@ -242,8 +246,11 @@ def practice_edit_theme(current_thesis): current_thesis.title = topic current_thesis.consultant = consultant if current_thesis.supervisor_id != supervisor_id: + supervisor_user_id = ( + Staff.query.filter_by(id=supervisor_id).first().user_id + ) add_mail_notification( - supervisor_id, + supervisor_user_id, "Добавлена новая учебная практика/ВКР", render_template( NotificationTemplates.NEW_PRACTICE_TO_SUPERVISOR.value, @@ -417,8 +424,12 @@ def practice_add_new_report(current_thesis): ) db.session.add(new_report) db.session.commit() + + supervisor_user_id = ( + Staff.query.filter_by(id=current_thesis.supervisor_id).first().user_id + ) add_mail_notification( - current_thesis.supervisor_id, + supervisor_user_id, "Новый отчёт по учебной практике", render_template( NotificationTemplates.NEW_REPORT_TO_SUPERVISOR.value, From 02db80e6fd3a84ae431555934152984c7f7ae0f8 Mon Sep 17 00:00:00 2001 From: ASlugin Date: Fri, 29 Sep 2023 23:20:47 +0300 Subject: [PATCH 3/6] Fix nooffer page and remove .html from route --- src/flask_se.py | 4 ++-- src/templates/nooffer.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/flask_se.py b/src/flask_se.py index 18c247ff..4a5c3146 100644 --- a/src/flask_se.py +++ b/src/flask_se.py @@ -657,7 +657,7 @@ def frequently_asked_questions(): return render_template("frequently_asked_questions.html") -@app.route("/nooffer.html") +@app.route("/nooffer") def nooffer(): return render_template("nooffer.html") @@ -680,7 +680,7 @@ def sitemap(): """Generate sitemap.xml. Makes a list of urls and date modified.""" pages = [] skip_pages = [ - "/nooffer.html", + "/nooffer", "/fetch_theses", "/Sitemap.xml", "/sitemap.xml", diff --git a/src/templates/nooffer.html b/src/templates/nooffer.html index 99482b5d..eb752f19 100644 --- a/src/templates/nooffer.html +++ b/src/templates/nooffer.html @@ -6,7 +6,7 @@
-
+
From eee71adebdee4e1ca3d3b48b029e6a8cde6b5285 Mon Sep 17 00:00:00 2001 From: ASlugin Date: Sat, 30 Sep 2023 00:06:04 +0300 Subject: [PATCH 4/6] Add ability to edit title of review themes --- src/flask_se_admin.py | 8 +++++--- src/flask_se_practice_admin.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/flask_se_admin.py b/src/flask_se_admin.py index c3d1cc00..d45b757e 100644 --- a/src/flask_se_admin.py +++ b/src/flask_se_admin.py @@ -17,6 +17,8 @@ # Base model view with access and inaccess methods class SeAdminModelView(ModelView): + can_set_page_size = True + def is_accessible(self): if current_user.is_authenticated: if current_user.role >= ADMIN_ROLE_LEVEL: @@ -230,10 +232,10 @@ class SeAdminModelViewReviewDiplomaThemes(SeAdminModelViewReviewer): "rows": 10, "style": "width: 100%;", }, - "requirements": {"rows": 3, "style": "width: 100%;", "readonly": True}, - "title": {"readonly": True}, + "requirements": {"rows": 3, "style": "width: 100%;"}, + "title": {"readonly": False}, "level": {"disabled": True}, - "company": {"disabled": True}, + "company": {"disabled": False}, "author": {"readonly": True}, "comment": { "rows": 5, diff --git a/src/flask_se_practice_admin.py b/src/flask_se_practice_admin.py index b2a54852..d4cd6a92 100644 --- a/src/flask_se_practice_admin.py +++ b/src/flask_se_practice_admin.py @@ -472,7 +472,7 @@ def archive_thesis(): add_mail_notification( current_thesis.author_id, - "[SE site] Ваша работы перенесена в архив практик и ВКР", + "[SE site] Ваша работа перенесена в архив практик и ВКР", render_template( NotificationTemplates.THESIS_WAS_ARCHIVED_BY_ADMIN.value, curator=current_user, From 5841293e3cc90602c3d3e2573bc4555ba0d44944 Mon Sep 17 00:00:00 2001 From: ASlugin Date: Sat, 30 Sep 2023 15:44:34 +0300 Subject: [PATCH 5/6] Add thesis and msearch folders to gitignore --- .gitignore | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index c5911ee7..c7b88fd1 100644 --- a/.gitignore +++ b/.gitignore @@ -99,6 +99,8 @@ flask_se_practice_yandex_secret.conf **/__pycache__/ # Do not track documents for thesises -src/static/practice/reviews/*.pdf -src/static/practice/slides/*.pdf -src/static/practice/texts/*.pdf +src/static/practice/*/*.pdf +src/static/thesis/*/*.pdf + +# Do not track fulltext search files +src/msearch/* \ No newline at end of file From 1288f1def9de105f1e840b4b54dd0eb258cef0ae Mon Sep 17 00:00:00 2001 From: ASlugin Date: Sun, 1 Oct 2023 17:44:12 +0300 Subject: [PATCH 6/6] Fix staff and thesis page in admin panel --- src/flask_se_admin.py | 59 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 9 deletions(-) diff --git a/src/flask_se_admin.py b/src/flask_se_admin.py index d45b757e..69c9c59b 100644 --- a/src/flask_se_admin.py +++ b/src/flask_se_admin.py @@ -3,12 +3,12 @@ from flask import redirect, url_for from flask_admin import AdminIndexView, expose from flask_admin.contrib.sqla import ModelView +from flask_admin.contrib.sqla.fields import QuerySelectField from flask_login import current_user - from wtforms import TextAreaField, SelectField from flask_se_config import SECRET_KEY_THESIS -from se_models import db +from se_models import db, Users, Staff, Worktype, Courses, AreasOfStudy ADMIN_ROLE_LEVEL = 5 REVIEW_ROLE_LEVEL = 3 @@ -31,8 +31,46 @@ def inaccessible_callback(self, name, **kwargs): class SeAdminModelViewThesis(SeAdminModelView): - column_exclude_list = ["text"] - pass + column_list = ( + "name_ru", + "name_en", + "author", + "supervisor", + "publish_year", + "recomended", + "temporary", + "review_status", + "download_thesis", + "download_presentation", + ) + form_extra_fields = { + "supervisor": QuerySelectField( + "Научный руководитель", + query_factory=lambda: Staff.query.all(), + get_pk=lambda staff: staff.id, + ), + "owner": QuerySelectField( + "Author user", + query_factory=lambda: Users.query.all(), + get_pk=lambda user: user.id, + ), + "type": QuerySelectField( + "Тип работы", + query_factory=lambda: Worktype.query.all(), + get_pk=lambda t: t.id, + ), + "course": QuerySelectField( + "Курс", + query_factory=lambda: Courses.query.all(), + get_label=lambda c: c.name, + get_pk=lambda c: c.id, + ), + "area": QuerySelectField( + "Направление обучения", + query_factory=lambda: AreasOfStudy.query.all(), + get_pk=lambda c: c.id, + ), + } class SeAdminModelViewReviewer(ModelView): @@ -131,7 +169,7 @@ class SeAdminModelViewStaff(SeAdminModelView): "still_working", ) form_columns = ( - "user_id", + "user", "official_email", "position", "science_degree", @@ -146,8 +184,13 @@ class SeAdminModelViewStaff(SeAdminModelView): ("к.т.н.", "к.т.н."), ] } - - pass + form_extra_fields = { + "user": QuerySelectField( + "User", + query_factory=lambda: Users.query.all(), + get_pk=lambda user: user.id, + ) + } class SeAdminModelViewNews(SeAdminModelView): @@ -272,5 +315,3 @@ class SeAdminModelViewCurrentThesis(SeAdminModelView): status="Статус", ) column_choices = {"status": [(1, "Текущая работа"), (2, "Завершенная работа")]} - - pass