Only allow open org to show members

This commit is contained in:
cuom1999 2022-06-26 12:07:34 +07:00
parent 50afd6cd59
commit 0e324a3cce
7 changed files with 75 additions and 15 deletions

View file

@ -70,7 +70,7 @@ class ProblemForm(ModelForm):
),
"types": AdminSelect2MultipleWidget,
"group": AdminSelect2Widget,
"memory_limit": TextInput(attrs={'size':'20'}),
"memory_limit": TextInput(attrs={"size": "20"}),
}
if HeavyPreviewAdminPageDownWidget is not None:
widgets["description"] = HeavyPreviewAdminPageDownWidget(

View file

@ -7,13 +7,20 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('judge', '0127_auto_20220616_1442'),
("judge", "0127_auto_20220616_1442"),
]
operations = [
migrations.AlterField(
model_name='problem',
name='memory_limit',
field=models.PositiveIntegerField(help_text='The memory limit for this problem, in kilobytes (e.g. 256mb = 262144 kilobytes).', validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(1048576)], verbose_name='memory limit'),
model_name="problem",
name="memory_limit",
field=models.PositiveIntegerField(
help_text="The memory limit for this problem, in kilobytes (e.g. 256mb = 262144 kilobytes).",
validators=[
django.core.validators.MinValueValidator(0),
django.core.validators.MaxValueValidator(1048576),
],
verbose_name="memory limit",
),
),
]

View file

@ -6,18 +6,54 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('judge', '0128_auto_20220620_2210'),
("judge", "0128_auto_20220620_2210"),
]
operations = [
migrations.AlterField(
model_name='problemdata',
name='checker',
field=models.CharField(blank=True, choices=[('standard', 'Standard'), ('floats', 'Floats'), ('floatsabs', 'Floats (absolute)'), ('floatsrel', 'Floats (relative)'), ('rstripped', 'Non-trailing spaces'), ('sorted', 'Unordered'), ('identical', 'Byte identical'), ('linecount', 'Line-by-line'), ('custom', 'Custom checker (PY)'), ('customval', 'Custom validator (CPP)'), ('interact', 'Interactive'), ('testlib', 'Testlib')], max_length=10, verbose_name='checker'),
model_name="problemdata",
name="checker",
field=models.CharField(
blank=True,
choices=[
("standard", "Standard"),
("floats", "Floats"),
("floatsabs", "Floats (absolute)"),
("floatsrel", "Floats (relative)"),
("rstripped", "Non-trailing spaces"),
("sorted", "Unordered"),
("identical", "Byte identical"),
("linecount", "Line-by-line"),
("custom", "Custom checker (PY)"),
("customval", "Custom validator (CPP)"),
("interact", "Interactive"),
("testlib", "Testlib"),
],
max_length=10,
verbose_name="checker",
),
),
migrations.AlterField(
model_name='problemtestcase',
name='checker',
field=models.CharField(blank=True, choices=[('standard', 'Standard'), ('floats', 'Floats'), ('floatsabs', 'Floats (absolute)'), ('floatsrel', 'Floats (relative)'), ('rstripped', 'Non-trailing spaces'), ('sorted', 'Unordered'), ('identical', 'Byte identical'), ('linecount', 'Line-by-line'), ('custom', 'Custom checker (PY)'), ('customval', 'Custom validator (CPP)'), ('interact', 'Interactive'), ('testlib', 'Testlib')], max_length=10, verbose_name='checker'),
model_name="problemtestcase",
name="checker",
field=models.CharField(
blank=True,
choices=[
("standard", "Standard"),
("floats", "Floats"),
("floatsabs", "Floats (absolute)"),
("floatsrel", "Floats (relative)"),
("rstripped", "Non-trailing spaces"),
("sorted", "Unordered"),
("identical", "Byte identical"),
("linecount", "Line-by-line"),
("custom", "Custom checker (PY)"),
("customval", "Custom validator (CPP)"),
("interact", "Interactive"),
("testlib", "Testlib"),
],
max_length=10,
verbose_name="checker",
),
),
]

View file

@ -232,7 +232,9 @@ class ProblemDataCompiler(object):
if self.data.checker == "interact":
interactor_path = split_path_first(self.data.interactive_judge.name)
if len(interactor_path) != 2:
raise ProblemDataError(_("How did you corrupt the interactor path?"))
raise ProblemDataError(
_("How did you corrupt the interactor path?")
)
init["interactive"] = {
"files": interactor_path[1],
"feedback": True,

View file

@ -306,6 +306,17 @@ class OrganizationUsers(QueryStringSortMixin, OrganizationDetailView):
default_desc = all_sorts
default_sort = "-performance_points"
def dispatch(self, request, *args, **kwargs):
res = super(OrganizationUsers, self).dispatch(request, *args, **kwargs)
if self.can_access(self.organization) or self.organization.is_open:
return res
return generic_message(
request,
_("Can't access organization"),
_("You are not allowed to access this organization."),
status=403,
)
def get_context_data(self, **kwargs):
context = super(OrganizationUsers, self).get_context_data(**kwargs)
context["title"] = _("%s Members") % self.object.name

View file

@ -5,7 +5,9 @@
{{ make_tab_item('contests', 'fa fa-trophy', organization.get_contests_url(), _('Contests')) }}
{{ make_tab_item('submissions', 'fa fa-book', organization.get_submissions_url(), _('Submissions')) }}
{% endif %}
{{ make_tab_item('users', 'fa fa-user', organization.get_users_url(), _('Members')) }}
{% if is_member or can_edit or organization.is_open %}
{{ make_tab_item('users', 'fa fa-user', organization.get_users_url(), _('Members')) }}
{% endif %}
{% if perms.judge.change_organization %}
{{ make_tab_item('admin', 'fa fa-edit', url('admin:judge_organization_change', organization.id), _('Admin')) }}
{% endif %}

View file

@ -70,5 +70,7 @@
</div>
</div>
{% endif %}
{% include 'top-users.html' %}
{% if is_member or can_edit or organization.is_open %}
{% include 'top-users.html' %}
{% endif %}
</div>