Intitial teams support #147

Merged
Oleg-Komarov merged 34 commits from teams-support into main 2024-05-23 19:43:54 +02:00
2 changed files with 1 additions and 10 deletions
Showing only changes of commit a75ed9c5f2 - Show all commits

View File

@ -117,7 +117,6 @@ class ExtensionUpdateForm(forms.ModelForm):
)
msg_need_previews = _('Please add at least one preview.')
msg_duplicate_file = _('Please select another file instead of the duplicate.')
invalid_team_value = '-'
class Meta:
model = extensions.models.Extension
@ -129,7 +128,6 @@ class ExtensionUpdateForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
"""Pass the request and initialise all the nested form(set)s."""
self.request = kwargs.pop('request')
self.add_invalid_team_choice = kwargs.pop('add_invalid_team_choice', False)
super().__init__(*args, **kwargs)
if self.request.POST:
edit_preview_formset = EditPreviewFormSet(
@ -170,9 +168,7 @@ class ExtensionUpdateForm(forms.ModelForm):
team_slug = None
if self.instance.team:
team_slug = self.instance.team.slug
choices = [(None, self.request.user), *[(team.slug, team.name) for team in user_teams]]
if self.add_invalid_team_choice:
choices.insert(0, (self.invalid_team_value, '-----'))
choices = [(None, 'None'), *[(team.slug, team.name) for team in user_teams]]
self.fields['team'] = forms.ChoiceField(
choices=choices,
required=False,
@ -225,9 +221,6 @@ class ExtensionUpdateForm(forms.ModelForm):
return
team_slug = self.cleaned_data['team']
if team_slug == self.invalid_team_value:
self.add_error('team', _('Please select one of the valid values'))
return
if team_slug:
team = self.request.user.teams.filter(slug=team_slug).first()
if not team:

View File

@ -375,7 +375,6 @@ class DraftExtensionView(
extension_form = ExtensionUpdateForm(
instance=self.extension,
request=self.request,
add_invalid_team_choice=True,
)
context['extension_form'] = extension_form
context['edit_preview_formset'] = extension_form.edit_preview_formset
@ -392,7 +391,6 @@ class DraftExtensionView(
self.request.FILES,
instance=self.extension,
request=self.request,
add_invalid_team_choice=True,
)
if form.is_valid() and extension_form.is_valid():
return self.form_valid(form, extension_form)