Skip to content

Commit

Permalink
Attribution data can now be added to a problem (author + link) and it…
Browse files Browse the repository at this point in the history
… will be displayed at the end of the problem's statement.
  • Loading branch information
FherStk committed Aug 12, 2024
1 parent 8cebced commit c6cbea5
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
3 changes: 2 additions & 1 deletion judge/admin/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ class ProblemAdmin(NoBatchDeleteMixin, VersionAdmin):
'fields': (
'code', 'name', 'is_public', 'is_manually_managed', 'date', 'authors', 'curators', 'testers',
'organizations', 'submission_source_visibility_mode', 'is_full_markup',
'description', 'license',
'description',
),
}),
(_('Authorship'), {'fields': (('authorship_name', 'authorship_uri'), 'license')}),
(_('Social Media'), {'classes': ('collapse',), 'fields': ('og_image', 'summary')}),
(_('Taxonomy'), {'fields': ('types', 'group')}),
(_('Points'), {'fields': (('points', 'partial'), 'short_circuit')}),
Expand Down
2 changes: 1 addition & 1 deletion judge/admin/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def get_formset(self, request, obj=None, **kwargs):

def formfield_for_dbfield(self, db_field, **kwargs):
submission = kwargs.pop('obj', None)
label = None
# label = None
if submission:
if db_field.name == 'participation':
kwargs['queryset'] = ContestParticipation.objects.filter(user=submission.user,
Expand Down
23 changes: 23 additions & 0 deletions judge/migrations/0147_problem_authorship.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.23 on 2024-01-02 08:20

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('judge', '0146_comment_revision_count_v2'),
]

operations = [
migrations.AddField(
model_name='problem',
name='authorship_name',
field=models.CharField(blank=True, help_text="Use it for attribution purposes, the original author's name will be added at the end of the problem.", max_length=100, verbose_name="author's name"),
),
migrations.AddField(
model_name='problem',
name='authorship_uri',
field=models.URLField(blank=True, max_length=255, verbose_name="author's URI"),
),
]
4 changes: 4 additions & 0 deletions judge/models/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ class Problem(models.Model):
authors = models.ManyToManyField(Profile, verbose_name=_('creators'), blank=True, related_name='authored_problems',
help_text=_('These users will be able to edit the problem, '
'and be listed as authors.'))
authorship_name = models.CharField(max_length=100, verbose_name=_("author's name"), blank=True,
help_text=_("Use it for attribution purposes, the original author's name will "
'be added at the end of the problem.'))
authorship_uri = models.URLField(max_length=255, verbose_name=_("author's URI"), blank=True)
curators = models.ManyToManyField(Profile, verbose_name=_('curators'), blank=True, related_name='curated_problems',
help_text=_('These users will be able to edit the problem, '
'but not be listed as authors.'))
Expand Down
29 changes: 29 additions & 0 deletions templates/problem/problem.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@
.problem-info-entry {
padding-top: 0.5em;
}

.authorship {
font-style: italic;
font-weight: bold;
}

.authorship a {
font-weight: normal;
}

.authorship hr {
margin-bottom: 10px;
}
</style>
{% endblock %}

Expand Down Expand Up @@ -304,6 +317,22 @@ <h2 style="display: inline-block">{{ title }}</h2>
{{ description|markdown(problem.markdown_style, MATH_ENGINE)|reference|str|safe }}
{% endcache %}

{% if problem.authorship_name %}
<span class="authorship">
<hr>
{% trans trimmed %} Authorship: {% endtrans %}

{% if problem.authorship_uri %}
<a href="{{ problem.authorship_uri }}">
{{ problem.authorship_name }}
</a>
{% else %}
{{ problem.authorship_name }}
{% endif %}
</span>
<br />
{% endif %}

{% with license=problem.license %}
{% if license %}
<span class="license">
Expand Down

0 comments on commit c6cbea5

Please sign in to comment.