Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add field for participant in Submission #1586

Merged
merged 3 commits into from
Sep 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'),
),
]
14 changes: 14 additions & 0 deletions tabbycat/results/migrations/0006_merge_20200904_1743.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 3.1.1 on 2020-09-05 00:43

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('results', '0005_ballotsubmission_participant_submitter'),
('results', '0005_auto_20200902_1208'),
]

operations = [
]
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