Changeset 1837
- Timestamp:
- 03/03/09 13:46:01 (13 months ago)
- Location:
- trunk/pylucid_project
- Files:
-
- 4 modified
-
media/PyLucid/internal_page/blog/edit_blog_entry.css (modified) (1 diff)
-
media/PyLucid/internal_page/blog/edit_blog_entry.html (modified) (2 diffs)
-
PyLucid/plugins_internal/blog/blog.py (modified) (4 diffs)
-
tests/plugin_admin_blog.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pylucid_project/media/PyLucid/internal_page/blog/edit_blog_entry.css
r1686 r1837 8 8 border: 1px solid #000; 9 9 background-color: #FFF; 10 } 11 /* -------------------------------------------------------------------------- */ 12 #blog_preview { 13 background-color: #EEE; 14 } 15 #blog_preview, #blog_preview legend { 16 border-color: #A00; 10 17 } 11 18 /* -------------------------------------------------------------------------- */ -
trunk/pylucid_project/media/PyLucid/internal_page/blog/edit_blog_entry.html
r1701 r1837 1 {% if preview_content %} 2 <fieldset id="blog_preview"> 3 <legend><strong>{% trans 'preview' %}</strong></span> 4 </legend> 5 {{ preview_content }} 6 </fieldset> 7 {% endif %} 8 1 9 <fieldset><legend>{{ legend }}</legend> 2 10 <form method="post" action="."> … … 12 20 </ul> 13 21 <input type="submit" name="save" value="{% trans 'save' %}" /> 22 <input type="submit" name="preview" value="{% trans 'preview' %}" /> 14 23 <input onclick="self.location.href='{{ url_abort }}'" name="abort" value="{% trans 'abort' %}" type="reset" /> 15 24 </form> -
trunk/pylucid_project/PyLucid/plugins_internal/blog/blog.py
r1835 r1837 28 28 from django.http import HttpResponse 29 29 from django.core.mail import send_mail 30 #from django.utils.encoding import force_unicode31 30 from django.utils.translation import ugettext as _ 32 #from django import forms33 #from django.forms import ValidationError34 #from django.contrib.syndication.feeds import Feed, FeedDoesNotExist35 31 36 32 # from PyLucid 37 from PyLucid.tools.utils import escape 33 from PyLucid.tools.syndication_feed import FeedFormat, FEED_FORMAT_INFO 34 from PyLucid.tools.content_processors import apply_markup 38 35 from PyLucid.system.BasePlugin import PyLucidBasePlugin 39 36 from PyLucid.tools.utils import escape_django_tags 40 37 from PyLucid.system.page_msg import PageMessages 41 #from PyLucid.tools.forms_utils import InternalURLField 42 from PyLucid.tools.syndication_feed import FeedFormat, FEED_FORMAT_INFO 38 from PyLucid.tools.utils import escape 43 39 44 40 # from blog plugin … … 285 281 } 286 282 283 if blog_obj == None: # a new blog entry should be created 284 context["legend"] = _("Create a new blog entry") 285 else: 286 context["legend"] = _("Edit a existing blog entry") 287 287 288 if self.request.method == 'POST': 288 289 form = BlogEntryForm(self.request.POST) 289 290 #self.page_msg(self.request.POST) 290 if form.is_valid(): 291 if form.is_valid() and "preview" in self.request.POST: 292 # Do only a preview of the blog content with the markup 293 preview_content = apply_markup( 294 content = form.cleaned_data["content"], 295 context = self.context, 296 markup_no = form.cleaned_data["markup"], 297 ) 298 context["preview_content"] = preview_content 299 elif form.is_valid(): 300 # Save the new/edited blog entry 291 301 new_tags = form.cleaned_data.pop("new_tags") # ListCharField 292 302 … … 324 334 else: 325 335 if blog_obj == None: 326 context["legend"] = _("Create a new blog entry")327 336 form = BlogEntryForm( 328 337 initial={"markup": self.preferences["default_markup"],} 329 338 ) 330 339 else: 331 context["legend"] = _("Edit a existing blog entry")332 340 form = BlogEntryForm(instance=blog_obj) 333 341 … … 487 495 Send notify emails. 488 496 """ 497 #self.page_msg(self.request.POST) 489 498 content = clean_data["content"] 490 491 499 try: 492 500 mail_title = self._check_comment_submit(blog_entry, content) -
trunk/pylucid_project/tests/plugin_admin_blog.py
r1836 r1837 37 37 # Run test with: 38 38 PAGE_ID = 1 39 40 41 BLOG_POST_DATA1 = { 42 u'headline': u'A unittest blog entry', 43 u'markup': u'6', # Creole 44 u'content': u'The unittest blog content', 45 u'is_public': u'on', 46 u'new_tags': u'unittest blog tags', 47 } 48 39 49 40 50 class TestPluginBlog(tests.TestCase): … … 103 113 ) 104 114 115 def test_blog_entry_preview(self): 116 """ 117 Test the markup preview 118 """ 119 self.login("staff") 120 121 post_data = { 122 u'headline': u'preview test', 123 u'markup': u'6', # Creole 124 u'content': u'[[url|title]]\n*list1\n*list2', 125 u'preview': u'preview' 126 } 127 128 # Create a new blog entry 129 response = self.client.post(self.add_entry_url, post_data) 130 self.failUnlessEqual(response.status_code, 200) 131 self.assertResponse( 132 response, 133 must_contain=( 134 '<p><a href="url">title</a></p>', 135 "<li>list1</li>", "<li>list2</li>", 136 "preview", 137 "Create a new blog entry", 138 "save", "preview", "abort", 139 ), 140 must_not_contain=("Traceback", "Error",), 141 ) 142 105 143 def test_create_new_blog_entry(self): 106 144 """ … … 110 148 """ 111 149 self.login("staff") 112 150 151 post_data = BLOG_POST_DATA1.copy() 152 post_data.update({u'save': u'save'}) 153 113 154 # Create a new blog entry 114 response = self.client.post( 115 self.add_entry_url, 116 { 117 u'headline': u'A unittest blog entry', 118 u'markup': u'6', # Creole 119 u'content': u'The unittest blog content', 120 u'is_public': u'on', 121 u'new_tags': u'unittest blog tags', 122 u'save': u'save', 123 } 124 ) 155 response = self.client.post(self.add_entry_url, post_data) 125 156 self.failUnlessEqual(response.status_code, 200) 126 157 self.assertResponse(