Skip to content

Commit

Permalink
Merge pull request #161 from PetrDlouhy/fix_staticfiles
Browse files Browse the repository at this point in the history
fix gen_coll_tabular.html template
  • Loading branch information
coordt authored Sep 22, 2022
2 parents ba26126 + b08da9a commit c9c8d3d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions categories/templates/admin/edit_inline/gen_coll_tabular.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load i18n staticfiles %}
{% load i18n static %}
<div class="inline-group">
<div class="tabular inline-related {% if forloop.last %}last-related{% endif %}">
{{ inline_admin_formset.formset.management_form }}
Expand All @@ -17,7 +17,7 @@ <h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
{% if inline_admin_form.form.non_field_errors %}
<tr><td colspan="{{ inline_admin_form.field_count }}">{{ inline_admin_form.form.non_field_errors }}</td></tr>
{% endif %}
<tr class="{% cycle row1,row2 %} {% if inline_admin_form.original or inline_admin_form.show_url %}has_original{% endif %}">
<tr class="{% cycle 'row1' 'row2' %} {% if inline_admin_form.original or inline_admin_form.show_url %}has_original{% endif %}">
<td class="original">
{% if inline_admin_form.original or inline_admin_form.show_url %}<p>
{% if inline_admin_form.original %} {{ inline_admin_form.original.content_object }}{% endif %}
Expand Down
17 changes: 16 additions & 1 deletion categories/tests/test_admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib.auth.models import User
from django.test import Client, TestCase
from django.test.utils import override_settings
from django.urls import reverse
from django.utils.encoding import smart_str

Expand All @@ -9,9 +10,9 @@
class TestCategoryAdmin(TestCase):
def setUp(self):
self.client = Client()
self.superuser = User.objects.create_superuser("testuser", "testuser@example.com", "password")

def test_adding_parent_and_child(self):
User.objects.create_superuser("testuser", "testuser@example.com", "password")
self.client.login(username="testuser", password="password")
url = reverse("admin:categories_category_add")
data = {
Expand Down Expand Up @@ -65,3 +66,17 @@ def test_adding_parent_and_child(self):
url = reverse("admin:categories_category_changelist")
resp = self.client.get(url)
self.assertEqual(resp.status_code, 200)

@override_settings(RELATION_MODELS=True)
def test_addview_get(self):
self.client.force_login(self.superuser)
url = reverse("admin:categories_category_add")
resp = self.client.get(url)
self.assertEqual(resp.status_code, 200)
self.assertContains(resp, '<tr class="row1 ">')
self.assertContains(
resp,
'<input type="number" name="categoryrelation_set-0-object_id" class="vIntegerField" '
'min="0" id="id_categoryrelation_set-0-object_id">',
html=True,
)

0 comments on commit c9c8d3d

Please sign in to comment.