mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-20 09:46:06 +02:00
Cleanup unused content
This commit is contained in:
parent
3837359977
commit
0218da50d8
3 changed files with 13 additions and 61 deletions
|
@ -98,14 +98,8 @@ class PortfolioSeniorOfficialForm(forms.ModelForm):
|
||||||
"full_name": forms.TextInput(attrs={"readonly": "readonly"})
|
"full_name": forms.TextInput(attrs={"readonly": "readonly"})
|
||||||
}
|
}
|
||||||
|
|
||||||
# the database fields have blank=True so ModelForm doesn't create
|
|
||||||
# required fields by default. Use this list in __init__ to mark each
|
|
||||||
# of these fields as required
|
|
||||||
required = ["first_name", "last_name", "title", "email"]
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
for field_name in self.required:
|
|
||||||
self.fields[field_name].required = True
|
|
||||||
|
|
||||||
if self.instance:
|
if self.instance:
|
||||||
self.fields["full_name"].initial = self.instance.get_formatted_name()
|
self.fields["full_name"].initial = self.instance.get_formatted_name()
|
||||||
|
|
|
@ -23,20 +23,6 @@
|
||||||
|
|
||||||
<p>Your senior official is a person within your organization who can authorize domain requests.</p>
|
<p>Your senior official is a person within your organization who can authorize domain requests.</p>
|
||||||
|
|
||||||
{% if santa_exists %}
|
|
||||||
{% include "includes/form_errors.html" with form=form %}
|
|
||||||
{% include "includes/required_fields.html" %}
|
|
||||||
<form class="usa-form usa-form--large" method="post" novalidate>
|
|
||||||
{% csrf_token %}
|
|
||||||
{% input_with_errors form.first_name %}
|
|
||||||
{% input_with_errors form.last_name %}
|
|
||||||
{% input_with_errors form.title %}
|
|
||||||
{% input_with_errors form.email %}
|
|
||||||
<button type="submit" class="usa-button">
|
|
||||||
Save
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
{% else %}
|
|
||||||
<p>The senior official for your organization can’t be updated here. To suggest an update, email <a href="mailto:help@get.gov" class="usa-link">help@get.gov</a></p>
|
<p>The senior official for your organization can’t be updated here. To suggest an update, email <a href="mailto:help@get.gov" class="usa-link">help@get.gov</a></p>
|
||||||
|
|
||||||
{% if not senior_official %}
|
{% if not senior_official %}
|
||||||
|
@ -52,7 +38,6 @@
|
||||||
{% include "includes/input_read_only.html" with field=form.email %}
|
{% include "includes/input_read_only.html" with field=form.email %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -99,6 +99,7 @@ class PortfolioOrganizationView(PortfolioBasePermissionView, FormMixin):
|
||||||
class PortfolioSeniorOfficialView(PortfolioBasePermissionView, FormMixin):
|
class PortfolioSeniorOfficialView(PortfolioBasePermissionView, FormMixin):
|
||||||
"""
|
"""
|
||||||
View to handle displaying and updating the portfolio's senior official details.
|
View to handle displaying and updating the portfolio's senior official details.
|
||||||
|
For now, this view is readonly.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
model = Portfolio
|
model = Portfolio
|
||||||
|
@ -130,31 +131,3 @@ class PortfolioSeniorOfficialView(PortfolioBasePermissionView, FormMixin):
|
||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
form = self.get_form()
|
form = self.get_form()
|
||||||
return self.render_to_response(self.get_context_data(form=form))
|
return self.render_to_response(self.get_context_data(form=form))
|
||||||
|
|
||||||
# These functions are included for future compatibility, but for now
|
|
||||||
# we do not offer an edit mode for senior officials.
|
|
||||||
def post(self, request, *args, **kwargs):
|
|
||||||
"""Handle POST requests to process form submission."""
|
|
||||||
self.object = self.get_object()
|
|
||||||
form = self.get_form()
|
|
||||||
if form.is_valid():
|
|
||||||
return self.form_valid(form)
|
|
||||||
else:
|
|
||||||
return self.form_invalid(form)
|
|
||||||
|
|
||||||
def form_valid(self, form):
|
|
||||||
"""Handle the case when the form is valid."""
|
|
||||||
senior_official = form.save()
|
|
||||||
portfolio = self.get_object()
|
|
||||||
portfolio.senior_official = senior_official
|
|
||||||
portfolio.save()
|
|
||||||
messages.success(self.request, "The Senior Official for this portfolio has been updated.")
|
|
||||||
return super().form_valid(form)
|
|
||||||
|
|
||||||
def form_invalid(self, form):
|
|
||||||
"""Handle the case when the form is invalid."""
|
|
||||||
return self.render_to_response(self.get_context_data(form=form))
|
|
||||||
|
|
||||||
def get_success_url(self):
|
|
||||||
"""Redirect to the overview page for the portfolio."""
|
|
||||||
return reverse("senior-official")
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue