[CLEAN] [IMP] website_blog: module cleaning + website template improvements
authorThibault Delavallée <tde@openerp.com>
Fri, 11 Oct 2013 09:39:13 +0000 (11:39 +0200)
committerThibault Delavallée <tde@openerp.com>
Fri, 11 Oct 2013 09:39:13 +0000 (11:39 +0200)
[MOV] website_blog: module organization cleaning. Files have been moved accordingly to the new organization
we would like to impose in OpenERP addons :
- model-related files: in models directory
- data/demo files: in data directory
- renamed sexurity/website_mail.xml to website_blog.xml, to avoid confusing the module with website_mail

[CLEAN] website_blog: cleaned website templates

Cleaned options: tags, hide author name, ... and default values for those options. We decided
to display tags, but hide blog name. Default implementation is a single blog layout.

Fixed display without right column: should take all page width.

Updated template ids: option begin by opt_ to easily find them when grepping / searching.

[FIX] website_blog: fixed class name for tests, importing class that does not exist anymore in trunk (was changed)

bzr revid: tde@openerp.com-20131011093913-qlkgqxvodlx41rnk

addons/website/controllers/main.py

index 5016390..04967d5 100644 (file)
@@ -7,17 +7,25 @@ import json
 import logging
 import os
 import datetime
+import re
 
 from sys import maxint
 
 import psycopg2
-import slugify
 import werkzeug
 import werkzeug.exceptions
 import werkzeug.utils
 import werkzeug.wrappers
 from PIL import Image
 
+try:
+    from slugify import slugify
+except ImportError:
+    def slugify(s, max_length=None):
+        spaceless = re.sub(r'\s+', '-', s)
+        specialless = re.sub(r'[^-_a-z0-9]', '', spaceless)
+        return specialless[:max_length]
+
 import openerp
 from openerp.addons.website.models import website
 from openerp.addons.web import http
@@ -53,7 +61,7 @@ class Website(openerp.addons.web.controllers.main.Home):
     def pagenew(self, path, noredirect=NOPE):
         module = 'website'
         # completely arbitrary max_length
-        idname = slugify.slugify(path, max_length=50)
+        idname = slugify(path, max_length=50)
 
         request.cr.execute('SAVEPOINT pagenew')
         imd = request.registry['ir.model.data']