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, "types": AdminSelect2MultipleWidget,
"group": AdminSelect2Widget, "group": AdminSelect2Widget,
"memory_limit": TextInput(attrs={'size':'20'}), "memory_limit": TextInput(attrs={"size": "20"}),
} }
if HeavyPreviewAdminPageDownWidget is not None: if HeavyPreviewAdminPageDownWidget is not None:
widgets["description"] = HeavyPreviewAdminPageDownWidget( widgets["description"] = HeavyPreviewAdminPageDownWidget(

View file

@ -7,13 +7,20 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('judge', '0127_auto_20220616_1442'), ("judge", "0127_auto_20220616_1442"),
] ]
operations = [ operations = [
migrations.AlterField( migrations.AlterField(
model_name='problem', model_name="problem",
name='memory_limit', 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'), 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): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('judge', '0128_auto_20220620_2210'), ("judge", "0128_auto_20220620_2210"),
] ]
operations = [ operations = [
migrations.AlterField( migrations.AlterField(
model_name='problemdata', model_name="problemdata",
name='checker', 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'), 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( migrations.AlterField(
model_name='problemtestcase', model_name="problemtestcase",
name='checker', 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'), 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": if self.data.checker == "interact":
interactor_path = split_path_first(self.data.interactive_judge.name) interactor_path = split_path_first(self.data.interactive_judge.name)
if len(interactor_path) != 2: 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"] = { init["interactive"] = {
"files": interactor_path[1], "files": interactor_path[1],
"feedback": True, "feedback": True,

View file

@ -306,6 +306,17 @@ class OrganizationUsers(QueryStringSortMixin, OrganizationDetailView):
default_desc = all_sorts default_desc = all_sorts
default_sort = "-performance_points" 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): def get_context_data(self, **kwargs):
context = super(OrganizationUsers, self).get_context_data(**kwargs) context = super(OrganizationUsers, self).get_context_data(**kwargs)
context["title"] = _("%s Members") % self.object.name 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('contests', 'fa fa-trophy', organization.get_contests_url(), _('Contests')) }}
{{ make_tab_item('submissions', 'fa fa-book', organization.get_submissions_url(), _('Submissions')) }} {{ make_tab_item('submissions', 'fa fa-book', organization.get_submissions_url(), _('Submissions')) }}
{% endif %} {% endif %}
{% if is_member or can_edit or organization.is_open %}
{{ make_tab_item('users', 'fa fa-user', organization.get_users_url(), _('Members')) }} {{ make_tab_item('users', 'fa fa-user', organization.get_users_url(), _('Members')) }}
{% endif %}
{% if perms.judge.change_organization %} {% if perms.judge.change_organization %}
{{ make_tab_item('admin', 'fa fa-edit', url('admin:judge_organization_change', organization.id), _('Admin')) }} {{ make_tab_item('admin', 'fa fa-edit', url('admin:judge_organization_change', organization.id), _('Admin')) }}
{% endif %} {% endif %}

View file

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