Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

Commit

Permalink
add payment information to template and test
Browse files Browse the repository at this point in the history
  • Loading branch information
alee committed Feb 21, 2015
1 parent 66ef90c commit 61819db
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 27 deletions.
17 changes: 6 additions & 11 deletions vcweb/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2089,8 +2089,7 @@ def current_round_activity_log(self):

def to_dict(self):
participant_group_relationships = [
{'pk': pgr.pk, 'participant_number': pgr.participant_number,
'email': pgr.participant.email}
{'pk': pgr.pk, 'participant_number': pgr.participant_number, 'email': pgr.participant.email}
for pgr in self.participant_group_relationship_set.select_related('participant__user').all()
]
return {
Expand All @@ -2100,10 +2099,9 @@ def to_dict(self):
}

def get_related_group(self):
# FIXME: currently only assumes single paired relationships
# FIXME: assumes single paired relationships, this method will raise an error in group clusters with groups > 2
gr = GroupRelationship.objects.get(group=self)
related_gr = GroupRelationship.objects.select_related(
'group').get(~models.Q(group=self), cluster=gr.cluster)
related_gr = GroupRelationship.objects.select_related('group').get(~models.Q(group=self), cluster=gr.cluster)
return related_gr.group

def log(self, log_message):
Expand All @@ -2114,15 +2112,12 @@ def log(self, log_message):

def add(self, parameter=None, amount=0):
# could be a float or an int..
update_dict = {parameter.value_field_name:
models.F(parameter.value_field_name) + amount}
self.log("adding %s to this group's %s parameter" %
(amount, parameter))
update_dict = {parameter.value_field_name: models.F(parameter.value_field_name) + amount}
self.log("adding %s to this group's %s parameter" % (amount, parameter))
updated_rows = self.data_value_set.filter(round_data=self.current_round_data, parameter=parameter).update(
**update_dict)
if updated_rows != 1:
logger.error(
"Updated %s rows, should have been only one.", updated_rows)
logger.error("Updated %s rows, should have been only one.", updated_rows)

def has_data_parameter(self, **kwargs):
criteria = self._criteria(**kwargs)
Expand Down
2 changes: 2 additions & 0 deletions vcweb/experiment/lighterprints/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def __init__(self, group_scores):
self.yesterday = date.today() - timedelta(1)
self.experimenter_email = settings.DEFAULT_FROM_EMAIL
self.experiment = group_scores.experiment
self.experiment_configuration = group_scores.experiment_configuration
self.round_data = group_scores.round_data
self.treatment_type = group_scores.treatment_type
self.has_leaderboard = group_scores.has_leaderboard
Expand All @@ -134,6 +135,7 @@ def get_context(self, group):
return Context({
'experiment': experiment,
'experiment_completed': experiment.is_last_round,
'payment_information': self.experiment_configuration.payment_information,
'number_of_groups': self.number_of_groups,
'group_name': group.name,
'summary_date': self.yesterday,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Lighter Footprints Summary for {{ summary_date }}
(http://en.wikipedia.org/wiki/Public_good) where there often exists a conflict between individual and collective interests.

{{ payment_information }}

{% else %}
You are a member of {{ group_name }}. To participate in this experiment, visit [{{experiment.full_participant_url}}]({{experiment.full_participant_url}}).
{% endif %}
Expand All @@ -21,7 +22,3 @@ You are a member of {{ group_name }}. To participate in this experiment, visit [
* Each member of your group earned {{ daily_earnings }}
* Your total earnings over the entire experiment are: {{ total_earnings }}
{% endif %}

{% if completed %}
Congratulations! Your group reached the target of {{ threshold }} average points per person.
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@ Lighter Footprints Summary for {{ summary_date }}
{% if experiment_completed %}
**The experiment is now over.** Thank you for participating. The experiment was a variation of a public good game
(http://en.wikipedia.org/wiki/Public_good) where there often exists a conflict between individual and collective interests.
{% if has_leaderboard %}
This particular experiment tests the effect of information on the outcomes of other groups (e.g., leaderboards).
{% endif %}

{% if linear_public_good %}
{{ payment_information }}
In order to receive payment please visit Jennifer Fraser (Jennifer.Fraser@asu.edu) at Matthews Hall 102 after Fall Break
(e.g., starting on Oct. 15th) on Monday (2-4pm), Wednesday (10am-1pm), or Friday (10am-1pm). You must pick up your
payment by October 31st. Be sure to bring your ASURITE Sun Card.
{% endif %}

{% else %}
You are a member of {{ group_name }}. To participate in this experiment, visit [{{experiment.full_participant_url}}]({{experiment.full_participant_url}}).
{% endif %}


* You earned {{ individual_points }} points while the average in your group was {{ average_daily_points }} point(s).
* You earned {{ individual_points }} points.
* Members of your group earned, on average, {{ average_daily_points }} point(s).
* {{ number_of_chat_messages }} chat messages were posted by your group.
{% if has_leaderboard %}
* Your group was ranked {{ group_rank}} out of {{ number_of_groups }}
Expand All @@ -27,7 +23,3 @@ You are a member of {{ group_name }}. To participate in this experiment, visit [
* Each member of your group earned {{ daily_earnings }}
* Your total earnings over the entire experiment are: {{ total_earnings }}
{% endif %}

{% if completed %}
Congratulations! Your group reached the target of {{ threshold }} average points per person.
{% endif %}
21 changes: 21 additions & 0 deletions vcweb/experiment/lighterprints/tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import logging

from django.conf import settings
from django.core.cache import cache
from vcweb.core.tests import BaseVcwebTest
from vcweb.core.models import ParticipantRoundDataValue, ChatMessage, Like, Comment
Expand Down Expand Up @@ -31,6 +32,7 @@ def setUp(self, treatment_type='LEVEL_BASED', leaderboard=True, linear_public_go
ec.set_parameter_value(parameter=get_linear_public_good_parameter(), boolean_value=linear_public_good)
ec.set_parameter_value(parameter=get_treatment_type_parameter(), string_value=treatment_type)
ec.round_configuration_set.update(initialize_data_values=True)
ec.payment_information = '''unique text for payment information: tobacco hornworm'''
ec.save()

@property
Expand Down Expand Up @@ -192,12 +194,31 @@ def test_summary_emails(self):
gs = GroupScores(e)
for group in e.groups:
summary_emails = gs.email_generator.generate(group)
group_emails = [pgr.participant.email for pgr in group.participant_group_relationship_set.all()]
for email in summary_emails:
for recipient in email.recipients():
if recipient != settings.DEFAULT_FROM_EMAIL:
group_emails.remove(recipient)
self.assertTrue(email.recipients())
self.assertTrue("5 chat messages were posted" in email.body)
self.assertTrue("You earned 250 point(s)." in email.body)
self.assertTrue("Members of your group earned, on average, 250 point(s)." in email.body)
self.assertTrue("Members of all groups earned, on average, 250 point(s)." in email.body)
self.assertFalse(group_emails, "Group emails should have all been removed")

def test_payment_information(self):
e = self.experiment
e.activate()
while e.has_next_round:
e.advance_to_next_round()
gs = GroupScores(e)
for group in e.groups:
summary_emails = gs.email_generator.generate(group)
for email in summary_emails:
logger.error("recipients: %s", email.recipients())
logger.error("body: %s", email.body)
self.assertTrue(email.recipients())
self.assertTrue("tobacco hornworm" in email.body)

def test_view_model(self):
e = self.experiment
Expand Down

0 comments on commit 61819db

Please sign in to comment.