musician reload webapp options after save webappoption

This commit is contained in:
Jorge Pastor 2024-05-02 21:21:33 +02:00
parent b911e0e89f
commit 142c9f97ae
3 changed files with 17 additions and 11 deletions

View file

@ -227,10 +227,17 @@ class WebappOptionForm(forms.ModelForm):
super().__init__(*args, **kwargs)
self.webapp = self.instance.webapp
target = 'this.id.replace("name", "value")'
self.fields['name'].widget.attrs = DynamicHelpTextSelect(target, self.OPTIONS_HELP_TEXT).attrs
def save(self, commit=True):
instance = super().save(commit=False)
instance.webapp = self.webapp
if commit:
super().save(commit=True)
self.webapp.save()
return instance
class WebappOptionCreateForm(WebappOptionForm):
@ -244,13 +251,6 @@ class WebappOptionCreateForm(WebappOptionForm):
choices[grupo] = (opciones[0], nueva_lista)
self.fields['name'].widget.choices = choices
def save(self, commit=True):
instance = super().save(commit=False)
instance.webapp = self.webapp
if commit:
super().save(commit=True)
return instance
def clean(self):
cleaned_data = super().clean()
name = self.cleaned_data.get("name")

View file

@ -734,6 +734,12 @@ class WebappDeleteOptionView(CustomContextMixin, UserTokenRequiredMixin, DeleteV
def get_success_url(self):
return reverse_lazy("musician:webapp-detail", kwargs={"pk": self.kwargs["pk"]})
def delete(self, request, *args, **kwargs):
object = self.get_object()
response = super().delete(request, *args, **kwargs)
object.webapp.save()
return response
class WebappUpdateOptionView(CustomContextMixin, UserTokenRequiredMixin, UpdateView):
model = WebAppOption

View file

@ -42,8 +42,8 @@ class WebAppServiceMixin(object):
# cambios de permisos en servidores nuevos
perms = Template(textwrap.dedent("""\
{% if sftpuser %}
chown -R {{ sftpuser }}:{{ sftpuser }} {{ app_path }}/* {% else %}
chown -R {{ user }}:{{ group }} {{ app_path }}/*
chown -R {{ sftpuser }}:{{ sftpuser }} {{ app_path }} {% else %}
chown -R {{ user }}:{{ group }} {{ app_path }}
{% endif %}
"""
))