Refactor test utilities and enhance ASGI settings

- Cleaned up and standardized assertions in ApiTestMixin for API response validation.
- Updated ASGI settings to use os.environ for setting the DJANGO_SETTINGS_MODULE.
- Removed unused imports and improved formatting in settings.py.
- Refactored URL patterns in urls.py for better readability and organization.
- Enhanced view functions in views.py for consistency and clarity.
- Added .flake8 configuration for linting and style enforcement.
- Introduced type stubs for django-environ to improve type checking with Pylance.
This commit is contained in:
pacnpal
2025-08-20 19:51:59 -04:00
parent 69c07d1381
commit 66ed4347a9
230 changed files with 15094 additions and 11578 deletions

View File

@@ -14,15 +14,15 @@ class Company(TrackedModel):
objects = CompanyManager()
class CompanyRole(models.TextChoices):
OPERATOR = 'OPERATOR', 'Park Operator'
PROPERTY_OWNER = 'PROPERTY_OWNER', 'Property Owner'
OPERATOR = "OPERATOR", "Park Operator"
PROPERTY_OWNER = "PROPERTY_OWNER", "Property Owner"
name = models.CharField(max_length=255)
slug = models.SlugField(max_length=255, unique=True)
roles = ArrayField(
models.CharField(max_length=20, choices=CompanyRole.choices),
default=list,
blank=True
blank=True,
)
description = models.TextField(blank=True)
website = models.URLField(blank=True)
@@ -41,8 +41,8 @@ class Company(TrackedModel):
return self.name
class Meta:
ordering = ['name']
verbose_name_plural = 'Companies'
ordering = ["name"]
verbose_name_plural = "Companies"
class CompanyHeadquarters(models.Model):
@@ -50,46 +50,41 @@ class CompanyHeadquarters(models.Model):
Simple address storage for company headquarters without coordinate tracking.
Focus on human-readable location information for display purposes.
"""
# Relationships
company = models.OneToOneField(
'Company',
on_delete=models.CASCADE,
related_name='headquarters'
"Company", on_delete=models.CASCADE, related_name="headquarters"
)
# Address Fields (No coordinates needed)
street_address = models.CharField(
max_length=255,
blank=True,
help_text="Mailing address if publicly available"
help_text="Mailing address if publicly available",
)
city = models.CharField(
max_length=100,
db_index=True,
help_text="Headquarters city"
max_length=100, db_index=True, help_text="Headquarters city"
)
state_province = models.CharField(
max_length=100,
blank=True,
db_index=True,
help_text="State/Province/Region"
help_text="State/Province/Region",
)
country = models.CharField(
max_length=100,
default='USA',
default="USA",
db_index=True,
help_text="Country where headquarters is located"
help_text="Country where headquarters is located",
)
postal_code = models.CharField(
max_length=20,
blank=True,
help_text="ZIP or postal code"
max_length=20, blank=True, help_text="ZIP or postal code"
)
# Optional mailing address if different or more complete
mailing_address = models.TextField(
blank=True,
help_text="Complete mailing address if different from basic address"
help_text="Complete mailing address if different from basic address",
)
# Metadata
@@ -108,9 +103,15 @@ class CompanyHeadquarters(models.Model):
components.append(self.state_province)
if self.postal_code:
components.append(self.postal_code)
if self.country and self.country != 'USA':
if self.country and self.country != "USA":
components.append(self.country)
return ", ".join(components) if components else f"{self.city}, {self.country}"
return (
", ".join(components)
if components
else f"{
self.city}, {
self.country}"
)
@property
def location_display(self):
@@ -118,7 +119,7 @@ class CompanyHeadquarters(models.Model):
parts = [self.city]
if self.state_province:
parts.append(self.state_province)
elif self.country != 'USA':
elif self.country != "USA":
parts.append(self.country)
return ", ".join(parts) if parts else "Unknown Location"
@@ -128,7 +129,7 @@ class CompanyHeadquarters(models.Model):
class Meta:
verbose_name = "Company Headquarters"
verbose_name_plural = "Company Headquarters"
ordering = ['company__name']
ordering = ["company__name"]
indexes = [
models.Index(fields=['city', 'country']),
models.Index(fields=["city", "country"]),
]