diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 226527e28..25f2afe34 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -2562,9 +2562,11 @@ class PortfolioAdmin(ListHeaderAdmin): # ] def save_model(self, request, obj, form, change): - # ---- update creator ---- - # Set the creator field to the current admin user - obj.creator = request.user if request.user.is_authenticated else None + + if not obj.creator is None: + # ---- update creator ---- + # Set the creator field to the current admin user + obj.creator = request.user if request.user.is_authenticated else None # ---- update organization name ---- # org name will be the same as federal agency, if it is federal, diff --git a/src/registrar/migrations/0103_portfolio_domaininformation_portfolio_and_more.py b/src/registrar/migrations/0103_portfolio_domaininformation_portfolio_and_more.py index 3edc34b2a..df0945712 100644 --- a/src/registrar/migrations/0103_portfolio_domaininformation_portfolio_and_more.py +++ b/src/registrar/migrations/0103_portfolio_domaininformation_portfolio_and_more.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.10 on 2024-06-17 19:47 +# Generated by Django 4.2.10 on 2024-06-18 03:19 from django.conf import settings from django.db import migrations, models @@ -150,7 +150,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name="domaininformation", name="portfolio", - field=models.OneToOneField( + field=models.ForeignKey( blank=True, help_text="Portfolio associated with this domain", null=True, @@ -162,7 +162,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name="domainrequest", name="portfolio", - field=models.OneToOneField( + field=models.ForeignKey( blank=True, help_text="Portfolio associated with this domain request", null=True, diff --git a/src/registrar/models/domain_information.py b/src/registrar/models/domain_information.py index c058ab209..b6f2dd9a7 100644 --- a/src/registrar/models/domain_information.py +++ b/src/registrar/models/domain_information.py @@ -58,7 +58,7 @@ class DomainInformation(TimeStampedModel): ) # portfolio - portfolio = models.OneToOneField( + portfolio = models.ForeignKey( "registrar.Portfolio", on_delete=models.PROTECT, null=True, diff --git a/src/registrar/models/domain_request.py b/src/registrar/models/domain_request.py index dfb57cee0..1c4725be1 100644 --- a/src/registrar/models/domain_request.py +++ b/src/registrar/models/domain_request.py @@ -304,7 +304,7 @@ class DomainRequest(TimeStampedModel): ) # portfolio - portfolio = models.OneToOneField( + portfolio = models.ForeignKey( "registrar.Portfolio", on_delete=models.PROTECT, null=True, diff --git a/src/registrar/models/portfolio.py b/src/registrar/models/portfolio.py index 14de445c2..b3131cb87 100644 --- a/src/registrar/models/portfolio.py +++ b/src/registrar/models/portfolio.py @@ -21,18 +21,15 @@ class Portfolio(TimeStampedModel): OrganizationChoices = DomainRequest.OrganizationChoices StateTerritoryChoices = DomainRequest.StateTerritoryChoices - # creator - stores who created this model. If no creator is specified in DJA, + # Stores who created this model. If no creator is specified in DJA, # then the creator will default to the current request user""" creator = models.ForeignKey("registrar.User", on_delete=models.PROTECT, help_text="Associated user", unique=False) - # notes - text field (copies what is done on domain requests) notes = models.TextField( null=True, blank=True, ) - # federal agency - FK to fed agency table (Not nullable, should default - # to the Non-federal agency value in the fed agency table) federal_agency = models.ForeignKey( "registrar.FederalAgency", on_delete=models.PROTECT, @@ -41,7 +38,6 @@ class Portfolio(TimeStampedModel): default=get_default_federal_agency, ) - # organization type - should match organization types allowed on domain info organization_type = models.CharField( max_length=255, choices=OrganizationChoices.choices, @@ -50,34 +46,29 @@ class Portfolio(TimeStampedModel): help_text="Type of organization", ) - # organization name - # NOTE: org name will be the same as federal agency, if it is federal, - # otherwise it will be the actual org name. If nothing is entered for - # org name and it is a federal organization, have this field fill with - # the federal agency text name. organization_name = models.CharField( null=True, blank=True, ) - # address_line1 address_line1 = models.CharField( null=True, blank=True, verbose_name="address line 1", ) - # address_line2 + address_line2 = models.CharField( null=True, blank=True, verbose_name="address line 2", ) - # city + city = models.CharField( null=True, blank=True, ) - # state (copied from domain_request.py -- imports enums from domain_request.py) + + # (imports enums from domain_request.py) state_territory = models.CharField( max_length=2, choices=StateTerritoryChoices.choices, @@ -85,14 +76,14 @@ class Portfolio(TimeStampedModel): blank=True, verbose_name="state / territory", ) - # zipcode + zipcode = models.CharField( max_length=10, null=True, blank=True, verbose_name="zip code", ) - # urbanization + urbanization = models.CharField( null=True, blank=True, @@ -100,7 +91,6 @@ class Portfolio(TimeStampedModel): verbose_name="urbanization", ) - # security_contact_email security_contact_email = models.EmailField( null=True, blank=True,