app/soc/views/helpers/custom_widgets.py
author Pawel Solyga <Pawel.Solyga@gmail.com>
Tue, 30 Sep 2008 16:49:54 +0000
changeset 215 d020c95b17b1
parent 211 ec26682053df
child 264 97b60788cb9a
permissions -rw-r--r--
Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view. Patch by: Pawel Solyga Review by: to-be-reviewed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
127
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     2
#
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     4
#
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     8
#
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    10
#
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    16
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    17
"""Custom widgets used for form fields.
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    18
"""
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    19
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    20
__authors__ = [
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    21
  '"Pawel Solyga" <pawel.solyga@gmail.com>',
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    22
  ]
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    23
141
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 127
diff changeset
    24
from django import newforms as forms
127
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    25
from django.newforms.widgets import flatatt
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    26
from django.newforms.util import smart_unicode
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    27
from django.utils.html import escape
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    28
from django.utils import simplejson
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    29
from django.utils.safestring import mark_safe
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    30
215
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    31
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    32
class ReadOnlyInput(forms.widgets.Input):
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    33
  """Read only input widget.
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    34
  """
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    35
  input_type = 'text'
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    36
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    37
  def render(self, name, value, attrs=None):
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    38
    """Render ReadOnlyInput widget as HTML.
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    39
    """
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    40
    attrs['readonly'] = 'readonly'
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    41
    return super(ReadOnlyInput, self).render(name, value, attrs)
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    42
127
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    43
215
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    44
class TinyMCE(forms.widgets.Textarea):
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    45
  """TinyMCE widget. 
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    46
  
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    47
  Requires to include tiny_mce_src.js in your template. Widget can be
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    48
  customized by overwriting or adding extra options to mce_settings
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    49
  dictionary
127
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    50
215
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    51
  You can set TinyMCE widget for particular form field using code below:
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    52
    class ExampleForm(forms_helpers.DbModelForm):
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    53
      content = forms.fields.CharField(widget=custom_widgets.TinyMCE())
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    54
  
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    55
  You can include tiny_mce_src.js in your template using:
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    56
    {% block scripts %}
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    57
  	  <script type="text/javascript" src="/tiny_mce/tiny_mce_src.js"></script>
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    58
    {% endblock %}
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    59
  """ 
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    60
  DEF_MCE_SETTINGS = { 'mode': "exact",
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    61
                       'theme': "simple",
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    62
                       'theme_advanced_toolbar_location': "top",
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    63
                       'theme_advanced_toolbar_align': "center"}
127
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    64
215
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    65
  mce_settings = DEF_MCE_SETTINGS.copy()
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    66
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    67
  TINY_MCE_HTML_FMT = u'''\
194
8bdb1d2d0c36 Change indentation level to 2 (from 4) and rename MCE_DEF_SETTINGS to
Todd Larsen <tlarsen@google.com>
parents: 188
diff changeset
    68
<textarea %(attrs)s>%(value)s</textarea>
8bdb1d2d0c36 Change indentation level to 2 (from 4) and rename MCE_DEF_SETTINGS to
Todd Larsen <tlarsen@google.com>
parents: 188
diff changeset
    69
<script type="text/javascript">
215
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    70
tinyMCE.init(%(settings_json)s)
194
8bdb1d2d0c36 Change indentation level to 2 (from 4) and rename MCE_DEF_SETTINGS to
Todd Larsen <tlarsen@google.com>
parents: 188
diff changeset
    71
</script>'''
215
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    72
  
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    73
  def render(self, name, value, attrs=None):
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    74
    """Render TinyMCE widget as HTML.
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    75
    """
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    76
    if value is None:
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    77
      value = ''
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    78
    value = smart_unicode(value)
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    79
    final_attrs = self.build_attrs(attrs, name=name)
188
27ed1a09c98d Changes in TinyMCE widget in custom_widgets.py based on review comments.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 141
diff changeset
    80
    
215
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    81
    self.mce_settings['elements'] = "id_%s" % name
211
ec26682053df Made mce_settings class variable in TinyMCE widget a copy of default settings instead of reference.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 194
diff changeset
    82
      
215
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    83
    # convert mce_settings from dict to JSON
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    84
    mce_json = simplejson.JSONEncoder().encode(self.mce_settings)
127
70206a64da4a Created custom_widgets.py and added TinyMCE django widget that can be later used for particular form fields.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    85
215
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    86
    return mark_safe(self.TINY_MCE_HTML_FMT % 
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    87
        {'attrs': flatatt(final_attrs),
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    88
         'value': escape(value), 
d020c95b17b1 Clean up too long lines in profile.py. Add ReadOnlyInput widget to custom_widgets module, it can be used to display read-only form fields. Display read-only "Id" field in LookUp view if user has been found and in User Edit Developer view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 211
diff changeset
    89
         'settings_json':  mce_json})