Django

Code

Ticket #494: 494.patch

File 494.patch, 4.2 kB (added by Antonis Christofides <anthony@itia.ntua.gr>, 8 months ago)

Patch with alternative approach

  • django/db/models/fields/related.py

    old new  
    1717    from sets import Set as set   # Python 2.3 fallback 
    1818 
    1919# Values for Relation.edit_inline. 
    20 TABULAR, STACKED = 1, 2 
     20TABULAR, STACKED = 'inline_tabular ', 'inline_stacked ' 
    2121 
    2222RECURSIVE_RELATIONSHIP_CONSTANT = 'self' 
    2323 
  • django/contrib/admin/templatetags/admin_modify.py

    old new  
    166166    def render(self, context): 
    167167        relation = self.rel_var.resolve(context) 
    168168        context.push() 
    169         if relation.field.rel.edit_inline == models.TABULAR: 
     169        edit_inline = relation.field.rel.edit_inline 
     170        if edit_inline.startswith(models.TABULAR): 
    170171            bound_related_object_class = TabularBoundRelatedObject 
    171         elif relation.field.rel.edit_inline == models.STACKED: 
     172            edit_inline = edit_inline[len(models.TABULAR):] 
     173        elif edit_inline.startswith(models.STACKED): 
    172174            bound_related_object_class = StackedBoundRelatedObject 
     175            edit_inline = edit_inline[len(models.STACKED):] 
    173176        else: 
    174177            bound_related_object_class = relation.field.rel.edit_inline 
    175178        original = context.get('original', None) 
    176179        bound_related_object = relation.bind(context['form'], original, bound_related_object_class) 
    177180        context['bound_related_object'] = bound_related_object 
     181        context['extra_classes'] = edit_inline 
    178182        t = loader.get_template(bound_related_object.template_name()) 
    179183        output = t.render(context) 
    180184        context.pop() 
  • django/contrib/admin/templates/admin/edit_inline_stacked.html

    old new  
    11{% load admin_modify %} 
    2 <fieldset class="module aligned"> 
     2<fieldset class="module aligned {{extra_classes}}"> 
    33   {% for fcw in bound_related_object.form_field_collection_wrappers %} 
    44      <h2>{{ bound_related_object.relation.opts.verbose_name|capfirst }}&nbsp;#{{ forloop.counter }}</h2> 
    55      {% if bound_related_object.show_url %}{% if fcw.obj.original %} 
  • django/contrib/admin/templates/admin/edit_inline_tabular.html

    old new  
    11{% load admin_modify %} 
    2 <fieldset class="module"> 
     2<fieldset class="module {{extra_classes}}"> 
    33   <h2>{{ bound_related_object.relation.opts.verbose_name_plural|capfirst }}</h2><table> 
    44   <thead><tr> 
    55   {% for fw in bound_related_object.field_wrapper_list %} 
  • docs/model-api.txt

    old new  
    818818                             interface. Use either ``models.TABULAR`` or ``models.STACKED``, 
    819819                             which, respectively, designate whether the inline-editable 
    820820                             objects are displayed as a table or as a "stack" of 
    821                              fieldsets. 
     821                             fieldsets. You can append a string specifying extra CSS 
     822                             classes to be used for the inline fieldsets; the ``collapse`` 
     823                             and ``wide`` classes, documented below, are useful. 
     824                             For example: 
    822825 
     826                                edit_inline = models.TABULAR + 'collapse' 
     827 
    823828    ``limit_choices_to``     A dictionary of lookup arguments and values (see 
    824829                             the `Database API reference`_) that limit the 
    825830                             available admin choices for this object. Use this