[virtualcommons-developer] commit/vcweb: alllee: redirecting to experiment monitor page after cloni
Status: Beta
Brought to you by:
alllee
|
From: <com...@bi...> - 2013-03-21 10:09:35
|
1 new commit in vcweb: https://bitbucket.org/virtualcommons/vcweb/commits/bda736d07dac/ changeset: bda736d07dac user: alllee date: 2013-03-21 11:09:18 summary: redirecting to experiment monitor page after cloning an experiment affected #: 4 files diff -r 7f7cd79155ad634a78404fa2a4f8ed2aa12576e1 -r bda736d07dac7751c58cdf1d533d033aaa047b92 vcweb/core/models.py --- a/vcweb/core/models.py +++ b/vcweb/core/models.py @@ -736,6 +736,16 @@ self.current_round_sequence_number = max(self.current_round_sequence_number - 1, 1) self.save() + def move_to_next_round(self): + if self.is_round_in_progress: + self.end_round() + if self.has_next_round: + self.current_round_elapsed_time = 0 + self.current_round_sequence_number += 1 + return True + else: + logger.warning("trying to advance past the last round - no-op") + def invoke(self, action_name): if action_name in ('advance_to_next_round', 'end_round', 'start_round', 'activate', 'deactivate', 'complete'): getattr(self, action_name)() @@ -743,14 +753,8 @@ raise AttributeError("Invalid experiment action %s requested of experiment %s" % (action_name, self)) def advance_to_next_round(self): - if self.is_round_in_progress: - self.end_round() - if self.has_next_round: - self.current_round_elapsed_time = 0 - self.current_round_sequence_number += 1 + if self.move_to_next_round(): self.start_round() - else: - logger.warning("trying to advance past the last round - no-op") def create_round_data(self): round_data, created = self.round_data_set.get_or_create(round_configuration=self.current_round) @@ -851,7 +855,8 @@ experiment_dict['allRoundData'] = self.all_round_data() experiment_dict['chatMessages'] = [chat_message.to_dict() for chat_message in self.all_chat_messages] experiment_dict['messages'] = [unicode(log) for log in self.activity_log_set.order_by('-date_created')] - experiment_dict['experimenterNotes'] = self.current_round_data.experimenter_notes + if self.is_round_in_progress: + experiment_dict['experimenterNotes'] = self.current_round_data.experimenter_notes return experiment_dict def as_dict(self, *args, **kwargs): diff -r 7f7cd79155ad634a78404fa2a4f8ed2aa12576e1 -r bda736d07dac7751c58cdf1d533d033aaa047b92 vcweb/core/templates/experimenter/monitor.html --- a/vcweb/core/templates/experimenter/monitor.html +++ b/vcweb/core/templates/experimenter/monitor.html @@ -14,8 +14,8 @@ <div class='btn-group'><a class='btn btn-success' data-bind="click: confirmExperimentAction, css: { disabled: isRoundInProgress }" data-action='start_round' data-content='Starts the round.'><i class='icon-play'></i> start</a><a class='btn btn-success' data-bind='click: advanceToNextRound' data-action='advance_to_next_round' data-content='Advances to and starts the next round.'><i class='icon-step-forward'></i> next round</a> - <a class='btn btn-success' data-bind='click: refreshAllParticipants' data-content='Sends a page refresh to all connected participants.' ><i class='icon-exchange'></i> refresh participants</a>--> - <a class='btn btn-primary' data-bind='click: update' data-content='Refresh this page with the latest data from the server.' ><i class='icon-refresh'></i></a> + <a class='btn btn-success' data-bind='click: updateParticipants' data-content='Updates all connected participants.' ><i class='icon-exchange'></i> update</a> + <a class='btn btn-primary' data-bind='click: update' data-content='Update this page and pull the latest data from the server.' ><i class='icon-refresh'></i></a><a class='btn btn-danger' data-bind='click: confirmExperimentAction' data-action='deactivate' data-content='Deactivates this experiment.'><i class='icon-off'></i></a></div></div> @@ -68,7 +68,7 @@ <li><a href='export/configuration.xml'><i class='icon-cog'></i>xml</a></li><li><a href='export/configuration.json'><i class='icon-pencil'></i>json</a></li></ul> - <a class='btn btn-danger' data-bind='click: confirmExperimentAction' data-action='complete' data-content='Mark this experiment as completed and archive it.'><i class='icon-save'></i> archive</a> + <a class='btn btn-danger' data-bind='css: { disabled: isArchived}, click: confirmExperimentAction' data-action='complete' data-content='Mark this experiment as completed and archive it.'><i class='icon-save'></i> archive</a></div></div><div class='span6'> @@ -84,7 +84,7 @@ <h4>Experimenter Notes (<span data-bind='text: roundSequenceLabel'></span>)</h4><form id="experimenterNotesForm" class='form-inline'><div class='controls'> - <textarea class='input-block-level' id='experimenterNotes' data-bind='text: experimenterNotes' placeholder="Experimenter notes to be stored with this round's data" rows="3"></textarea> + <textarea class='input-block-level' id='experimenterNotesText' data-bind='text: experimenterNotes' placeholder="Experimenter notes to be stored with this round's data" rows="3"></textarea><button id='submitExperimenterNotesButton' class='btn btn-primary' type='submit' data-bind='click: saveExperimenterNotes'>Save</button></div></form> @@ -168,14 +168,13 @@ {% include "includes/experimenter.events.html" %} {% include "includes/sockjs.html" %} <script type='text/javascript'> -// FIXME: we should verify if exposing this here is the "right" thing to do. var experimentModelJson = $.parseJSON("{{ experimentModelJson|escapejs }}"); $(function() { function ExperimentModel(experimentModelJson) { var self = this; var model = ko.mapping.fromJS(experimentModelJson); model.saveExperimenterNotes = function(localModel, evt) { - var notes = $('#experimenterNotes').val(); + var notes = $('#experimenterNotesText').val(); Dajaxice.vcweb.core.save_experimenter_notes(function(data) { if (data.success) { $('#submitExperimenterNotesButton').val('Saved!'); @@ -187,18 +186,23 @@ $('#progress-modal').modal('show'); Dajaxice.vcweb.core.get_experiment_model(update(model), {pk: {{experiment.pk}}}); } - model.confirmExperimentAction = function(experimentModel, evt) { - confirmExperimentControllerAction(evt.target, model); + model.confirmExperimentAction = function(m, evt) { + element = evt.target; + if ($(element).hasClass('disabled')) { + console.debug("aborting."); + return; + } + confirmExperimentControllerAction(element, model); } - model.advanceToNextRound = function(localModel, evt) { - confirmExperimentControllerAction(evt.target, model, function(confirmed) { + model.advanceToNextRound = function(m, evt) { + confirmExperimentControllerAction(evt.target, m, function(confirmed) { if (confirmed) { console.debug("advancing to next round, notify all participants"); sendUpdateEvent(); } }); }; - model.refreshAllParticipants = function(localModel, evt) { + model.updateParticipants = function(m, evt) { confirmAction(evt.target, function(confirmed, action) { if (confirmed) { console.debug("sending update event"); @@ -214,7 +218,7 @@ }); return model; } - function confirmExperimentControllerAction(element, experimentModel, callback) { + function confirmExperimentControllerAction(element, m, callback) { confirmAction(element, function(confirmed, action) { $('#progress-modal').modal('show'); Dajaxice.vcweb.core.experiment_controller(function(data) { diff -r 7f7cd79155ad634a78404fa2a4f8ed2aa12576e1 -r bda736d07dac7751c58cdf1d533d033aaa047b92 vcweb/core/urls.py --- a/vcweb/core/urls.py +++ b/vcweb/core/urls.py @@ -4,7 +4,6 @@ from vcweb.core.views import (Dashboard, LoginView, LogoutView, RegistrationView, monitor, CloneExperimentView, RegisterEmailListView, RegisterSimpleParticipantsView, ClearParticipantsExperimentView, add_experiment, Participate, download_data, export_configuration, api_logger, participant_ready, deactivate) - import logging import urllib diff -r 7f7cd79155ad634a78404fa2a4f8ed2aa12576e1 -r bda736d07dac7751c58cdf1d533d033aaa047b92 vcweb/core/views.py --- a/vcweb/core/views.py +++ b/vcweb/core/views.py @@ -326,9 +326,10 @@ # FIXME: these last two use GET (which should be idempotent) to modify database state which makes HTTP sadful class CloneExperimentView(ExperimenterSingleExperimentView): def process(self): - return self.experiment.clone() + self.experiment = self.experiment.clone() + return self.experiment def render_to_response(self, context): - return redirect('core:dashboard') + return redirect('core:monitor_experiment', pk=self.experiment.pk) class ClearParticipantsExperimentView(ExperimenterSingleExperimentView): def process(self): 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. |