Remove group adding in edit profile

This commit is contained in:
yucyle 2023-08-08 17:30:47 +07:00 committed by GitHub
parent f9bdc75176
commit 8f42885482
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 25 deletions

View file

@ -74,7 +74,6 @@ class ProfileForm(ModelForm):
model = Profile model = Profile
fields = [ fields = [
"about", "about",
"organizations",
"timezone", "timezone",
"language", "language",
"ace_theme", "ace_theme",
@ -98,26 +97,9 @@ class ProfileForm(ModelForm):
attrs={"style": "max-width:700px;min-width:700px;width:700px"}, attrs={"style": "max-width:700px;min-width:700px;width:700px"},
) )
def clean(self):
organizations = self.cleaned_data.get("organizations") or []
max_orgs = settings.DMOJ_USER_MAX_ORGANIZATION_COUNT
if sum(org.is_open for org in organizations) > max_orgs:
raise ValidationError(
_("You may not be part of more than {count} public groups.").format(
count=max_orgs
)
)
return self.cleaned_data
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
user = kwargs.pop("user", None) user = kwargs.pop("user", None)
super(ProfileForm, self).__init__(*args, **kwargs) super(ProfileForm, self).__init__(*args, **kwargs)
if not user.has_perm("judge.edit_all_organization"):
self.fields["organizations"].queryset = Organization.objects.filter(
Q(is_open=True) | Q(id__in=user.profile.organizations.all()),
)
def file_size_validator(file): def file_size_validator(file):

View file

@ -44,7 +44,7 @@
#center-float { #center-float {
position: relative; position: relative;
margin: 0 auto auto -28.5em; margin: 0 auto auto -28.5em;
left: 50%; left: 60%;
width: 700px; width: 700px;
} }
</style> </style>
@ -142,12 +142,6 @@
</tr> </tr>
</table> </table>
</td> </td>
<td>
<div style="padding-bottom:0.4em;margin-top:-2em" class="block-header">
{{ _('Affiliated organizations') }}:
</div>
{{ form.organizations }}
</td>
</tr> </tr>
</table> </table>