1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-22 13:04:19 +00:00

Fixed conditions evaluation mode defaulting to '0' instead of ConditionMode.all_or.

This commit is contained in:
Lorenzo Balugani 2021-05-10 16:25:34 +02:00
parent 0b9b5e301a
commit da2a7b9e8b
3 changed files with 4 additions and 4 deletions

View file

@ -15,7 +15,7 @@ class Repository(ext.Model):
start = ext.Column(ext.DateTime, nullable=True) start = ext.Column(ext.DateTime, nullable=True)
end = ext.Column(ext.DateTime, nullable=True) end = ext.Column(ext.DateTime, nullable=True)
is_active = ext.Column(ext.Boolean, nullable=False, default=False) 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 # Foreign Keys
owner_id = ext.Column(ext.String, ext.ForeignKey("user.email", ondelete="CASCADE"), nullable=False) 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, "is_active": self.is_active,
"end": self.end.isoformat() if self.end else None, "end": self.end.isoformat() if self.end else None,
"owner": self.owner.to_json(), "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] "conditions": [c.to_json() for c in self.conditions]
} }

View file

@ -12,4 +12,4 @@ from .Notification import Notification
from .Repository import Repository from .Repository import Repository
from .Tweet import Tweet from .Tweet import Tweet
from .User import User from .User import User
from .Enums import ConditionType, OperationType from .Enums import ConditionType, OperationType, ConditionMode

View file

@ -170,7 +170,7 @@ def page_repository(rid):
repository.is_active = True repository.is_active = True
if 'evaluation_mode' in request.json: if 'evaluation_mode' in request.json:
try: try:
evaluation_mode = ConditionType(request.json['evaluation_mode']) evaluation_mode = ConditionMode(request.json['evaluation_mode'])
except KeyError: except KeyError:
return json_error("Unknown `type` specified."), 400 return json_error("Unknown `type` specified."), 400
repository.evaluation_mode = evaluation_mode repository.evaluation_mode = evaluation_mode