diff --git a/src/registrar/assets/sass/_theme/_admin.scss b/src/registrar/assets/sass/_theme/_admin.scss new file mode 100644 index 000000000..afba7f44f --- /dev/null +++ b/src/registrar/assets/sass/_theme/_admin.scss @@ -0,0 +1,6 @@ +.min-width-25 { + min-width: 25px; +} +.min-width-81 { + min-width: 81px; +} diff --git a/src/registrar/assets/sass/_theme/cisa_colors.scss b/src/registrar/assets/sass/_theme/_cisa_colors.scss similarity index 100% rename from src/registrar/assets/sass/_theme/cisa_colors.scss rename to src/registrar/assets/sass/_theme/_cisa_colors.scss diff --git a/src/registrar/assets/sass/_theme/styles.scss b/src/registrar/assets/sass/_theme/styles.scss index aef29a7f5..fc98416e8 100644 --- a/src/registrar/assets/sass/_theme/styles.scss +++ b/src/registrar/assets/sass/_theme/styles.scss @@ -9,3 +9,7 @@ /*-------------------------------------------------- --- Custom Styles ---------------------------------*/ @forward "uswds-theme-custom-styles"; + +/*-------------------------------------------------- +--- Admin ---------------------------------*/ +@forward "admin"; \ No newline at end of file diff --git a/src/registrar/templates/admin/app_list.html b/src/registrar/templates/admin/app_list.html new file mode 100644 index 000000000..fb5934470 --- /dev/null +++ b/src/registrar/templates/admin/app_list.html @@ -0,0 +1,56 @@ +{% load i18n %} + +{% if app_list %} + {% for app in app_list %} +
+ + + + {# .gov override #} + + + + + {% if show_changelinks %} + + + {% endif %} + + + {# end .gov override #} + + {% for model in app.models %} + + {% if model.admin_url %} + + {% else %} + + {% endif %} + + {% if model.add_url %} + + {% else %} + + {% endif %} + + {% if model.admin_url and show_changelinks %} + {% if model.view_only %} + + {% else %} + + {% endif %} + {% elif show_changelinks %} + + {% endif %} + + {% endfor %} +
+ {{ app.name }} +
ModelAdd + + {% translate 'View/Change' %}
{{ model.name }}{{ model.name }}{% translate 'Add' %}{% translate 'View' %}{% translate 'Change' %}
+
+ {% endfor %} +{% else %} +

{% translate 'You don’t have permission to view or edit anything.' %}

+{% endif %} \ No newline at end of file diff --git a/src/registrar/templates/admin/base_site.html b/src/registrar/templates/admin/base_site.html new file mode 100644 index 000000000..1887ea332 --- /dev/null +++ b/src/registrar/templates/admin/base_site.html @@ -0,0 +1,15 @@ +{% extends "admin/base.html" %} +{% load static %} + +{% block title %}{% if subtitle %}{{ subtitle }} | {% endif %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %} + +{% block extrastyle %}{{ block.super }}{% endblock %} + +{% block branding %} +

.gov admin

+{% if user.is_anonymous %} + {% include "admin/color_theme_toggle.html" %} +{% endif %} +{% endblock %} + +{% block nav-global %}{% endblock %} \ No newline at end of file diff --git a/src/registrar/templates/admin/change_list_results.html b/src/registrar/templates/admin/change_list_results.html new file mode 100644 index 000000000..1b8f40b1e --- /dev/null +++ b/src/registrar/templates/admin/change_list_results.html @@ -0,0 +1,90 @@ +{% load i18n static %} + +{% comment %} +.gov override +Load our custom filters to extract info from the django generated markup. +{% endcomment %} +{% load custom_filters %} + +{% if result_hidden_fields %} +
{# DIV for HTML validation #} +{% for item in result_hidden_fields %}{{ item }}{% endfor %} +
+{% endif %} +{% if results %} +
+ + + + +{# .gov - hardcode the select all checkbox #} + +{# .gov - don't let django generate the select all checkbox #} +{% for header in result_headers|slice:"1:" %} + +{% endfor %} + + + + + +{% comment %} +{% for result in results %} +{% if result.form.non_field_errors %} + +{% endif %} +{% for item in result %}{{ item }}{% endfor %} +{% endfor %} +{% endcomment %} + +{% comment %} +.gov - hardcode the row checkboxes using the custom filters to extract +the value attribute's value, and a label based on the anchor elements's +text. Then edit the for loop to keep django from generating the row select +checkboxes. +{% endcomment %} +{% for result in results %} + {% if result.form.non_field_errors %} + + {% endif %} + + + {% with result_value=result.0|extract_value %} + {% with result_label=result.1|extract_a_text %} + + {% endwith %} + {% endwith %} + + {% for item in result|slice:"1:" %} + {{ item }} + {% endfor %} + +{% endfor %} + + +
+
+ + + + +
+
+
+ {% if header.sortable %} + {% if header.sort_priority > 0 %} +
+ + {% if num_sorted_fields > 1 %}{{ header.sort_priority }}{% endif %} + +
+ {% endif %} + {% endif %} +
{% if header.sortable %}{{ header.text|capfirst }}{% else %}{{ header.text|capfirst }}{% endif %}
+
+
{{ result.form.non_field_errors }}
{{ result.form.non_field_errors }}
+ + +
+
+{% endif %} \ No newline at end of file diff --git a/src/registrar/templatetags/custom_filters.py b/src/registrar/templatetags/custom_filters.py new file mode 100644 index 000000000..a22b15a28 --- /dev/null +++ b/src/registrar/templatetags/custom_filters.py @@ -0,0 +1,25 @@ +from django import template +import re + +register = template.Library() + + +@register.filter(name="extract_value") +def extract_value(html_input): + match = re.search(r'value="([^"]*)"', html_input) + if match: + return match.group(1) + return "" + + +@register.filter +def extract_a_text(value): + # Use regex to extract the text within the tag + pattern = r"]*>(.*?)" + match = re.search(pattern, value) + if match: + extracted_text = match.group(1) + else: + extracted_text = "" + + return extracted_text diff --git a/src/registrar/tests/test_templatetags.py b/src/registrar/tests/test_templatetags.py index 681d823b7..0d1eed4fc 100644 --- a/src/registrar/tests/test_templatetags.py +++ b/src/registrar/tests/test_templatetags.py @@ -29,3 +29,33 @@ class TestTemplateTags(TestCase): self.assertTrue(result.startswith(settings.GETGOV_PUBLIC_SITE_URL)) # slash-slash host slash directory slash page self.assertEqual(result.count("/"), 4) + + +class CustomFiltersTestCase(TestCase): + def test_extract_value_filter(self): + from registrar.templatetags.custom_filters import extract_value + + html_input = ( + '' + ) + result = extract_value(html_input) + self.assertEqual(result, "123") + + html_input = ( + '' + ) + result = extract_value(html_input) + self.assertEqual(result, "abc") + + def test_extract_a_text_filter(self): + from registrar.templatetags.custom_filters import extract_a_text + + input_text = 'Link Text' + result = extract_a_text(input_text) + self.assertEqual(result, "Link Text") + + input_text = 'Another Link' + result = extract_a_text(input_text) + self.assertEqual(result, "Another Link")