├── tests ├── __init__.py ├── core │ ├── __init__.py │ ├── templates │ │ ├── inlines │ │ │ ├── user.html │ │ │ └── user.contact.html │ │ └── youtube_inlines │ │ │ └── youtube.html │ ├── tests │ │ ├── __init__.py │ │ ├── test_inlines.py │ │ ├── templateinline.py │ │ ├── modelinline.py │ │ ├── base.py │ │ └── templatetags.py │ ├── models.py │ └── fixtures │ │ └── users.json ├── settings.py └── manage.py ├── django_inlines ├── __init__.py ├── templatetags │ ├── __init__.py │ └── inlines.py ├── admin_urls.py ├── media │ └── django_inlines │ │ ├── inlines.css │ │ ├── inlines.js │ │ └── jquery-fieldselection.js ├── templates │ ├── inlines │ │ └── youtube.html │ └── admin │ │ └── django_inlines │ │ ├── js_inline_config.js │ │ └── inline_form.html ├── samples.py ├── forms.py ├── views.py └── inlines.py ├── .gitignore ├── AUTHORS ├── MANIFEST.in ├── CHANGES.rst ├── setup.py ├── LICENSE └── README.rst /tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /django_inlines/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /django_inlines/templatetags/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | django_inlines.egg-info 3 | MANIFEST -------------------------------------------------------------------------------- /tests/core/templates/inlines/user.html: -------------------------------------------------------------------------------- 1 | {{ object.name }} -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Christian Metts 2 | 3 | Additional contributions from: 4 | Daniel Lindsley 5 | Jannis Leidel 6 | Martin Mahner 7 | -------------------------------------------------------------------------------- /tests/core/tests/__init__.py: -------------------------------------------------------------------------------- 1 | from base import * 2 | from templateinline import * 3 | from modelinline import * 4 | from templatetags import * 5 | -------------------------------------------------------------------------------- /tests/core/templates/inlines/user.contact.html: -------------------------------------------------------------------------------- 1 | {{ object.name }}{% if object.phone %}, {{ object.phone }}{% endif %}{% if object.email %}, {{ object.email }}{% endif %} -------------------------------------------------------------------------------- /tests/core/templates/youtube_inlines/youtube.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | {% if inline.get_app_label %}
5 |
6 | {% endif %}
7 | {% if inline.help_text %}{{ inline.help_text }}{% endif %}
8 |
12 | 13 | 19 |
20 | {% endif %} 21 | 22 | {% for arg in inline.inline_args %} 23 |24 | {% if arg.options %} 25 | 31 | {% else %} 32 | 33 | {% endif %} 34 | {% if arg.help_text %}{{ arg.help_text }}{% endif %} 35 |
36 | {% endfor %} 37 | 38 | 39 | -------------------------------------------------------------------------------- /django_inlines/media/django_inlines/inlines.js: -------------------------------------------------------------------------------- 1 | var DjangoInlines = DjangoInlines || {} 2 | 3 | 4 | $(function() { 5 | 6 | $('.vInlineTextArea').each(function(){ 7 | var id = this.id; 8 | var div = $('Insert inline:
Check out my new video:
24 | 25 | {{ youtube http://www.youtube.com/watch?v=RXJKdh1KZ0w }} 26 | 27 | In your template:: 28 | 29 | {% load inlines %} 30 | {% process_inlines entry.body %} 31 | 32 | Output:: 33 | 34 |Check out my new video:
35 | 36 |{{ body|stripinlines }}
" 27 | context = { 28 | 'body': u"This is my YouTube video: {{ youtube C_ZebDKv1zo }}", 29 | } 30 | self.assertEqual(self.render(template, context), u'This is my YouTube video:
') 31 | 32 | 33 | class ProcessInlinesTestCase(TestCase): 34 | def render(self, template_string, context_dict=None): 35 | """A shortcut for testing template output.""" 36 | if context_dict is None: 37 | context_dict = {} 38 | 39 | c = Context(context_dict) 40 | t = Template(template_string) 41 | return t.render(c) 42 | 43 | def setUp(self): 44 | super(ProcessInlinesTestCase, self).setUp() 45 | 46 | # Stow. 47 | self.old_registry = inlines.registry 48 | inlines.registry = inlines.Registry() 49 | 50 | def tearDown(self): 51 | inlines.registry = self.old_registry 52 | super(ProcessInlinesTestCase, self).tearDown() 53 | 54 | def test_simple_usage(self): 55 | inlines.registry.register('youtube', YoutubeInline) 56 | 57 | template = u"{% load inlines %}{% process_inlines body %}
" 58 | context = { 59 | 'body': u"This is my YouTube video: {{ youtube C_ZebDKv1zo }}", 60 | } 61 | self.assertEqual(self.render(template, context), u'This is my YouTube video:
{% process_inlines body %}
" 67 | context = { 68 | 'body': u"This is my YouTube video: {{ youtube C_ZebDKv1zo height=295 width=480 }}", 69 | } 70 | self.assertEqual(self.render(template, context), u'This is my YouTube video:
{{ body|safe }}
" 76 | context = { 77 | 'body': u"This is my YouTube video: {{ youtube C_ZebDKv1zo }}", 78 | } 79 | self.assertEqual(self.render(template, context), u'This is my YouTube video:
{{ body|safe }}
" 88 | context = { 89 | 'body': u"This is my YouTube video: {{ youtube C_ZebDKv1zo }}", 90 | } 91 | self.assertEqual(self.render(template, context), u'This is my YouTube video:
{{ body|safe }}
" 94 | self.assertEqual(self.render(template, context), u'This is my YouTube video:
{% process_inlines body %}
" 101 | context = { 102 | 'body': u"Some text {{ quine Why hello }} but {{ double your fun }}.", 103 | } 104 | self.assertEqual(inlines.registry.process(context['body']), 'Some text {{ quine Why hello }} but your funyour fun.') 105 | self.assertEqual(self.render(template, context), u'Some text {{ quine Why hello }} but your funyour fun.
') 106 | 107 | def test_usage_with_template_dirs(self): 108 | inlines.registry.register('youtube', YoutubeInline) 109 | 110 | template = "{% load inlines %}{% process_inlines body in 'youtube_inlines' %}
" 111 | context = { 112 | 'body': u"This is my YouTube video: {{ youtube C_ZebDKv1zo }}", 113 | } 114 | self.assertEqual(self.render(template, context), u'This is my YouTube video:
{% with 'b' as bold %}{% process_inlines body in 'youtube_inlines' %}{% endwith %}
" 120 | context = { 121 | 'body': u"This is my YouTube video: {{ youtube C_ZebDKv1zo }}", 122 | } 123 | self.assertEqual(self.render(template, context), u'This is my YouTube video:
{% process_inlines body in 'youtube_inlines' %} {{ test }}
""" 129 | context = { 130 | 'body': u"This is my YouTube video: {{ youtube C_ZebDKv1zo bold=bold }} {{ youtube C_ZebDKv1zo }}", 131 | 'test': u"green" 132 | } 133 | self.assertEqual(self.render(template, context), u'This is my YouTube video:
{% process_inlines body in 'nonexistent_inlines' %}
" 145 | context = { 146 | 'body': u"This is my YouTube video: {{ youtube C_ZebDKv1zo }}", 147 | } 148 | self.assertEqual(self.render(template, context), u'This is my YouTube video: