mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Apply str instead of repr
This commit is contained in:
parent
ecad30eb79
commit
2da2a67b94
3 changed files with 17 additions and 19 deletions
|
@ -73,7 +73,7 @@ class SemesterRowFilter(FilterEqual):
|
||||||
return tuple()
|
return tuple()
|
||||||
|
|
||||||
semesters = Semester.sortedSemestersStartingWithNewest()
|
semesters = Semester.sortedSemestersStartingWithNewest()
|
||||||
return tuple((semester.id, semester.repr()) for semester in semesters)
|
return tuple((semester.id, str(semester)) for semester in semesters)
|
||||||
|
|
||||||
|
|
||||||
class UserView(SecureAdminModelView):
|
class UserView(SecureAdminModelView):
|
||||||
|
@ -327,7 +327,7 @@ class SemesterView(SecureAdminModelView):
|
||||||
def addMenuLink(space, newSemester):
|
def addMenuLink(space, newSemester):
|
||||||
categoryText = "Active semester"
|
categoryText = "Active semester"
|
||||||
link = MenuLink(
|
link = MenuLink(
|
||||||
name=newSemester.repr(),
|
name=str(newSemester),
|
||||||
url=url_for("set_semester") + "?semester_id=" + str(newSemester.id),
|
url=url_for("set_semester") + "?semester_id=" + str(newSemester.id),
|
||||||
category=categoryText,
|
category=categoryText,
|
||||||
)
|
)
|
||||||
|
@ -447,7 +447,7 @@ class PartRowFilter(FilterEqual):
|
||||||
return tuple()
|
return tuple()
|
||||||
|
|
||||||
parts = db.session.execute(select(Part).where(Part.semester == current_user.active_semester)).scalars()
|
parts = db.session.execute(select(Part).where(Part.semester == current_user.active_semester)).scalars()
|
||||||
return tuple((part.id, f"{part.program.repr()}{part.number}") for part in parts)
|
return tuple((part.id, part.str_without_semester()) for part in parts)
|
||||||
|
|
||||||
|
|
||||||
class PartStudentView(SecureAdminModelView):
|
class PartStudentView(SecureAdminModelView):
|
||||||
|
@ -543,7 +543,7 @@ class ProgramRowFilter(FilterEqual):
|
||||||
return tuple()
|
return tuple()
|
||||||
|
|
||||||
programs = db.session.execute(select(Program)).scalars()
|
programs = db.session.execute(select(Program)).scalars()
|
||||||
return tuple((program.id, program.repr()) for program in programs)
|
return tuple((program.id, str(program)) for program in programs)
|
||||||
|
|
||||||
|
|
||||||
class GroupView(SecureAdminModelView):
|
class GroupView(SecureAdminModelView):
|
||||||
|
@ -801,8 +801,7 @@ class AssistantView(SecureAdminModelView):
|
||||||
can_view_details = True
|
can_view_details = True
|
||||||
|
|
||||||
column_list = [
|
column_list = [
|
||||||
"user.first_name",
|
"user",
|
||||||
"user.last_name",
|
|
||||||
"semester_experiments",
|
"semester_experiments",
|
||||||
]
|
]
|
||||||
column_details_list = column_list + [
|
column_details_list = column_list + [
|
||||||
|
@ -864,8 +863,7 @@ class AdminView(SecureAdminModelView):
|
||||||
can_delete = False
|
can_delete = False
|
||||||
|
|
||||||
column_list = [
|
column_list = [
|
||||||
"user.first_name",
|
"user",
|
||||||
"user.last_name",
|
|
||||||
]
|
]
|
||||||
column_filters = (
|
column_filters = (
|
||||||
userHasRoleFilterFactory(Admin, "admin"),
|
userHasRoleFilterFactory(Admin, "admin"),
|
||||||
|
@ -893,7 +891,7 @@ class ExperimentRowFilter(FilterEqual):
|
||||||
return tuple(
|
return tuple(
|
||||||
(
|
(
|
||||||
f"{activeExperiment.number},{activeExperiment.program_id}",
|
f"{activeExperiment.number},{activeExperiment.program_id}",
|
||||||
f"{activeExperiment.number} {activeExperiment.program.repr()}",
|
f"{activeExperiment.number} {activeExperiment.program}",
|
||||||
)
|
)
|
||||||
for activeExperiment in activeExperiments
|
for activeExperiment in activeExperiments
|
||||||
)
|
)
|
||||||
|
@ -1032,7 +1030,7 @@ class AssistantRowFilter(FilterEqual):
|
||||||
return tuple()
|
return tuple()
|
||||||
|
|
||||||
activeAssistants = assistantQueryFactory()
|
activeAssistants = assistantQueryFactory()
|
||||||
return tuple((assistant.id, assistant.repr()) for assistant in activeAssistants)
|
return tuple((assistant.id, str(assistant)) for assistant in activeAssistants)
|
||||||
|
|
||||||
|
|
||||||
class AppointmentView(SecureAdminModelView):
|
class AppointmentView(SecureAdminModelView):
|
||||||
|
@ -1166,7 +1164,7 @@ class ExperimentMarkView(SecureAdminModelView):
|
||||||
return tuple()
|
return tuple()
|
||||||
|
|
||||||
admins = db.session.execute(select(Admin).join(User).where(User.active == True)).scalars()
|
admins = db.session.execute(select(Admin).join(User).where(User.active == True)).scalars()
|
||||||
return tuple((admin.id, admin.repr()) for admin in admins)
|
return tuple((admin.id, str(admin)) for admin in admins)
|
||||||
|
|
||||||
def apply(self, query, value, alias=None):
|
def apply(self, query, value, alias=None):
|
||||||
return query.where(ExperimentMark.admin_id == int(value))
|
return query.where(ExperimentMark.admin_id == int(value))
|
||||||
|
@ -1440,7 +1438,7 @@ class AnalysisView(SecureAdminBaseView):
|
||||||
hists = [
|
hists = [
|
||||||
AnalysisView.markHist(
|
AnalysisView.markHist(
|
||||||
data=marks[i],
|
data=marks[i],
|
||||||
title=activeAssistants[i].repr() + markTypeTitleAddition,
|
title=str(activeAssistants[i]) + markTypeTitleAddition,
|
||||||
)
|
)
|
||||||
for i in range(len(marks))
|
for i in range(len(marks))
|
||||||
]
|
]
|
||||||
|
@ -1486,13 +1484,13 @@ class AnalysisView(SecureAdminBaseView):
|
||||||
activeSemesterFinalPartMarksHists = [
|
activeSemesterFinalPartMarksHists = [
|
||||||
AnalysisView.markHist(
|
AnalysisView.markHist(
|
||||||
data=AnalysisView.get_final_part_marks(part),
|
data=AnalysisView.get_final_part_marks(part),
|
||||||
title=part.repr(),
|
title=str(part),
|
||||||
)
|
)
|
||||||
for part in parts
|
for part in parts
|
||||||
]
|
]
|
||||||
|
|
||||||
semesters = Semester.sortedSemestersStartingWithNewest()
|
semesters = Semester.sortedSemestersStartingWithNewest()
|
||||||
semesterLabels = [semester.repr() for semester in semesters]
|
semesterLabels = [str(semester) for semester in semesters]
|
||||||
meanFinalPartMarks = np.flip(
|
meanFinalPartMarks = np.flip(
|
||||||
[
|
[
|
||||||
np.mean(
|
np.mean(
|
||||||
|
|
|
@ -251,7 +251,7 @@ def importFromFile(filePath):
|
||||||
if dbExperiment is None:
|
if dbExperiment is None:
|
||||||
# TODO: Check if experimentProgram is None
|
# TODO: Check if experimentProgram is None
|
||||||
raise DataBaseImportException(
|
raise DataBaseImportException(
|
||||||
f"Experiment with number {experimentNumber} and program {experimentProgram.repr()} does not exist in the database. Please make sure that experiments are created from the web interface."
|
f"Experiment with number {experimentNumber} and program {experimentProgram} does not exist in the database. Please make sure that experiments are created from the web interface."
|
||||||
)
|
)
|
||||||
|
|
||||||
dbSemesterExperiment = get_first(
|
dbSemesterExperiment = get_first(
|
||||||
|
@ -262,7 +262,7 @@ def importFromFile(filePath):
|
||||||
|
|
||||||
if dbSemesterExperiment is None:
|
if dbSemesterExperiment is None:
|
||||||
raise DataBaseImportException(
|
raise DataBaseImportException(
|
||||||
f"No semester experiment exists in the database to the experiment with number {experimentNumber} and program {experimentProgram.repr()}. Please make sure that semester experiments are created in the web interface. The problem might be that the experiment was not active while creating a new semester"
|
f"No semester experiment exists in the database to the experiment with number {experimentNumber} and program {experimentProgram}. Please make sure that semester experiments are created in the web interface. The problem might be that the experiment was not active while creating a new semester"
|
||||||
)
|
)
|
||||||
|
|
||||||
dbSemesterExperiments[id] = dbSemesterExperiment
|
dbSemesterExperiments[id] = dbSemesterExperiment
|
||||||
|
@ -302,7 +302,7 @@ def importFromFile(filePath):
|
||||||
db.session.add(dbAppointment)
|
db.session.add(dbAppointment)
|
||||||
|
|
||||||
# Backup
|
# Backup
|
||||||
dest = relative_db_bk_dir / f"before_{dbSemester.repr()}_import_{now()}.db"
|
dest = relative_db_bk_dir / f"before_{dbSemester}_import_{now()}.db"
|
||||||
copy2(relative_db_path, dest)
|
copy2(relative_db_path, dest)
|
||||||
|
|
||||||
show(f"Made a backup of the database before commiting the import at {dest}")
|
show(f"Made a backup of the database before commiting the import at {dest}")
|
||||||
|
@ -313,7 +313,7 @@ def importFromFile(filePath):
|
||||||
|
|
||||||
raise ex
|
raise ex
|
||||||
|
|
||||||
dest = relative_db_bk_dir / f"after_{dbSemester.repr()}_import_{now()}.db"
|
dest = relative_db_bk_dir / f"after_{dbSemester}_import_{now()}.db"
|
||||||
copy2(relative_db_path, dest)
|
copy2(relative_db_path, dest)
|
||||||
|
|
||||||
show(f"Made a backup of the database after the import at {dest}")
|
show(f"Made a backup of the database after the import at {dest}")
|
||||||
|
|
|
@ -16,7 +16,7 @@ def initActiveSemesterMenuLinks(space):
|
||||||
for semester in semesters:
|
for semester in semesters:
|
||||||
space.add_link(
|
space.add_link(
|
||||||
MenuLink(
|
MenuLink(
|
||||||
name=semester.repr(),
|
name=str(semester),
|
||||||
url=url_for("set_semester") + "?semester_id=" + str(semester.id),
|
url=url_for("set_semester") + "?semester_id=" + str(semester.id),
|
||||||
category="Active semester",
|
category="Active semester",
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue