model updates

This commit is contained in:
CocoByte 2024-06-12 15:47:13 -06:00
parent 1e98ba38b9
commit c9c6890e7d
No known key found for this signature in database
GPG key ID: BBFAA2526384C97F
4 changed files with 35 additions and 67 deletions

View file

@ -2464,6 +2464,23 @@ class VerifiedByStaffAdmin(ListHeaderAdmin):
super().save_model(request, obj, form, change)
class PortfolioAdmin(ListHeaderAdmin):
# list_display = ("email", "requestor", "truncated_notes", "created_at")
# search_fields = ["email"]
# search_help_text = "Search by email."
# readonly_fields = [
# "requestor",
# ]
# change_form_template = "django/admin/email_clipboard_change_form.html"
def save_model(self, request, obj, form, change):
# Set the creator field to the current admin user
obj.creator = request.user if request.user.is_authenticated else None
super().save_model(request, obj, form, change)
class FederalAgencyAdmin(ListHeaderAdmin):
list_display = ["agency"]
search_fields = ["agency"]

View file

@ -59,14 +59,14 @@ class DomainInformation(TimeStampedModel):
# portfolio
portfolio = models.OneToOneField(
"registrar.Portfolio",
on_delete=models.PROTECT,
null=True,
blank=True,
related_name="DomainRequest_portfolio",
help_text="Portfolio associated with this domain",
)
# portfolio = models.OneToOneField(
# "registrar.Portfolio",
# on_delete=models.PROTECT,
# null=True,
# blank=True,
# related_name="DomainRequest_portfolio",
# help_text="Portfolio associated with this domain",
# )
domain_request = models.OneToOneField(
"registrar.DomainRequest",

View file

@ -287,14 +287,14 @@ class DomainRequest(TimeStampedModel):
)
# portfolio
portfolio = models.OneToOneField(
"registrar.Portfolio",
on_delete=models.PROTECT,
null=True,
blank=True,
related_name="DomainInformation_portfolio",
help_text="Portfolio associated with this domain",
)
# portfolio = models.OneToOneField(
# "registrar.Portfolio",
# on_delete=models.PROTECT,
# null=True,
# blank=True,
# related_name="DomainInformation_portfolio",
# help_text="Portfolio associated with this domain",
# )
# This is the domain request user who created this domain request. The contact
# information that they gave is in the `submitter` field

View file

@ -10,34 +10,13 @@ from .utility.time_stamped_model import TimeStampedModel
class Portfolio(TimeStampedModel):
"""
TODO:
Portfolio is used for organizing domains/domain-requests into
manageable groups.
"""
class Meta:
"""Contains meta information about this class"""
indexes = [
models.Index(fields=["user"]),
models.Index(fields=["email"]),
]
# use the short names in Django admin
OrganizationChoices = DomainRequest.OrganizationChoices
# NOTE: This will be specified in a future ticket
# class PortfolioTypes(models.TextChoices):
# TYPE1 = "foo", "foo"
# TYPE2 = "foo", "foo"
# TYPE3 = "foo", "foo"
# TYPE4 = "foo", "foo"
# NOTE: This will be specified in a future ticket
# portfolio_type = models.TextField(
# choices=PortfolioTypes.choices,
# null=True,
# blank=True,
# )
# creator- user foreign key- stores who created this model should get the user who is adding
# it via django admin if there is a user (aka not done via commandline/ manual means)"""
@ -54,34 +33,6 @@ class Portfolio(TimeStampedModel):
null=True,
blank=True,
)
# # domains- many to many to Domain field (nullable)
# domains = models.ManyToManyField(
# "registrar.Domain",
# null=True,
# blank=True,
# related_name="portfolio domains",
# verbose_name="portfolio domains",
# # on_delete=models.PROTECT, # TODO: protect this?
# )
# # domain_requests- Many to many to Domain Request field (nullable)
# domain_requests = models.ManyToManyField(
# "registrar.DomainRequest",
# null=True,
# blank=True,
# related_name="portfolio domain requests",
# verbose_name="portfolio domain requests",
# # on_delete=models.PROTECT, # TODO: protect this?
# )
# # organization
# organization = models.OneToOneField(
# "registrar.Organization",
# 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(