Fix suborg issue

This commit is contained in:
zandercymatics 2024-08-12 10:24:36 -06:00
parent bd615a18a2
commit 60c4f54e63
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
3 changed files with 8 additions and 5 deletions

View file

@ -189,10 +189,6 @@ class DomainSuborganizationForm(forms.ModelForm):
if self.instance and self.instance.sub_organization:
self.fields["sub_organization"].widget.attrs["data-default-value"] = self.instance.sub_organization.pk
def get_suborganization_name(self):
"""Returns the suborganization name for the readonly view"""
return self.instance.sub_organization.name if self.instance else None
class BaseNameserverFormset(forms.BaseFormSet):
def clean(self):

View file

@ -25,7 +25,7 @@
</form>
{% else %}
{% with description="The suborganization for this domain can only be updated by a organization administrator."%}
{% include "includes/input_read_only.html" with field=form.sub_organization value=instance.get_suborganization_name label_description=description%}
{% include "includes/input_read_only.html" with field=form.sub_organization value=suborganization_name label_description=description%}
{% endwith %}
{% endif %}
{% endblock %}

View file

@ -250,6 +250,13 @@ class DomainSubOrganizationView(DomainFormBaseView):
context_object_name = "domain"
form_class = DomainSuborganizationForm
def get_context_data(self, **kwargs):
"""Adds custom context."""
context = super().get_context_data(**kwargs)
if self.object and self.object.domain_info and self.object.domain_info.sub_organization:
context["suborganization_name"] = self.object.domain_info.sub_organization.name
return context
def get_form_kwargs(self, *args, **kwargs):
"""Add domain_info.organization_name instance to make a bound form."""
form_kwargs = super().get_form_kwargs(*args, **kwargs)