# Path: countylimits/models.py
# class CountyLimit(models.Model):
#     """County limit object."""
# 
#     fha_limit = models.DecimalField(
#         max_digits=12,
#         decimal_places=2,
#         help_text="Federal Housing Administration "
#         "loan lending limit for the county",
#     )
#     gse_limit = models.DecimalField(
#         max_digits=12,
#         decimal_places=2,
#         help_text="Loan limit for mortgages acquired "
#         "by the Government-Sponsored Enterprises",
#     )
#     va_limit = models.DecimalField(
#         max_digits=12,
#         decimal_places=2,
#         help_text="The Department of Veterans Affairs "
#         "loan guaranty program limit",
#     )
#     county = models.OneToOneField(County, on_delete=models.CASCADE)
# 
#     def __str__(self):
#         return "CountyLimit %s" % self.id
# 
#     @staticmethod
#     def county_limits_by_state(state):
#         """Get a list of state counties with limits."""
#         data = []
#         # state value can be a State FIPS or a state abbr.
#         state_obj = State.objects.filter(
#             models.Q(state_fips=state) | models.Q(state_abbr=state)
#         ).first()
#         limits = CountyLimit.objects.filter(county__state=state_obj)
#         for countylimit in limits:
#             data.append(
#                 {
#                     "state": str(abbr_to_name[state_obj.state_abbr]),
#                     "county": countylimit.county.county_name,
#                     "complete_fips": "{}{}".format(
#                         state_obj.state_fips, countylimit.county.county_fips
#                     ),
#                     "gse_limit": str(countylimit.gse_limit),
#                     "fha_limit": str(countylimit.fha_limit),
#                     "va_limit": str(countylimit.va_limit),
#                 }
#             )
#         return data


from countylimits.models import CountyLimit
from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response
    "41",
    "42",
    "44",
    "45",
    "46",
    "47",
    "48",
    "49",
    "50",
    "51",
    "53",
    "54",
    "55",
    "56",
    "60",
    "66",
    "69",
    "72",
    "78",
]


@api_view(["GET"])
def county_limits(request):
    """Return all counties with their limits per state."""
    if request.method == "GET":
        package = {"request": {}, "data": []}
        if "state" in request.GET:
            state = request.GET["state"]
            if state in SAFE_STATE_LIST:

# Path: countylimits/models.py
# class CountyLimit(models.Model):
#     """County limit object."""
# 
#     fha_limit = models.DecimalField(
#         max_digits=12,
#         decimal_places=2,
#         help_text="Federal Housing Administration "
#         "loan lending limit for the county",
#     )
#     gse_limit = models.DecimalField(
#         max_digits=12,
#         decimal_places=2,
#         help_text="Loan limit for mortgages acquired "
#         "by the Government-Sponsored Enterprises",
#     )
#     va_limit = models.DecimalField(
#         max_digits=12,
#         decimal_places=2,
#         help_text="The Department of Veterans Affairs "
#         "loan guaranty program limit",
#     )
#     county = models.OneToOneField(County, on_delete=models.CASCADE)
# 
#     def __str__(self):
#         return "CountyLimit %s" % self.id
# 
#     @staticmethod
#     def county_limits_by_state(state):
#         """Get a list of state counties with limits."""
#         data = []
#         # state value can be a State FIPS or a state abbr.
#         state_obj = State.objects.filter(
#             models.Q(state_fips=state) | models.Q(state_abbr=state)
#         ).first()
#         limits = CountyLimit.objects.filter(county__state=state_obj)
#         for countylimit in limits:
#             data.append(
#                 {
#                     "state": str(abbr_to_name[state_obj.state_abbr]),
#                     "county": countylimit.county.county_name,
#                     "complete_fips": "{}{}".format(
#                         state_obj.state_fips, countylimit.county.county_fips
#                     ),
#                     "gse_limit": str(countylimit.gse_limit),
#                     "fha_limit": str(countylimit.fha_limit),
#                     "va_limit": str(countylimit.va_limit),
#                 }
#             )
#         return data


# Path: countylimits/views.py
from countylimits.models import CountyLimit
from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response

    "41",
    "42",
    "44",
    "45",
    "46",
    "47",
    "48",
    "49",
    "50",
    "51",
    "53",
    "54",
    "55",
    "56",
    "60",
    "66",
    "69",
    "72",
    "78",
]


@api_view(["GET"])
def county_limits(request):
    """Return all counties with their limits per state."""
    if request.method == "GET":
        package = {"request": {}, "data": []}
        if "state" in request.GET:
            state = request.GET["state"]
            if state in SAFE_STATE_LIST:

                data = CountyLimit.county_limits_by_state(state)