[virtualcommons-developer] commit/vcweb: alllee: adding chat interface back and providing defaults
Status: Beta
Brought to you by:
alllee
From: <com...@bi...> - 2013-03-27 01:53:02
|
1 new commit in vcweb: https://bitbucket.org/virtualcommons/vcweb/commits/65cdbed51c4e/ Changeset: 65cdbed51c4e User: alllee Date: 2013-03-27 02:52:41 Summary: adding chat interface back and providing defaults to experiment model dict Affected #: 4 files diff -r ad15bcef5e4f8ec53ac052b0cc5f752e9406f93d -r 65cdbed51c4e01ece5079179a5a58fad5c27c07c vcweb/boundaries/templates/boundaries/participate.html --- a/vcweb/boundaries/templates/boundaries/participate.html +++ b/vcweb/boundaries/templates/boundaries/participate.html @@ -21,13 +21,12 @@ {% endblock content %} {% block sidebar %} -<div data-bind='if: chatEnabled'><h3>Chat</h3><div class='chat-sidebar well'><form id="chat-form" class='form-inline'><div class='input-prepend input-append'><span class='add-on'><i class='text-info icon-comment'></i></span> - <input style='width: 100%;' class='chat-action' id='chatText' type="text" placeholder="Enter a chat message"> + <input class='chat-action input-block-level' id='chatText' type="text" placeholder="Enter a chat message"><button class='btn' data-bind='click: submitChatMessage'>Send</button></div></form> @@ -40,7 +39,6 @@ </div></div></div> -</div> {% endblock sidebar %} {% block javascript %} {{ block.super }} @@ -439,7 +437,7 @@ model.startRound = function() { model.enableChat(); model.setFormDisabled("#vcweb-form", true); - model.secondsLeft(60); + model.secondsLeft(model.roundDuration()); model.setCurrentInterval( setInterval(function() { model.tick(); @@ -509,6 +507,9 @@ model.setFormDisabled("#vcweb-form", true); model.setFormDisabled("#chat-form", true); } + if (model.roundType() === "REGULAR") { + model.startRound() + } } return model; } diff -r ad15bcef5e4f8ec53ac052b0cc5f752e9406f93d -r 65cdbed51c4e01ece5079179a5a58fad5c27c07c vcweb/boundaries/views.py --- a/vcweb/boundaries/views.py +++ b/vcweb/boundaries/views.py @@ -55,6 +55,16 @@ logger.debug("getting view model for participant: %s", pgr) return JsonResponse(get_view_model_json(experiment, pgr)) +experiment_model_defaults = { + 'submitted': False, + 'chatEnabled': False, + 'resourceLevel': 0, + 'maxEarnings': 20.00, + 'maximumResourcesToDisplay': 20, + 'warningCountdownTime': 10, + 'maxHarvestDecision': 10, + 'harvestDecision': 0, + } # FIXME: need to distinguish between instructions / welcome rounds and practice/regular rounds def get_view_model_json(experiment, participant_group_relationship, **kwargs): ec = experiment.experiment_configuration @@ -62,10 +72,10 @@ current_round_data = experiment.current_round_data previous_round = experiment.previous_round previous_round_data = experiment.get_round_data(round_configuration=previous_round) - experiment_model_dict = experiment.to_dict(include_round_data=False, attrs={}) - experiment_model_dict['submitted'] = False + experiment_model_dict = experiment.to_dict(include_round_data=False, default_value_dict=experiment_model_defaults) # round / experiment configuration data + experiment_model_dict['roundDuration'] = current_round.duration regrowth_rate = get_regrowth_rate(current_round) cost_of_living = get_cost_of_living(current_round) experiment_model_dict['costOfLiving'] = cost_of_living @@ -74,15 +84,12 @@ experiment_model_dict['participantsPerGroup'] = ec.max_group_size experiment_model_dict['regrowthRate'] = regrowth_rate experiment_model_dict['initialResourceLevel'] = get_initial_resource_level(current_round) - experiment_model_dict['dollarsPerToken'] = float(ec.exchange_rate) - experiment_model_dict['resourceLevel'] = 0 experiment_model_dict['totalNumberOfParticipants'] = experiment.participant_set.count() experiment_model_dict['participantNumber'] = participant_group_relationship.participant_number experiment_model_dict['participantGroupId'] = participant_group_relationship.pk experiment_model_dict['roundType'] = current_round.round_type experiment_model_dict['practiceRound'] = current_round.is_practice_round - experiment_model_dict['chatEnabled'] = False if current_round.is_regular_round: experiment_model_dict['chatEnabled'] = current_round.chat_enabled @@ -133,11 +140,6 @@ experiment_model_dict['groupData'] = group_data # FIXME: defaults hard coded in for now - experiment_model_dict['maxEarnings'] = 20.00 - experiment_model_dict['maximumResourcesToDisplay'] = 20 - experiment_model_dict['warningCountdownTime'] = 10 - experiment_model_dict['maxHarvestDecision'] = 10 - experiment_model_dict['hasSubmit'] = False experiment_model_dict['instructions'] = current_round.get_custom_instructions() experiment_model_dict.update(**kwargs) return dumps(experiment_model_dict) diff -r ad15bcef5e4f8ec53ac052b0cc5f752e9406f93d -r 65cdbed51c4e01ece5079179a5a58fad5c27c07c vcweb/core/models.py --- a/vcweb/core/models.py +++ b/vcweb/core/models.py @@ -893,7 +893,7 @@ }) return all_round_data - def to_dict(self, include_round_data=True, *args, **kwargs): + def to_dict(self, include_round_data=True, default_value_dict=None, attrs=None, *args, **kwargs): ec = self.experiment_configuration experiment_dict = { 'roundStatusLabel': self.status_label, @@ -912,6 +912,10 @@ 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 else '' + if default_value_dict: + experiment_dict.update(default_value_dict, **kwargs) + if attrs: + experiment_dict.update([(attr, getattr(self, attr, None)) for attr in attrs]) return experiment_dict def as_dict(self, *args, **kwargs): diff -r ad15bcef5e4f8ec53ac052b0cc5f752e9406f93d -r 65cdbed51c4e01ece5079179a5a58fad5c27c07c vcweb/static/css/boundaries/style.css --- a/vcweb/static/css/boundaries/style.css +++ b/vcweb/static/css/boundaries/style.css @@ -1,6 +1,6 @@ .chat-sidebar { height: 600px; - padding: 20px; + padding: 10px; } .boundaries-status-dashboard p { padding-top: 15px; 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. |