Changeset 727


Ignore:
Timestamp:
05/21/12 18:11:24 (2 years ago)
Author:
pmartin
Message:

See #635 Change MEDA_URL to STATIC_URL

Location:
inplaceeditform/trunk/inplaceeditform
Files:
8 edited
2 moved

Legend:

Unmodified
Added
Removed
  • inplaceeditform/trunk/inplaceeditform/commons.py

    r724 r727  
    9696    path_module, class_adaptor = ('.'.join(path_adaptor.split('.')[:-1]), path_adaptor.split('.')[-1]) 
    9797    return getattr(import_module(path_module), class_adaptor) 
     98 
     99 
     100def get_static_url(): 
     101    static_url = getattr(settings, 'STATIC_URL', None) 
     102    if static_url: 
     103        return static_url 
     104    else:  # To old django versions 
     105        return '%sinplaceeditform/' % getattr(settings, 'MEDIA_URL', None) 
  • inplaceeditform/trunk/inplaceeditform/fields.py

    r707 r727  
    88from django.utils.translation import ugettext 
    99 
    10 from inplaceeditform.commons import  import_module 
    11 from inplaceeditform.commons import has_transmeta, apply_filters 
     10from inplaceeditform.commons import apply_filters, import_module, has_transmeta, get_static_url 
    1211from inplaceeditform.perms import SuperUserPermEditInline 
    1312 
     
    9998        context = {'form': self.get_form(), 
    10099                   'field': self.get_field(), 
    101                    'MEDIA_URL': settings.MEDIA_URL, 
     100                   'STATIC_URL': get_static_url(), 
    102101                   'class_inplace': self.class_inplace} 
    103102        context.update(extra_context) 
     
    107106        extra_context = extra_context or {} 
    108107        context = {'field': self.get_field(), 
    109                    'MEDIA_URL': settings.MEDIA_URL, 
     108                   'STATIC_URL': get_static_url(), 
    110109                   'ADMIN_MEDIA_PREFIX': settings.ADMIN_MEDIA_PREFIX} 
    111110        context.update(extra_context) 
     
    226225    def render_value(self, field_name=None, template_name="inplaceeditform/adaptor_boolean/render_value.html"): 
    227226        value = super(AdaptorBooleanField, self).render_value(field_name) 
    228         return render_to_string(template_name, {'value': value, 'MEDIA_URL': settings.MEDIA_URL}) 
     227        return render_to_string(template_name, {'value': value, 'STATIC_URL': get_static_url()}) 
    229228 
    230229    def render_field(self, template_name="inplaceeditform/adaptor_boolean/render_field.html"): 
  • inplaceeditform/trunk/inplaceeditform/templates/inplaceeditform/adaptor_boolean/render_value.html

    r443 r727  
    11{% if value %} 
    2     <img src="{{ MEDIA_URL }}inplaceeditform/img/true.gif" title="{{ value }}" alt="{{ value }}"/> 
     2    <img src="{{ STATIC_URL }}img/true.gif" title="{{ value }}" alt="{{ value }}"/> 
    33{% else %} 
    4     <img src="{{ MEDIA_URL }}inplaceeditform/img/false.gif" title="{{ value }}" alt="{{ value }}"/> 
     4    <img src="{{ STATIC_URL }}img/false.gif" title="{{ value }}" alt="{{ value }}"/> 
    55{% endif %} 
  • inplaceeditform/trunk/inplaceeditform/templates/inplaceeditform/adaptor_file/render_media_field.html

    r609 r727  
    33{% block media %} 
    44    {{ block.super }} 
    5     <script src="{{ MEDIA_URL }}inplaceeditform/js/jquery.form.js" type="text/javascript"></script> 
     5    <script src="{{ STATIC_URL }}js/jquery.form.js" type="text/javascript"></script> 
    66{% endblock %} 
    77 
  • inplaceeditform/trunk/inplaceeditform/templates/inplaceeditform/adaptor_image/render_field.html

    r629 r727  
    55{% block actions %} 
    66   {{ block.super }} 
    7     <script src="{{ MEDIA_URL }}inplaceeditform/js/jquery.filestyle.mini.js" type="text/javascript"></script> 
     7    <script src="{{ STATIC_URL }}js/jquery.filestyle.mini.js" type="text/javascript"></script> 
    88    <script type="text/javascript"> 
    99        (function($){ 
    1010            $(document).ready(function () { 
    1111                $("#{{ field.auto_id }}").filestyle({  
    12                     image: "{{ MEDIA_URL }}inplaceeditform/img/load.png", 
     12                    image: "{{ STATIC_URL }}img/load.png", 
    1313                    imageheight : 22, 
    1414                    imagewidth : 19, 
  • inplaceeditform/trunk/inplaceeditform/templates/inplaceeditform/inplace_css.html

    r408 r727  
    1 <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}inplaceeditform/css/style.css" /> 
     1<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/style.css" /> 
  • inplaceeditform/trunk/inplaceeditform/templates/inplaceeditform/inplace_js.html

    r660 r727  
    33<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> 
    44--> 
    5 <script src="{{ MEDIA_URL }}inplaceeditform/js/jquery.json.js" type="text/javascript"></script> 
    6 <script src="{{ MEDIA_URL }}inplaceeditform/js/jquery.inplaceeditform.js" type="text/javascript"></script> 
     5<script src="{{ STATIC_URL }}js/jquery.json.js" type="text/javascript"></script> 
     6<script src="{{ STATIC_URL }}js/jquery.inplaceeditform.js" type="text/javascript"></script> 
    77 
    88{% if activate_inplaceedit %} 
  • inplaceeditform/trunk/inplaceeditform/templatetags/inplace_edit.py

    r611 r727  
    44from django.conf import settings 
    55 
    6 from inplaceeditform.commons import get_adaptor_class 
     6from inplaceeditform.commons import get_adaptor_class, get_static_url 
    77from inplaceeditform.tag_utils import RenderWithArgsAndKwargsNode, parse_args_kwargs 
    88 
     
    1212def inplace_js(context, activate_inplaceedit=True): 
    1313    return context.update({ 
    14             'MEDIA_URL': context.get('MEDIA_URL', settings.MEDIA_URL), 
    15             'ADMIN_MEDIA_PREFIX': settings.ADMIN_MEDIA_PREFIX, 
    16             'activate_inplaceedit': activate_inplaceedit, 
     14        'STATIC_URL': get_static_url(), 
     15        'ADMIN_MEDIA_PREFIX': settings.ADMIN_MEDIA_PREFIX, 
     16        'activate_inplaceedit': activate_inplaceedit, 
    1717    }) 
    1818register.inclusion_tag("inplaceeditform/inplace_js.html", takes_context=True)(inplace_js) 
     
    2121def inplace_css(context): 
    2222    return context.update({ 
    23             'MEDIA_URL': context.get('MEDIA_URL', settings.MEDIA_URL), 
    24             'ADMIN_MEDIA_PREFIX': settings.ADMIN_MEDIA_PREFIX, 
     23        'STATIC_URL': get_static_url(), 
     24        'ADMIN_MEDIA_PREFIX': settings.ADMIN_MEDIA_PREFIX, 
    2525    }) 
    2626register.inclusion_tag("inplaceeditform/inplace_css.html", takes_context=True)(inplace_css) 
    2727 
    2828 
     29def inplace_static(context): 
     30    return context.update({ 
     31        'STATIC_URL': get_static_url(), 
     32        'ADMIN_MEDIA_PREFIX': settings.ADMIN_MEDIA_PREFIX, 
     33    }) 
     34register.inclusion_tag("inplaceeditform/inplace_static.html", takes_context=True)(inplace_static) 
     35 
     36 
     37#to old django versions 
    2938def inplace_media(context): 
    30     return context.update({ 
    31             'MEDIA_URL': context.get('MEDIA_URL', settings.MEDIA_URL), 
    32             'ADMIN_MEDIA_PREFIX': settings.ADMIN_MEDIA_PREFIX, 
    33     }) 
    34 register.inclusion_tag("inplaceeditform/inplace_media.html", takes_context=True)(inplace_media) 
     39    return inplace_static(context) 
     40register.inclusion_tag("inplaceeditform/inplace_static.html", takes_context=True)(inplace_media) 
    3541 
    3642 
Note: See TracChangeset for help on using the changeset viewer.