Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed #21299 - Changed filters from title to capfirst on admin inline formsets. #1800

Closed
wants to merge 4 commits into from

2 participants

@renatooliveira

I don't if I have to make tests for this one, waiting for an advice.

https://code.djangoproject.com/ticket/21299

@timgraham
Owner

I don't think this warrants any new tests, but we need to update the existing ones. Here are the failures I see (including some selenium tests).

ERROR: test_prepopulated_fields (admin_views.tests.SeleniumAdminViewsFirefoxTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/django/tests/admin_views/tests.py", line 3446, in test_prepopulated_fields
    self.selenium.find_elements_by_link_text('Add another Related Prepopulated')[0].click()
IndexError: list index out of range

======================================================================
ERROR: test_add_stackeds (admin_inlines.tests.SeleniumFirefoxTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/django/tests/admin_inlines/tests.py", line 557, in test_add_stackeds
    'Add another Inner4 Stacked')
  File "/home/vagrant/.virtualenvs/py2.7/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 241, in find_element_by_link_text
    return self.find_element(by=By.LINK_TEXT, value=link_text)
  File "/home/vagrant/.virtualenvs/py2.7/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 675, in find_element
    {'using': by, 'value': value})['value']
  File "/home/vagrant/.virtualenvs/py2.7/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 160, in execute
    self.error_handler.check_response(response)
  File "/home/vagrant/.virtualenvs/py2.7/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 149, in check_response
    raise exception_class(message, screen, stacktrace)
NoSuchElementException: Message: u'Unable to locate element: {"method":"link text","selector":"Add another Inner4 Stacked"}' ; Stacktrace: Method FirefoxDriver.prototype.findElementInternal_ threw an error in file:///tmp/tmpcMYmWl/extensions/fxdriver@googlecode.com/components/driver_component.js 

======================================================================
ERROR: test_delete_stackeds (admin_inlines.tests.SeleniumFirefoxTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/django/tests/admin_inlines/tests.py", line 573, in test_delete_stackeds
    'Add another Inner4 Stacked')
  File "/home/vagrant/.virtualenvs/py2.7/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 241, in find_element_by_link_text
    return self.find_element(by=By.LINK_TEXT, value=link_text)
  File "/home/vagrant/.virtualenvs/py2.7/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 675, in find_element
    {'using': by, 'value': value})['value']
  File "/home/vagrant/.virtualenvs/py2.7/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 160, in execute
    self.error_handler.check_response(response)
  File "/home/vagrant/.virtualenvs/py2.7/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 149, in check_response
    raise exception_class(message, screen, stacktrace)
NoSuchElementException: Message: u'Unable to locate element: {"method":"link text","selector":"Add another Inner4 Stacked"}' ; Stacktrace: Method FirefoxDriver.prototype.findElementInternal_ threw an error in file:///tmp/tmpcMYmWl/extensions/fxdriver@googlecode.com/components/driver_component.js 

======================================================================
FAIL: test_many_to_many_inlines (admin_inlines.tests.TestInline)
Autogenerated many-to-many inlines are displayed correctly (#13407)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/django/tests/admin_inlines/tests.py", line 60, in test_many_to_many_inlines
    self.assertContains(response, 'Add another Author-Book Relationship')
  File "/django/django/test/testcases.py", line 344, in assertContains
    msg_prefix + "Couldn't find %s in response" % text_repr)
AssertionError: Couldn't find 'Add another Author-Book Relationship' in response

======================================================================
FAIL: test_inline_change_m2m_change_perm (admin_inlines.tests.TestInlinePermissions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/django/tests/admin_inlines/tests.py", line 452, in test_inline_change_m2m_change_perm
    self.assertContains(response, 'Add another Author-Book Relationship')
  File "/django/django/test/testcases.py", line 344, in assertContains
    msg_prefix + "Couldn't find %s in response" % text_repr)
AssertionError: Couldn't find 'Add another Author-Book Relationship' in response

----------------------------------------------------------------------
@timgraham timgraham commented on the diff
...ontrib/admin/templates/admin/edit_inline/stacked.html
@@ -1,6 +1,6 @@
{% load i18n admin_static %}
<div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
- <h2>{{ inline_admin_formset.opts.verbose_name_plural|title }}</h2>
+ <h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
{{ inline_admin_formset.formset.management_form }}
{{ inline_admin_formset.formset.non_form_errors }}
@timgraham Owner

there's one more instance of "verbose_name|title" on line in this file. any reason you didn't change that?

Sorry, I some how wasn't able to push to my github fork and when I re-did my fork, I forgot to change this filter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@renatooliveira

@timgraham I couldn't find how to run the selenium tests, can you tell me?

Thanks

@renatooliveira

@timgraham let me know if there is anything else.

@timgraham
Owner

Merged in 4356964 - thanks!

@timgraham timgraham closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
6 django/contrib/admin/templates/admin/edit_inline/stacked.html
@@ -1,11 +1,11 @@
{% load i18n admin_static %}
<div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
- <h2>{{ inline_admin_formset.opts.verbose_name_plural|title }}</h2>
+ <h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
{{ inline_admin_formset.formset.management_form }}
{{ inline_admin_formset.formset.non_form_errors }}
@timgraham Owner

there's one more instance of "verbose_name|title" on line in this file. any reason you didn't change that?

Sorry, I some how wasn't able to push to my github fork and when I re-did my fork, I forgot to change this filter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
{% for inline_admin_form in inline_admin_formset %}<div class="inline-related{% if forloop.last %} empty-form last-related{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
- <h3><b>{{ inline_admin_formset.opts.verbose_name|title }}:</b>&nbsp;<span class="inline_label">{% if inline_admin_form.original %}{{ inline_admin_form.original }}{% else %}#{{ forloop.counter }}{% endif %}</span>
+ <h3><b>{{ inline_admin_formset.opts.verbose_name|capfirst }}:</b>&nbsp;<span class="inline_label">{% if inline_admin_form.original %}{{ inline_admin_form.original }}{% else %}#{{ forloop.counter }}{% endif %}</span>
{% if inline_admin_form.show_url %}<a href="{% url 'admin:view_on_site' inline_admin_form.original_content_type_id inline_admin_form.original.pk %}">{% trans "View on site" %}</a>{% endif %}
{% if inline_admin_formset.formset.can_delete and inline_admin_form.original %}<span class="delete">{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}</span>{% endif %}
</h3>
@@ -24,7 +24,7 @@
prefix: '{{ inline_admin_formset.formset.prefix }}',
adminStaticPrefix: '{% static "admin/" %}',
deleteText: "{% trans "Remove" %}",
- addText: "{% blocktrans with verbose_name=inline_admin_formset.opts.verbose_name|title %}Add another {{ verbose_name }}{% endblocktrans %}"
+ addText: "{% blocktrans with verbose_name=inline_admin_formset.opts.verbose_name|capfirst %}Add another {{ verbose_name }}{% endblocktrans %}"
});
})(django.jQuery);
</script>
View
2  django/contrib/admin/templates/admin/edit_inline/tabular.html
@@ -74,7 +74,7 @@
$("#{{ inline_admin_formset.formset.prefix }}-group .tabular.inline-related tbody tr").tabularFormset({
prefix: "{{ inline_admin_formset.formset.prefix }}",
adminStaticPrefix: '{% static "admin/" %}',
- addText: "{% blocktrans with inline_admin_formset.opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}",
+ addText: "{% blocktrans with inline_admin_formset.opts.verbose_name|capfirst as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}",
deleteText: "{% trans 'Remove' %}"
});
})(django.jQuery);
View
8 tests/admin_inlines/tests.py
@@ -57,7 +57,7 @@ def test_many_to_many_inlines(self):
# The heading for the m2m inline block uses the right text
self.assertContains(response, '<h2>Author-book relationships</h2>')
# The "add another" label is correct
- self.assertContains(response, 'Add another Author-Book Relationship')
+ self.assertContains(response, 'Add another Author-book relationship')
# The '+' is dropped from the autogenerated form prefix (Author_books+)
self.assertContains(response, 'id="id_Author_books-TOTAL_FORMS"')
@@ -449,7 +449,7 @@ def test_inline_change_m2m_change_perm(self):
response = self.client.get(self.author_change_url)
# We have change perm on books, so we can add/change/delete inlines
self.assertContains(response, '<h2>Author-book relationships</h2>')
- self.assertContains(response, 'Add another Author-Book Relationship')
+ self.assertContains(response, 'Add another Author-book relationship')
self.assertContains(response, '<input type="hidden" id="id_Author_books-TOTAL_FORMS" '
'value="4" name="Author_books-TOTAL_FORMS" />', html=True)
self.assertContains(response, '<input type="hidden" id="id_Author_books-0-id" '
@@ -554,7 +554,7 @@ def test_add_stackeds(self):
self.assertEqual(rows_length(), 3)
add_button = self.selenium.find_element_by_link_text(
- 'Add another Inner4 Stacked')
+ 'Add another Inner4 stacked')
add_button.click()
self.assertEqual(rows_length(), 4)
@@ -570,7 +570,7 @@ def test_delete_stackeds(self):
self.assertEqual(rows_length(), 3)
add_button = self.selenium.find_element_by_link_text(
- 'Add another Inner4 Stacked')
+ 'Add another Inner4 stacked')
add_button.click()
add_button.click()
View
4 tests/admin_views/tests.py
@@ -3443,7 +3443,7 @@ def test_prepopulated_fields(self):
self.assertEqual(slug2, 'option-one-here-stacked-inline')
# Add an inline
- self.selenium.find_elements_by_link_text('Add another Related Prepopulated')[0].click()
+ self.selenium.find_elements_by_link_text('Add another Related prepopulated')[0].click()
self.selenium.find_element_by_css_selector('#id_relatedprepopulated_set-1-pubdate').send_keys('1999-01-25')
self.get_select_option('#id_relatedprepopulated_set-1-status', 'option two').click()
self.selenium.find_element_by_css_selector('#id_relatedprepopulated_set-1-name').send_keys(' now you haVe anöther sŤāÇkeð inline with a very ... loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooog text... ')
@@ -3463,7 +3463,7 @@ def test_prepopulated_fields(self):
self.assertEqual(slug2, 'option-two-and-now-tabular-inline')
# Add an inline
- self.selenium.find_elements_by_link_text('Add another Related Prepopulated')[1].click()
+ self.selenium.find_elements_by_link_text('Add another Related prepopulated')[1].click()
self.selenium.find_element_by_css_selector('#id_relatedprepopulated_set-2-1-pubdate').send_keys('1981-08-22')
self.get_select_option('#id_relatedprepopulated_set-2-1-status', 'option one').click()
self.selenium.find_element_by_css_selector('#id_relatedprepopulated_set-2-1-name').send_keys('a tÃbűlaŘ inline with ignored ;"&*^\%$#@-/`~ characters')
Something went wrong with that request. Please try again.