Allow clone ended contests
This commit is contained in:
parent
1291d750de
commit
35756d2f15
7 changed files with 659 additions and 620 deletions
|
@ -441,16 +441,32 @@ class ContestDetail(
|
||||||
.add_i18n_name(self.request.LANGUAGE_CODE)
|
.add_i18n_name(self.request.LANGUAGE_CODE)
|
||||||
)
|
)
|
||||||
context["editable_organizations"] = self.get_editable_organizations()
|
context["editable_organizations"] = self.get_editable_organizations()
|
||||||
|
context["is_clonable"] = is_contest_clonable(self.request, self.object)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class ContestClone(
|
def is_contest_clonable(request, contest):
|
||||||
ContestMixin, PermissionRequiredMixin, TitleMixin, SingleObjectFormView
|
if not request.profile:
|
||||||
):
|
return False
|
||||||
|
if not Organization.objects.filter(admins=request.profile).exists():
|
||||||
|
return False
|
||||||
|
if request.user.has_perm("judge.clone_contest"):
|
||||||
|
return True
|
||||||
|
if contest.ended:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
class ContestClone(ContestMixin, TitleMixin, SingleObjectFormView):
|
||||||
title = _("Clone Contest")
|
title = _("Clone Contest")
|
||||||
template_name = "contest/clone.html"
|
template_name = "contest/clone.html"
|
||||||
form_class = ContestCloneForm
|
form_class = ContestCloneForm
|
||||||
permission_required = "judge.clone_contest"
|
|
||||||
|
def get_object(self, queryset=None):
|
||||||
|
contest = super().get_object(queryset)
|
||||||
|
if not is_contest_clonable(self.request, contest):
|
||||||
|
raise Http404()
|
||||||
|
return contest
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
kwargs = super().get_form_kwargs()
|
kwargs = super().get_form_kwargs()
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -39,12 +39,6 @@ msgstr "Đăng ký tên"
|
||||||
msgid "Report"
|
msgid "Report"
|
||||||
msgstr "Báo cáo"
|
msgstr "Báo cáo"
|
||||||
|
|
||||||
msgid "Insert Image"
|
|
||||||
msgstr "Chèn hình ảnh"
|
|
||||||
|
|
||||||
msgid "Save"
|
|
||||||
msgstr "Lưu"
|
|
||||||
|
|
||||||
msgid "2sat"
|
msgid "2sat"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -600,3 +594,8 @@ msgstr ""
|
||||||
msgid "z-function"
|
msgid "z-function"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#~ msgid "Insert Image"
|
||||||
|
#~ msgstr "Chèn hình ảnh"
|
||||||
|
|
||||||
|
#~ msgid "Save"
|
||||||
|
#~ msgstr "Lưu"
|
||||||
|
|
|
@ -383,7 +383,7 @@
|
||||||
<footer>
|
<footer>
|
||||||
<span id="footer-content">
|
<span id="footer-content">
|
||||||
<br>
|
<br>
|
||||||
<a class="background-footer" target="_blank" href="https://dmoj.ca">proudly powered by <b>DMOJ</b></a><a target="_blank" href="https://github.com/LQDJudge/online-judge"> | developed by LQDJudge team</a> |
|
<a class="background-footer" target="_blank" href="https://dmoj.ca">proudly powered by <b>DMOJ</b></a>|<a target="_blank" href="https://github.com/LQDJudge/online-judge"> developed by LQDJudge team</a>
|
||||||
{% if i18n_config.footer %}
|
{% if i18n_config.footer %}
|
||||||
{{ i18n_config.footer|safe }} |
|
{{ i18n_config.footer|safe }} |
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
<div><label class="inline-header grayed">{{ _('Enter a new key for the cloned contest:') }}</label></div>
|
<div><label class="inline-header grayed">{{ _('Enter a new key for the cloned contest:') }}</label></div>
|
||||||
<div id="contest-key-container"><span class="fullwidth">{{ form.key }}</span></div>
|
<div id="contest-key-container"><span class="fullwidth">{{ form.key }}</span></div>
|
||||||
<div><label class="inline-header grayed">{{ _('Group:') }}</label></div>
|
<div><label class="inline-header grayed">{{ _('Group') }}:</label></div>
|
||||||
{{form.organization}}
|
{{form.organization}}
|
||||||
{% if form.organization.errors %}
|
{% if form.organization.errors %}
|
||||||
<div id="form-errors">
|
<div id="form-errors">
|
||||||
|
|
|
@ -36,7 +36,4 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ make_tab_item('edit', 'fa fa-edit', url('admin:judge_contest_change', contest.id), _('Edit')) }}
|
{{ make_tab_item('edit', 'fa fa-edit', url('admin:judge_contest_change', contest.id), _('Edit')) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.judge.clone_contest %}
|
|
||||||
{{ make_tab_item('clone', 'fa fa-copy', url('contest_clone', contest.key), _('Clone')) }}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -82,11 +82,16 @@
|
||||||
{{ contest.description|markdown|reference|str|safe }}
|
{{ contest.description|markdown|reference|str|safe }}
|
||||||
{% endcache %}
|
{% endcache %}
|
||||||
</div>
|
</div>
|
||||||
{% if editable_organizations %}
|
{% if editable_organizations or is_clonable %}
|
||||||
<div>
|
<div style="display: flex; gap: 0.5em;">
|
||||||
{% for org in editable_organizations %}
|
{% for org in editable_organizations %}
|
||||||
<span> [<a href="{{ url('organization_contest_edit', org.id , org.slug , contest.key) }}">{{ _('Edit in') }} {{org.slug}}</a>]</span>
|
<span> [<a href="{{ url('organization_contest_edit', org.id , org.slug , contest.key) }}">{{ _('Edit in') }} {{org.slug}}</a>]</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% if is_clonable %}
|
||||||
|
<span>
|
||||||
|
[<a href="{{url('contest_clone', contest.key)}}"}}>{{_('Clone')}}</a>]
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue