Skip to content
Snippets Groups Projects
Commit ab82f9ae authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[experiments][models] Refactor declaration handling

Make it properties like for other models
parent 3c63ea80
No related branches found
No related tags found
2 merge requests!2551.4.x,!249Web fixes
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment