mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-04 22:40:30 +00:00
Compare commits
6 commits
788d47c8c7
...
3b8f114788
Author | SHA1 | Date | |
---|---|---|---|
3b8f114788 | |||
900049d410 | |||
7f3797719d | |||
dd91e12fba | |||
694b07c11e | |||
74b3096ba0 |
5 changed files with 29 additions and 38 deletions
|
@ -1,13 +0,0 @@
|
||||||
# Do not share the secret key or the password salt!
|
|
||||||
# These secrets can be generated using the script at
|
|
||||||
# advlabdb/scripts/setup/generate_secrets.py
|
|
||||||
SECRET_KEY=
|
|
||||||
SECURITY_PASSWORD_SALT=
|
|
||||||
|
|
||||||
# Server URL
|
|
||||||
SERVER_NAME=
|
|
||||||
|
|
||||||
# Database
|
|
||||||
RELATIVE_DB_DIR=db
|
|
||||||
|
|
||||||
CHECK_EMAIL_DELIVERABILITY=True
|
|
|
@ -1061,11 +1061,8 @@ class AppointmentView(SecureAdminModelView):
|
||||||
def apply(self, query, value, alias=None):
|
def apply(self, query, value, alias=None):
|
||||||
experimentNumber, programId = ExperimentRowFilter.get_values(value)
|
experimentNumber, programId = ExperimentRowFilter.get_values(value)
|
||||||
|
|
||||||
return (
|
return query.join(Experiment).where(
|
||||||
query.join(GroupExperiment)
|
Experiment.program_id == programId, Experiment.number == experimentNumber
|
||||||
.join(SemesterExperiment)
|
|
||||||
.join(Experiment)
|
|
||||||
.where(Experiment.program_id == programId, Experiment.number == experimentNumber)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
class AssistantFilter(AssistantRowFilter):
|
class AssistantFilter(AssistantRowFilter):
|
||||||
|
@ -1158,11 +1155,8 @@ class ExperimentMarkView(SecureAdminModelView):
|
||||||
def apply(self, query, value, alias=None):
|
def apply(self, query, value, alias=None):
|
||||||
experimentNumber, programId = ExperimentRowFilter.get_values(value)
|
experimentNumber, programId = ExperimentRowFilter.get_values(value)
|
||||||
|
|
||||||
return (
|
return query.join(Experiment).where(
|
||||||
query.join(GroupExperiment)
|
Experiment.program_id == programId, Experiment.number == experimentNumber
|
||||||
.join(SemesterExperiment)
|
|
||||||
.join(Experiment)
|
|
||||||
.where(Experiment.program_id == programId, Experiment.number == experimentNumber)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
class ProgramFilter(ProgramRowFilter):
|
class ProgramFilter(ProgramRowFilter):
|
||||||
|
|
|
@ -113,7 +113,7 @@ class PartStudent(db.Model):
|
||||||
Return True if final_part_mark changed, False otherwise.
|
Return True if final_part_mark changed, False otherwise.
|
||||||
"""
|
"""
|
||||||
finalWeightingSum = 0
|
finalWeightingSum = 0
|
||||||
finalMark = 0
|
finalMarkSum = 0
|
||||||
groupExperiments = []
|
groupExperiments = []
|
||||||
|
|
||||||
for experimentMark in self.experiment_marks:
|
for experimentMark in self.experiment_marks:
|
||||||
|
@ -138,7 +138,11 @@ class PartStudent(db.Model):
|
||||||
finalWeighting = semesterExperiment.final_weighting
|
finalWeighting = semesterExperiment.final_weighting
|
||||||
finalWeightingSum += finalWeighting
|
finalWeightingSum += finalWeighting
|
||||||
|
|
||||||
finalMark += finalWeighting * experimentMark.final_experiment_mark
|
# Not using final_experiment_mark to avoid rounding two times
|
||||||
|
finalMarkSum += finalWeighting * (
|
||||||
|
semesterExperiment.protocol_weighting * experimentMark.protocol_mark
|
||||||
|
+ semesterExperiment.oral_weighting * experimentMark.oral_mark
|
||||||
|
)
|
||||||
|
|
||||||
if set(groupExperiments) != set(self.group.group_experiments):
|
if set(groupExperiments) != set(self.group.group_experiments):
|
||||||
flash(f"{self} does not have an experiment mark for every group experiment in his group!", "warning")
|
flash(f"{self} does not have an experiment mark for every group experiment in his group!", "warning")
|
||||||
|
@ -147,7 +151,7 @@ class PartStudent(db.Model):
|
||||||
oldFinalPartMark = self.final_part_mark
|
oldFinalPartMark = self.final_part_mark
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.final_part_mark = roundHalfUpToInt(finalMark / finalWeightingSum)
|
self.final_part_mark = roundHalfUpToInt(finalMarkSum / finalWeightingSum)
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
|
|
@ -11,7 +11,7 @@ from pathlib import Path
|
||||||
# Volumes
|
# Volumes
|
||||||
VOLUMES_DIR = Path.home() / "volumes"
|
VOLUMES_DIR = Path.home() / "volumes"
|
||||||
# AdvLabDB
|
# AdvLabDB
|
||||||
ADVLABDB_REPO_LINK = "https://gitlab.rlp.net/mobitar/advlabdb.git"
|
ADVLABDB_REPO_LINK = "https://codeberg.org/Mo8it/AdvLabDB.git"
|
||||||
ADVLABDB_VOLUMES_DIR = VOLUMES_DIR / "advlabdb"
|
ADVLABDB_VOLUMES_DIR = VOLUMES_DIR / "advlabdb"
|
||||||
ADVLABDB_REPO_DIR = ADVLABDB_VOLUMES_DIR / "repo"
|
ADVLABDB_REPO_DIR = ADVLABDB_VOLUMES_DIR / "repo"
|
||||||
ADVLABDB_LOGS_DIR = ADVLABDB_VOLUMES_DIR / "logs"
|
ADVLABDB_LOGS_DIR = ADVLABDB_VOLUMES_DIR / "logs"
|
||||||
|
@ -179,6 +179,21 @@ def create_nginx_container():
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Needed for main and create_advlabdb_container
|
||||||
|
advlabdb_container_args = f"""--network {args.network} \
|
||||||
|
-e ADVLABDB_DATA_DIR=/volumes/data \
|
||||||
|
-v {ADVLABDB_REPO_DIR}:/volumes/repo:Z \
|
||||||
|
-v {ADVLABDB_DATA_DIR}:/volumes/data:Z \
|
||||||
|
-v {ADVLABDB_LOGS_DIR}:/volumes/logs:Z"""
|
||||||
|
|
||||||
|
|
||||||
|
def create_advlabdb_container():
|
||||||
|
create_container(
|
||||||
|
"advlabdb",
|
||||||
|
f"{advlabdb_container_args} localhost/advlabdb:latest",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
pull_or_clone_repo()
|
pull_or_clone_repo()
|
||||||
|
|
||||||
|
@ -240,14 +255,8 @@ def main():
|
||||||
print(f"Making sure that the logs directory {ADVLABDB_LOGS_DIR} exists.")
|
print(f"Making sure that the logs directory {ADVLABDB_LOGS_DIR} exists.")
|
||||||
ADVLABDB_LOGS_DIR.mkdir(parents=True, exist_ok=True)
|
ADVLABDB_LOGS_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
container_args = f"""--network {args.network} \
|
|
||||||
-e ADVLABDB_DATA_DIR=/volumes/data \
|
|
||||||
-v {ADVLABDB_REPO_DIR}:/volumes/repo:Z \
|
|
||||||
-v {ADVLABDB_DATA_DIR}:/volumes/data:Z \
|
|
||||||
-v {ADVLABDB_LOGS_DIR}:/volumes/logs:Z"""
|
|
||||||
|
|
||||||
# Running setup commands (if needed)
|
# Running setup commands (if needed)
|
||||||
run_manage = f"podman run -it --rm {container_args} localhost/advlabdb:latest python3 manage.py"
|
run_manage = f"podman run -it --rm {advlabdb_container_args} localhost/advlabdb:latest python3 manage.py"
|
||||||
commands = (
|
commands = (
|
||||||
# Generate secret keys if secrets.ini does not exist yet
|
# Generate secret keys if secrets.ini does not exist yet
|
||||||
f"{run_manage} setup generate-secrets",
|
f"{run_manage} setup generate-secrets",
|
||||||
|
@ -258,10 +267,7 @@ def main():
|
||||||
for command in commands:
|
for command in commands:
|
||||||
run(command, check=True)
|
run(command, check=True)
|
||||||
|
|
||||||
create_container(
|
create_advlabdb_container()
|
||||||
"advlabdb",
|
|
||||||
f"{container_args} localhost/advlabdb:latest",
|
|
||||||
)
|
|
||||||
|
|
||||||
# Create Traefik container if needed
|
# Create Traefik container if needed
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue