mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 18:09:25 +02:00
Fix bugs with email
This commit is contained in:
parent
d9ec108f58
commit
87d51c1002
4 changed files with 59 additions and 27 deletions
|
@ -1205,7 +1205,8 @@ class DomainRequest(TimeStampedModel):
|
|||
return False
|
||||
|
||||
def is_suborganization(self) -> bool:
|
||||
"""Determines if this record is a suborganization or not"""
|
||||
"""Determines if this record is a suborganization or not by checking if a suborganization exists,
|
||||
and if it doesn't, determining if properties like requested_suborganization exist."""
|
||||
if self.portfolio:
|
||||
if self.sub_organization:
|
||||
return True
|
||||
|
@ -1216,12 +1217,18 @@ class DomainRequest(TimeStampedModel):
|
|||
return False
|
||||
|
||||
def is_custom_suborganization(self) -> bool:
|
||||
"""Used on the requesting entity form to determine if a user is trying to request
|
||||
a new suborganization using the domain request form.
|
||||
|
||||
This only occurs when no suborganization is selected, but they've filled out
|
||||
the requested_suborganization, suborganization_city, and suborganization_state_territory fields.
|
||||
"""
|
||||
if self.is_suborganization():
|
||||
return not self.sub_organization and self.has_information_required_to_make_suborganization()
|
||||
else:
|
||||
return False
|
||||
|
||||
def has_information_required_to_make_suborganization(self):
|
||||
def has_information_required_to_make_suborganization(self) -> bool:
|
||||
"""Checks if we have all the information we need to create a new suborganization object.
|
||||
Checks for a the existence of requested_suborganization, suborganization_city, suborganization_state_territory"""
|
||||
if self.requested_suborganization and self.suborganization_city and self.suborganization_state_territory:
|
||||
|
|
|
@ -2,6 +2,8 @@ from django.db import models
|
|||
|
||||
from registrar.models.domain_request import DomainRequest
|
||||
from registrar.models.federal_agency import FederalAgency
|
||||
from registrar.models.user import User
|
||||
from registrar.models.utility.portfolio_helper import UserPortfolioRoleChoices
|
||||
|
||||
from .utility.time_stamped_model import TimeStampedModel
|
||||
|
||||
|
@ -131,6 +133,17 @@ class Portfolio(TimeStampedModel):
|
|||
def get_federal_type(cls, federal_agency):
|
||||
return federal_agency.federal_type if federal_agency else None
|
||||
|
||||
@property
|
||||
def portfolio_admin_users(self):
|
||||
"""Gets all users with the role organization_admin for this particular portfolio.
|
||||
Returns a queryset of User."""
|
||||
admin_ids = self.portfolio_users.filter(
|
||||
roles__overlap=[
|
||||
UserPortfolioRoleChoices.ORGANIZATION_ADMIN,
|
||||
],
|
||||
).values_list("user__id", flat=True)
|
||||
return User.objects.filter(id__in=admin_ids)
|
||||
|
||||
# == Getters for domains == #
|
||||
def get_domains(self, order_by=None):
|
||||
"""Returns all DomainInformations associated with this portfolio"""
|
||||
|
|
|
@ -1,16 +1,7 @@
|
|||
SUMMARY OF YOUR DOMAIN REQUEST
|
||||
{% load custom_filters %}SUMMARY OF YOUR DOMAIN REQUEST
|
||||
|
||||
Requesting entity:
|
||||
{% if domain_request.portfolio and domain_request.organization_name == domain_request.portfolio.organization_name %}
|
||||
{{domain_request.portfolio.organization_name}}
|
||||
{{domain_request.portfolio.city}}, {{domain_request.portfolio.state_territory}}
|
||||
{% elif domain_request.sub_organization %}
|
||||
{{domain_request.sub_organization}}
|
||||
{% comment %} We don't have city or state_territory for suborganizations yet, so no data should display {% endcomment %}
|
||||
{% elif domain_request.requested_suborganization and domain_request.suborganization_city and domain_request.suborganization_state_territory %}
|
||||
{{domain_request.requested_suborganization}}
|
||||
{{domain_request.suborganization_city}}, {{domain_request.suborganization_state_territory}}
|
||||
{% endif %}
|
||||
Requesting entity: {# if blockmakes a newline #}
|
||||
{{ domain_request|display_requesting_entity }}
|
||||
{% if domain_request.current_websites.exists %}
|
||||
Current websites: {% for site in domain_request.current_websites.all %}
|
||||
{% spaceless %}{{ site.website }}{% endspaceless %}
|
||||
|
@ -23,19 +14,16 @@ Alternative domains:
|
|||
{% endfor %}{% endif %}
|
||||
Purpose of your domain:
|
||||
{{ domain_request.purpose }}
|
||||
{% if domain_request.additional_details%}
|
||||
{% if domain_request.anything_else %}
|
||||
Additional details:
|
||||
{{ domain_request.additional_details }}
|
||||
{% endif %}
|
||||
|
||||
Your contact information:
|
||||
{% spaceless %}{% include "emails/includes/contact.txt" with contact=recipient %}{% endspaceless %}
|
||||
|
||||
Other employees from your organization:{% for other in domain_request.other_contacts.all %}
|
||||
{% spaceless %}{% include "emails/includes/contact.txt" with contact=other %}{% endspaceless %}
|
||||
{% empty %}
|
||||
{{ domain_request.no_other_contacts_rationale }}
|
||||
{% endfor %}{% if domain_request.anything_else %}
|
||||
Anything else?
|
||||
{{ domain_request.anything_else }}
|
||||
{% endif %}
|
||||
{% if recipient %}
|
||||
Your contact information:
|
||||
{% spaceless %}{% include "emails/includes/contact.txt" with contact=recipient %}{% endspaceless %}
|
||||
{% endif %}
|
||||
|
||||
Administrators from your organization:{% for admin in domain_request.portfolio.portfolio_admin_users %}
|
||||
{% spaceless %}{% if admin != recipient %}{% include "emails/includes/contact.txt" with contact=admin %}{% endif %}{% endspaceless %}
|
||||
{% endfor %}
|
||||
|
||||
|
|
|
@ -257,3 +257,27 @@ def portfolio_role_summary(user, portfolio):
|
|||
return user.portfolio_role_summary(portfolio)
|
||||
else:
|
||||
return []
|
||||
|
||||
@register.filter(name="display_requesting_entity")
|
||||
def display_requesting_entity(domain_request):
|
||||
"""Workaround for a newline issue in .txt files (our emails) as if statements
|
||||
count as a newline to the file.
|
||||
Will output something that looks like:
|
||||
MyOrganizationName
|
||||
Boise, ID
|
||||
"""
|
||||
display = ""
|
||||
if domain_request.portfolio and domain_request.organization_name == domain_request.portfolio.organization_name:
|
||||
display = (
|
||||
f"{domain_request.portfolio.organization_name}\n"
|
||||
f"{domain_request.portfolio.city}, {domain_request.portfolio.state_territory}"
|
||||
)
|
||||
elif domain_request.sub_organization:
|
||||
display = domain_request.sub_organization
|
||||
elif domain_request.has_information_required_to_make_suborganization():
|
||||
display = (
|
||||
f"{domain_request.requested_suborganization}\n"
|
||||
f"{domain_request.suborganization_city}, {domain_request.suborganization_state_territory}"
|
||||
)
|
||||
|
||||
return display
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue