Repository: cisagov/manage.get.gov

Issue:
Add field for tribe locality on Tribal Goverment Question Page 
### Story

As a Registrant Applicant I want a way to specify the locality of my tribe so that I can give analysts more specific information to complete their review of my request

![tribalgovernment](https://github.com/cisagov/getgov/assets/107440934/48d1a8a2-e074-4ad2-9440-838eaa3e382a)


### Acceptance Criteria

- [x] Content is drafted for the question
- [x] Content is approved
- [x] Design prototype demonstrates the look and feel for approval
- [x] Implement the field in the registrar

A new field is added to the page that allows the user to specify the locality of their tribe

### Additional Context

_No response_

### Issue Links

_No response_


Discussion:
drafted content for this one in Google Docs. Waiting for feedback
copy approved!

Resolving patch:
diff --git a/src/registrar/templatetags/custom_filters.py b/src/registrar/templatetags/custom_filters.py
--- a/src/registrar/templatetags/custom_filters.py
+++ b/src/registrar/templatetags/custom_filters.py
@@ -23,3 +23,20 @@ def extract_a_text(value):
         extracted_text = ""
 
     return extracted_text
+
+
+@register.filter
+def find_index(haystack, needle):
+    try:
+        return haystack.index(needle)
+    except ValueError:
+        return -1
+
+
+@register.filter
+def slice_after(value, substring):
+    index = value.find(substring)
+    if index != -1:
+        result = value[index + len(substring) :]
+        return result
+    return value
diff --git a/src/registrar/views/utility/mixins.py b/src/registrar/views/utility/mixins.py
--- a/src/registrar/views/utility/mixins.py
+++ b/src/registrar/views/utility/mixins.py
@@ -24,6 +24,12 @@ def has_permission(self):
         The user is in self.request.user and the domain needs to be looked
         up from the domain's primary key in self.kwargs["pk"]
         """
+
+        # ticket 806
+        # if self.request.user is staff or admin and
+        # domain.application__status = 'approved' or 'rejected' or 'action needed'
+        #     return True
+
         if not self.request.user.is_authenticated:
             return False
 
@@ -33,6 +39,10 @@ def has_permission(self):
         ).exists():
             return False
 
+        # ticket 796
+        # if domain.application__status != 'approved'
+        #     return false
+
         # if we need to check more about the nature of role, do it here.
         return True
 


Test patch:
diff --git a/src/registrar/tests/test_templatetags.py b/src/registrar/tests/test_templatetags.py
--- a/src/registrar/tests/test_templatetags.py
+++ b/src/registrar/tests/test_templatetags.py
@@ -3,6 +3,12 @@
 from django.conf import settings
 from django.test import TestCase
 from django.template import Context, Template
+from registrar.templatetags.custom_filters import (
+    extract_value,
+    extract_a_text,
+    find_index,
+    slice_after,
+)
 
 
 class TestTemplateTags(TestCase):
@@ -33,8 +39,6 @@ def test_public_site_url_leading_slash(self):
 
 class CustomFiltersTestCase(TestCase):
     def test_extract_value_filter(self):
-        from registrar.templatetags.custom_filters import extract_value
-
         html_input = (
             '<input type="checkbox" name="_selected_action" value="123" '
             'id="label_123" class="action-select">'
@@ -50,8 +54,6 @@ def test_extract_value_filter(self):
         self.assertEqual(result, "abc")
 
     def test_extract_a_text_filter(self):
-        from registrar.templatetags.custom_filters import extract_a_text
-
         input_text = '<a href="#">Link Text</a>'
         result = extract_a_text(input_text)
         self.assertEqual(result, "Link Text")
@@ -59,3 +61,25 @@ def test_extract_a_text_filter(self):
         input_text = '<a href="/example">Another Link</a>'
         result = extract_a_text(input_text)
         self.assertEqual(result, "Another Link")
+
+    def test_find_index(self):
+        haystack = "Hello, World!"
+        needle = "lo"
+        result = find_index(haystack, needle)
+        self.assertEqual(result, 3)
+
+        needle = "XYZ"
+        result = find_index(haystack, needle)
+        self.assertEqual(result, -1)
+
+    def test_slice_after(self):
+        value = "Hello, World!"
+        substring = "lo"
+        result = slice_after(value, substring)
+        self.assertEqual(result, ", World!")
+
+        substring = "XYZ"
+        result = slice_after(value, substring)
+        self.assertEqual(
+            result, value
+        )  # Should return the original value if substring not found