Skip to content

Commit e9c2173

Browse files
committed
Merge branch 'master-custom' of https://github.com/FherStk/online-judge into Infer-test-cases-from-zip
2 parents e295fd4 + d9bcd1e commit e9c2173

File tree

5 files changed

+58
-1
lines changed

5 files changed

+58
-1
lines changed

judge/admin/problem.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class ProblemAdmin(NoBatchDeleteMixin, VersionAdmin):
128128
'description', 'include_test_cases', 'license',
129129
),
130130
}),
131+
(_('Authorship'), {'fields': (('authorship_name', 'authorship_uri'), 'license')}),
131132
(_('Social Media'), {'classes': ('collapse',), 'fields': ('og_image', 'summary')}),
132133
(_('Taxonomy'), {'fields': ('types', 'group')}),
133134
(_('Points'), {'fields': (('points', 'partial'), 'short_circuit')}),

judge/admin/submission.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def get_formset(self, request, obj=None, **kwargs):
7575

7676
def formfield_for_dbfield(self, db_field, **kwargs):
7777
submission = kwargs.pop('obj', None)
78-
label = None
78+
# label = None
7979
if submission:
8080
if db_field.name == 'participation':
8181
kwargs['queryset'] = ContestParticipation.objects.filter(user=submission.user,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 3.2.23 on 2024-01-02 08:20
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('judge', '0146_comment_revision_count_v2'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='problem',
15+
name='authorship_name',
16+
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"),
17+
),
18+
migrations.AddField(
19+
model_name='problem',
20+
name='authorship_uri',
21+
field=models.URLField(blank=True, max_length=255, verbose_name="author's URI"),
22+
),
23+
]

judge/models/problem.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ class Problem(models.Model):
127127
authors = models.ManyToManyField(Profile, verbose_name=_('creators'), blank=True, related_name='authored_problems',
128128
help_text=_('These users will be able to edit the problem, '
129129
'and be listed as authors.'))
130+
authorship_name = models.CharField(max_length=100, verbose_name=_("author's name"), blank=True,
131+
help_text=_("Use it for attribution purposes, the original author's name will "
132+
'be added at the end of the problem.'))
133+
authorship_uri = models.URLField(max_length=255, verbose_name=_("author's URI"), blank=True)
130134
curators = models.ManyToManyField(Profile, verbose_name=_('curators'), blank=True, related_name='curated_problems',
131135
help_text=_('These users will be able to edit the problem, '
132136
'but not be listed as authors.'))

templates/problem/problem.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@
4141
.problem-info-entry {
4242
padding-top: 0.5em;
4343
}
44+
45+
.authorship {
46+
font-style: italic;
47+
font-weight: bold;
48+
}
49+
50+
.authorship a {
51+
font-weight: normal;
52+
}
53+
54+
.authorship hr {
55+
margin-bottom: 10px;
56+
}
4457
</style>
4558
{% endblock %}
4659

@@ -305,6 +318,22 @@ <h2 style="display: inline-block">{{ title }}</h2>
305318
{{ test_cases|markdown(problem.markdown_style, MATH_ENGINE)|reference|str|safe }}
306319
{% endcache %}
307320

321+
{% if problem.authorship_name %}
322+
<span class="authorship">
323+
<hr>
324+
{% trans trimmed %} Authorship: {% endtrans %}
325+
326+
{% if problem.authorship_uri %}
327+
<a href="{{ problem.authorship_uri }}">
328+
{{ problem.authorship_name }}
329+
</a>
330+
{% else %}
331+
{{ problem.authorship_name }}
332+
{% endif %}
333+
</span>
334+
<br />
335+
{% endif %}
336+
308337
{% with license=problem.license %}
309338
{% if license %}
310339
<span class="license">

0 commit comments

Comments
 (0)