[virtualcommons-svn] commit/vcweb: alllee: wiring up clone experiment functionality
Status: Beta
Brought to you by:
alllee
From: <com...@bi...> - 2013-07-22 07:23:25
|
1 new commit in vcweb: https://bitbucket.org/virtualcommons/vcweb/commits/94a0b76f6cbc/ Changeset: 94a0b76f6cbc User: alllee Date: 2013-07-22 09:23:14 Summary: wiring up clone experiment functionality Affected #: 3 files diff -r 7e2d5e56d3b09e1f3be89997b9c77a095e390fba -r 94a0b76f6cbc871b70de376d6b6238ee32168c5c vcweb/core/ajax.py --- a/vcweb/core/ajax.py +++ b/vcweb/core/ajax.py @@ -110,6 +110,15 @@ @experimenter_required @dajaxice_register(method='POST') +def clone_experiment(request, experiment_id): + logger.debug("cloning experiment %s", experiment_id) + experiment = get_object_or_404(Experiment, pk=experiment_id) + experimenter = request.user.experimenter + cloned_experiment = experiment.clone(experimenter=experimenter) + return JsonResponse(dumps({'success': True, 'experiment': cloned_experiment.to_dict(attrs=('monitor_url', 'status_line', 'controller_url'))})) + +@experimenter_required +@dajaxice_register(method='POST') def create_experiment(request, experiment_configuration_id): logger.debug("incoming create experiment request POST: %s with id %s", request.POST, experiment_configuration_id, ) experiment_configuration = get_object_or_404(ExperimentConfiguration.objects.select_related('experiment_metadata'), pk=experiment_configuration_id) diff -r 7e2d5e56d3b09e1f3be89997b9c77a095e390fba -r 94a0b76f6cbc871b70de376d6b6238ee32168c5c vcweb/core/models.py --- a/vcweb/core/models.py +++ b/vcweb/core/models.py @@ -909,7 +909,7 @@ self.save() ACCEPTABLE_ACTIONS = ('advance_to_next_round', 'end_round', 'start_round', 'move_to_previous_round', 'activate', - 'deactivate', 'complete', 'restart_round', 'restart') + 'deactivate', 'complete', 'restart_round', 'restart', 'clone') def invoke(self, action_name, experimenter=None): if action_name in Experiment.ACCEPTABLE_ACTIONS: logger.debug("experimenter %s invoking action %s", experimenter, action_name) diff -r 7e2d5e56d3b09e1f3be89997b9c77a095e390fba -r 94a0b76f6cbc871b70de376d6b6238ee32168c5c vcweb/core/templates/experimenter/dashboard.html --- a/vcweb/core/templates/experimenter/dashboard.html +++ b/vcweb/core/templates/experimenter/dashboard.html @@ -91,19 +91,19 @@ model.controllerUrl = function(experimentModel, urlAction) { return experimentModel.controller_url() + "/" + urlAction; } + function pendingExperimentCallback(data) { + if (data.success) { + pendingExperimentModel = ko.mapping.fromJS(data.experiment); + model.pendingExperiments.unshift(pendingExperimentModel); + model.activatePendingExperimentsTab(); + } + } model.createNewExperiment = function(configurationModel) { - Dajaxice.vcweb.core.create_experiment(function(data) { - if (data.success) { - pendingExperimentModel = ko.mapping.fromJS(data.experiment); - model.pendingExperiments.unshift(pendingExperimentModel); - model.activatePendingExperimentsTab(); - } - }, - { experiment_configuration_id: configurationModel.pk() }); + Dajaxice.vcweb.core.create_experiment(pendingExperimentCallback, { experiment_configuration_id: configurationModel.pk() }); } - model.cloneExperiment = function() { - console.debug("cloning experiment"); + model.cloneExperiment = function(experimentModel) { + Dajaxice.vcweb.core.clone_experiment(pendingExperimentCallback, { experiment_id: experimentModel.pk() }); } model.modify = function() { console.debug("modify existing configuration"); Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |