From ab82f9ae4dc9499fd9e4507515cafe72e5dc74be Mon Sep 17 00:00:00 2001 From: Samuel Gaist <samuel.gaist@idiap.ch> Date: Wed, 29 Aug 2018 15:20:17 +0200 Subject: [PATCH] [experiments][models] Refactor declaration handling Make it properties like for other models --- beat/web/experiments/models/experiment.py | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/beat/web/experiments/models/experiment.py b/beat/web/experiments/models/experiment.py index 60e589d7d..d09485e83 100755 --- a/beat/web/experiments/models/experiment.py +++ b/beat/web/experiments/models/experiment.py @@ -48,6 +48,9 @@ from ...common.models import get_contribution_declaration_filename from ...common.models import get_contribution_description_filename from ...common.models import get_description from ...common.models import set_description +from ...common.models import get_declaration +from ...common.models import set_declaration +from ...common.models import get_declaration_string from ...common import storage from ...common.exceptions import ShareError @@ -749,23 +752,9 @@ class Experiment(Shareable): #_____ Properties __________ - def set_declaration(self, value): - if isinstance(value, dict): - value = simplejson.dumps(value, indent=4, cls=NumpyJSONEncoder) - - storage.set_file_content(self, 'declaration_file', self.declaration_filename(), value) - - def get_declaration(self): - return simplejson.loads(storage.get_file_content(self, 'declaration_file')) - - declaration = property(get_declaration, set_declaration) - description = property(get_description, set_description) - - - @property - def declaration_string(self): - return storage.get_file_content(self, 'declaration_file') + declaration = property(get_declaration, set_declaration) + declaration_string = property(beat.web.common.models.get_declaration_string) def schedule(self): @@ -788,6 +777,6 @@ class Experiment(Shareable): author = username or self.author name = name or self.name xp, _, __ = Experiment.objects.create_experiment(author, - self.toolchain, name, self.get_declaration(), + self.toolchain, name, self.declaration, self.short_description, self.description) return xp -- GitLab