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

Problem authorship #2303

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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
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