Skip to content

Commit

Permalink
Add field for participant in Submission
Browse files Browse the repository at this point in the history
This commit adds a new field to Submission models as a Person foreign
key. This field is then populated when using private URLs as an
alternative to IP addresses (although still collected).

With this, ballots can be more easily distinguished from which
adjudicator had submitted the ballot. This is added to the "other
ballots" list. It can also be used to find which team member submitted
feedback, although not shown in any template.
  • Loading branch information
tienne-B committed Aug 14, 2020
1 parent f8ea5d0 commit 6216166
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 2.2.13 on 2020-08-14 13:18

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('participants', '0016_auto_20200705_1317'),
('adjfeedback', '0008_auto_20200705_1317'),
]

operations = [
migrations.AddField(
model_name='adjudicatorfeedback',
name='participant_submitter',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='adjfeedback_adjudicatorfeedback_participant_submitted', to='participants.Person', verbose_name='from participant'),
),
]
5 changes: 5 additions & 0 deletions tabbycat/adjfeedback/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,11 @@ def get_team_short_name(self, team):
def is_page_enabled(self, tournament):
return tournament.pref('participant_feedback') == 'private-urls'

def get_submitter_fields(self):
fields = super().get_submitter_fields()
fields['participant_submitter'] = self.object
return fields

def get_success_url(self):
# Redirect to non-cached page: their original private URL
if isinstance(self.object, Adjudicator):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 2.2.13 on 2020-08-14 13:18

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('participants', '0016_auto_20200705_1317'),
('results', '0004_auto_20200705_1317'),
]

operations = [
migrations.AddField(
model_name='ballotsubmission',
name='participant_submitter',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='results_ballotsubmission_participant_submitted', to='participants.Person', verbose_name='from participant'),
),
]
5 changes: 5 additions & 0 deletions tabbycat/results/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class Submission(models.Model):
confirmed = models.BooleanField(default=False,
verbose_name=_("confirmed"))

# relevant for private URL submissions
participant_submitter = models.ForeignKey('participants.Person', models.PROTECT,
blank=True, null=True, related_name="%(app_label)s_%(class)s_participant_submitted",
verbose_name=_("from participant"))

# only relevant if submitter was in tab room
submitter = models.ForeignKey(settings.AUTH_USER_MODEL, models.PROTECT,
blank=True, null=True, related_name="%(app_label)s_%(class)s_submitted",
Expand Down
12 changes: 9 additions & 3 deletions tabbycat/results/templates/ballot/other_ballots_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ <h4 class="list-group-item-heading mb-0">
entered by <strong>{{ submitter }}</strong>,
{% endblocktrans %}
{% elif other.submitter_type == ballotsub.SUBMITTER_PUBLIC %}
{% blocktrans trimmed with ip_address=other.ip_address %}
submitted from the public form on {{ ip_address }},
{% endblocktrans %}
{% if other.participant_submitter %}
{% blocktrans trimmed with adjudicator=other.participant_submitter %}
submitted from <strong>{{ adjudicator }}</strong>'s private URL,
{% endblocktrans %}
{% else %}
{% blocktrans trimmed with ip_address=other.ip_address %}
submitted from the public form on {{ ip_address }},
{% endblocktrans %}
{% endif %}
{% endif %}

{% blocktrans trimmed with timestamp=other.timestamp timeago=other.timestamp|timesince %}
Expand Down
4 changes: 4 additions & 0 deletions tabbycat/results/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,10 @@ class OldPublicNewBallotSetByRandomisedUrlView(SingleObjectByRandomisedUrlMixin,
allow_null_tournament = True
private_url = True

def populate_objects(self):
super().populate_objects()
self.ballotsub.participant_submitter = Adjudicator.objects.get(url_key=self.kwargs['url_key'])

def get_success_url(self):
return reverse_tournament('privateurls-person-index', self.tournament, kwargs={'url_key': self.kwargs['url_key']})

Expand Down

0 comments on commit 6216166

Please sign in to comment.