From da2a7b9e8b3e16a8b79f64e68a7d36c43b4c8309 Mon Sep 17 00:00:00 2001 From: Lorenzo Balugani Date: Mon, 10 May 2021 16:25:34 +0200 Subject: [PATCH] Fixed conditions evaluation mode defaulting to '0' instead of ConditionMode.all_or. --- code/backend/nest_backend/database/tables/Repository.py | 4 ++-- code/backend/nest_backend/database/tables/__init__.py | 2 +- code/backend/nest_backend/routes/repository/repository.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/backend/nest_backend/database/tables/Repository.py b/code/backend/nest_backend/database/tables/Repository.py index 06a3410..a3e1803 100644 --- a/code/backend/nest_backend/database/tables/Repository.py +++ b/code/backend/nest_backend/database/tables/Repository.py @@ -15,7 +15,7 @@ class Repository(ext.Model): start = ext.Column(ext.DateTime, nullable=True) end = ext.Column(ext.DateTime, nullable=True) is_active = ext.Column(ext.Boolean, nullable=False, default=False) - evaluation_mode = ext.Column(ext.Enum(ConditionMode), default=ConditionMode.all_or.value) + evaluation_mode = ext.Column(ext.Enum(ConditionMode), default=ConditionMode.all_or) # Foreign Keys owner_id = ext.Column(ext.String, ext.ForeignKey("user.email", ondelete="CASCADE"), nullable=False) @@ -35,6 +35,6 @@ class Repository(ext.Model): "is_active": self.is_active, "end": self.end.isoformat() if self.end else None, "owner": self.owner.to_json(), - "evaluation_mode": self.evaluation_mode, + "evaluation_mode": self.evaluation_mode.value, "conditions": [c.to_json() for c in self.conditions] } diff --git a/code/backend/nest_backend/database/tables/__init__.py b/code/backend/nest_backend/database/tables/__init__.py index b078d41..c273139 100644 --- a/code/backend/nest_backend/database/tables/__init__.py +++ b/code/backend/nest_backend/database/tables/__init__.py @@ -12,4 +12,4 @@ from .Notification import Notification from .Repository import Repository from .Tweet import Tweet from .User import User -from .Enums import ConditionType, OperationType \ No newline at end of file +from .Enums import ConditionType, OperationType, ConditionMode \ No newline at end of file diff --git a/code/backend/nest_backend/routes/repository/repository.py b/code/backend/nest_backend/routes/repository/repository.py index f4b81a1..47c42d6 100644 --- a/code/backend/nest_backend/routes/repository/repository.py +++ b/code/backend/nest_backend/routes/repository/repository.py @@ -170,7 +170,7 @@ def page_repository(rid): repository.is_active = True if 'evaluation_mode' in request.json: try: - evaluation_mode = ConditionType(request.json['evaluation_mode']) + evaluation_mode = ConditionMode(request.json['evaluation_mode']) except KeyError: return json_error("Unknown `type` specified."), 400 repository.evaluation_mode = evaluation_mode