Author: batiste.bieler
Date: Mon Feb 16 06:28:41 2009
New Revision: 346
Modified:
trunk/pages/admin/widgets.py
trunk/pages/models.py
trunk/pages/templates/admin/pages/page/widgets/wymeditor.html
Log:
Wymeditor widget generate less SQL requests. But still need some love with
the javascript. This code genereration in the template is not nice.
Modified: trunk/pages/admin/widgets.py
==============================================================================
--- trunk/pages/admin/widgets.py (original)
+++ trunk/pages/admin/widgets.py Mon Feb 16 06:28:41 2009
@@ -56,6 +56,7 @@
'admin/pages/page/widgets/richtextarea.html', context))
class TinyMCE(Textarea):
+
class Media:
js = [join(PAGES_MEDIA_URL, path) for path in (
'tiny_mce/tiny_mce.js',
@@ -79,6 +80,7 @@
'admin/pages/page/widgets/tinymce.html', context))
class WYMEditor(Textarea):
+
class Media:
js = [join(PAGES_MEDIA_URL, path) for path in (
'javascript/jquery.js',
@@ -96,6 +98,7 @@
def render(self, name, value, attrs=None):
rendered = super(WYMEditor, self).render(name, value, attrs)
context = {
+ 'page_list':Page.objects.all().order_by('tree_id'),
'name': name,
'language': self.language,
'PAGES_MEDIA_URL': PAGES_MEDIA_URL,
Modified: trunk/pages/models.py
==============================================================================
--- trunk/pages/models.py (original)
+++ trunk/pages/models.py Mon Feb 16 06:28:41 2009
@@ -236,6 +236,13 @@
return True
return False
+ def with_level(self):
+ level = ''
+ if self.level:
+ for n in range(0, self.level):
+ level += ' '
+ return mark_safe(level + self.__unicode__())
+
def __unicode__(self):
slug = self.slug()
# when created in console mode, page has no slug
Modified: trunk/pages/templates/admin/pages/page/widgets/wymeditor.html
==============================================================================
--- trunk/pages/templates/admin/pages/page/widgets/wymeditor.html
(original)
+++ trunk/pages/templates/admin/pages/page/widgets/wymeditor.html Mon Feb
16 06:28:41 2009
@@ -1,9 +1,4 @@
-{% load mptt_tags cache %}
-{% cache 180 WYMeditorTree %}
-{% comment %}
- This code is *very* slow... please replace this code with some ajax
-{% endcomment %}
-{% full_tree_for_model pages.Page as pages %}
+{% load mptt_tags %}
<script type="text/javascript">
jQuery('#id_{{ name }}').wymeditor({
lang: '{{ language }}',
@@ -41,8 +36,8 @@
+ "<div class='row'>"
+ "<label>Page</label>"
+ "<select class='wym_select_page_link'>"
- {% for page in pages %}
- + "<option value='{{ page.get_absolute_url }}'>{{ page
}}</option>"
+ {% for page in page_list %}
+ + "<option value='{{ page.get_absolute_url }}'>{{
page.with_level }}</option>"
{% endfor %}
+ "</select>"
+ "</div>"
@@ -80,4 +75,3 @@
}
});
</script>
-{% endcache %}
\ No newline at end of file
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---