1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-12-02 22:33:05 +00:00

Compare commits

...

6 commits

Author SHA1 Message Date
3b8f114788 Create create_advlabdb_container 2022-08-18 19:05:00 +02:00
900049d410 Do not join again after query_modifier joins 2022-08-18 18:58:30 +02:00
7f3797719d Avoid rounding two times 2022-08-18 17:39:40 +02:00
dd91e12fba Remove .env.template 2022-08-18 17:25:56 +02:00
694b07c11e Move settings example 2022-08-18 17:25:46 +02:00
74b3096ba0 Change main repo link 2022-08-18 16:46:10 +02:00
5 changed files with 29 additions and 38 deletions

View file

@ -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

View file

@ -1061,11 +1061,8 @@ class AppointmentView(SecureAdminModelView):
def apply(self, query, value, alias=None):
experimentNumber, programId = ExperimentRowFilter.get_values(value)
return (
query.join(GroupExperiment)
.join(SemesterExperiment)
.join(Experiment)
.where(Experiment.program_id == programId, Experiment.number == experimentNumber)
return query.join(Experiment).where(
Experiment.program_id == programId, Experiment.number == experimentNumber
)
class AssistantFilter(AssistantRowFilter):
@ -1158,11 +1155,8 @@ class ExperimentMarkView(SecureAdminModelView):
def apply(self, query, value, alias=None):
experimentNumber, programId = ExperimentRowFilter.get_values(value)
return (
query.join(GroupExperiment)
.join(SemesterExperiment)
.join(Experiment)
.where(Experiment.program_id == programId, Experiment.number == experimentNumber)
return query.join(Experiment).where(
Experiment.program_id == programId, Experiment.number == experimentNumber
)
class ProgramFilter(ProgramRowFilter):

View file

@ -113,7 +113,7 @@ class PartStudent(db.Model):
Return True if final_part_mark changed, False otherwise.
"""
finalWeightingSum = 0
finalMark = 0
finalMarkSum = 0
groupExperiments = []
for experimentMark in self.experiment_marks:
@ -138,7 +138,11 @@ class PartStudent(db.Model):
finalWeighting = semesterExperiment.final_weighting
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):
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
try:
self.final_part_mark = roundHalfUpToInt(finalMark / finalWeightingSum)
self.final_part_mark = roundHalfUpToInt(finalMarkSum / finalWeightingSum)
db.session.commit()
except Exception as ex:

View file

@ -11,7 +11,7 @@ from pathlib import Path
# Volumes
VOLUMES_DIR = Path.home() / "volumes"
# 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_REPO_DIR = ADVLABDB_VOLUMES_DIR / "repo"
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():
pull_or_clone_repo()
@ -240,14 +255,8 @@ def main():
print(f"Making sure that the logs directory {ADVLABDB_LOGS_DIR} exists.")
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)
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 = (
# Generate secret keys if secrets.ini does not exist yet
f"{run_manage} setup generate-secrets",
@ -258,10 +267,7 @@ def main():
for command in commands:
run(command, check=True)
create_container(
"advlabdb",
f"{container_args} localhost/advlabdb:latest",
)
create_advlabdb_container()
# Create Traefik container if needed