[virtualcommons-svn] commit/vcweb: alllee: refs issue 102 - setting up individual form submissions,
Status: Beta
Brought to you by:
alllee
From: <com...@bi...> - 2013-04-09 00:36:36
|
1 new commit in vcweb: https://bitbucket.org/virtualcommons/vcweb/commits/bca65c1a5c50/ Changeset: bca65c1a5c50 User: alllee Date: 2013-04-09 02:36:23 Summary: refs issue 102 - setting up individual form submissions, still need to set up UI Affected #: 4 files diff -r 9b5768e0d3151a152ea2182d3fe19946583e8505 -r bca65c1a5c5073b4dbbeefb3a3fbf553cbce1763 vcweb/boundaries/static/css/boundaries/style.css --- a/vcweb/boundaries/static/css/boundaries/style.css +++ b/vcweb/boundaries/static/css/boundaries/style.css @@ -26,3 +26,7 @@ margin-right: 0px; padding: 8px 8px 8px 8px; } +.harvest-decision-resources td { + cursor: pointer; +} + diff -r 9b5768e0d3151a152ea2182d3fe19946583e8505 -r bca65c1a5c5073b4dbbeefb3a3fbf553cbce1763 vcweb/boundaries/templates/boundaries/participate.html --- a/vcweb/boundaries/templates/boundaries/participate.html +++ b/vcweb/boundaries/templates/boundaries/participate.html @@ -445,19 +445,38 @@ <form id='vcweb-form' data-bind='submit: submitDecision' action='' method='post' class='form-horizontal' > {% csrf_token %} <div id='harvestDecisionDiv' data-bind='visible: !submitted()' class='control-group'> - <div class='input-prepend'> - <span class='add-on'><i class='icon-leaf'></i></span> - <input id='participantGroupId' type='hidden' name='participant_group_id' data-bind='value: participantGroupId'/> - <input id='harvestDecisionTextInput' type='hidden' name='integer_decision' data-bind='value: harvestDecision'> - <select id='harvestDecisionSelect' name='harvest_decision' required="required" form="vcweb-form" data-bind='options: harvestDecisionOptions, value: harvestDecision'> - </select> - </div> - <button id='submitDecisionButton' type='submit' class='btn btn-primary'>Submit</button> + <div data-bind='template: { name: "harvest-decision-multi-select-template" }'></div></div></form></div></div></script> +<script type='text/html' id='harvest-decision-multi-select-template'> + <table class='table'> + <tr class='row harvest-decision-resources' data-bind='foreach: harvestDecisionOptions'> + <td data-bind='attr: { id: "harvest-decision-td-" + $data }'> + <form data-bind='attr: { id: "multi-select-decision-form" + $data }'> + <input id='participantGroupId' type='hidden' name='participant_group_id' data-bind='value: $root.participantGroupId'/> + <input id='harvestDecisionTextInput' type='hidden' name='integer_decision' data-bind='value: $data'> + <div class='harvest-decision-tree' data-bind='click: $root.submitDecision.bind($data, "#multi-select-decision-form" + $data)'> + <img data-bind='attr: { src: $root.resourceImageUrl(), alt: "Harvest " + $data + " tree(s)." }'><br> + <span style='margin-left: 2px;' class='badge badge-success' data-bind='text: $data'></span> + </div> + </form> + </td> + </tr> + </table> +</script> +<script type='text/html' id='harvest-decision-select-template'> + <div class='input-prepend'> + <span class='add-on'><i class='icon-leaf'></i></span> + <input id='participantGroupId' type='hidden' name='participant_group_id' data-bind='value: participantGroupId'/> + <input id='harvestDecisionTextInput' type='hidden' name='integer_decision' data-bind='value: harvestDecision'> + <select id='harvestDecisionSelect' name='harvest_decision' required="required" form="vcweb-form" data-bind='options: harvestDecisionOptions, value: harvestDecision'> + </select> + </div> + <button id='submitDecisionButton' type='submit' class='btn btn-primary'>Submit</button> +</script><script src='{% static "js/bootstrap-tour.js" %}'></script><script type="text/javascript"> $(function() { @@ -582,8 +601,13 @@ 1000)); } }; - model.submitDecision = function(data, evt) { - var formData = $('#vcweb-form').serialize(); + model.submitDecision = function(formId, numberOfTrees) { + console.debug("formId: " + formId); + if (! formId) { + formId = "#vcweb-form"; + } + console.debug("number of trees: " + numberOfTrees); + var formData = $(formId).serialize(); model.submitted(true); console.debug(formData); $.post('submit-harvest-decision', formData, function(response) { diff -r 9b5768e0d3151a152ea2182d3fe19946583e8505 -r bca65c1a5c5073b4dbbeefb3a3fbf553cbce1763 vcweb/core/models.py --- a/vcweb/core/models.py +++ b/vcweb/core/models.py @@ -352,16 +352,19 @@ @property def current_round_elapsed_time(self): - if self.current_round_start_time: + if self.current_round_start_time and self.is_timed_round: return datetime.now() - self.current_round_start_time return timedelta(0) @property def time_remaining(self): - tr = self.current_round.duration - self.current_round_elapsed_time.seconds - if tr < 0: - return u"Expired %s seconds ago" % abs(tr) - return tr + if self.is_timed_round: + tr = self.current_round.duration - self.current_round_elapsed_time.seconds + if tr <= 0: + return u"Expired (%s seconds ago)" % abs(tr) + return tr + else: + return "Untimed round (advance manually or via automated checkpointing)" @property def is_timed_round(self): @@ -630,7 +633,7 @@ p.institution = institution p.save() per = ParticipantExperimentRelationship.objects.create(participant=p, experiment=self, created_by=self.experimenter.user) - email_messages.append(self.create_registration_email(per, password=password)) + email_messages.append(self.create_registration_email(per, password=password, is_new_participant=created)) if email_messages: mail.get_connection().send_messages(email_messages) diff -r 9b5768e0d3151a152ea2182d3fe19946583e8505 -r bca65c1a5c5073b4dbbeefb3a3fbf553cbce1763 vcweb/lighterprints/models.py --- a/vcweb/lighterprints/models.py +++ b/vcweb/lighterprints/models.py @@ -495,7 +495,6 @@ total_group_points = group_data_dict['total_group_points'] average = total_group_points / group_size group_data_dict['average_group_points'] = average - logger.debug("total carbon savings: %s divided by %s members = %s per person", total_group_points, group_size, average) return (group_scores, total_participant_points) 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. |