[IMP] move slugify to server, use slugified url as page name
bzr revid: xmo@openerp.com-20131108154842-ts1nnd40jusa92h6
This commit is contained in:
@@ -6,7 +6,6 @@ import json
|
||||
import logging
|
||||
import os
|
||||
import datetime
|
||||
import re
|
||||
|
||||
from sys import maxint
|
||||
|
||||
@@ -17,14 +16,6 @@ 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.osv import fields
|
||||
from openerp.addons.website.models import website
|
||||
@@ -66,7 +57,7 @@ class Website(openerp.addons.web.controllers.main.Home):
|
||||
def pagenew(self, path, noredirect=NOPE):
|
||||
module = 'website'
|
||||
# completely arbitrary max_length
|
||||
idname = slugify(path, max_length=50)
|
||||
idname = http.slugify(path, max_length=50)
|
||||
|
||||
request.cr.execute('SAVEPOINT pagenew')
|
||||
imd = request.registry['ir.model.data']
|
||||
|
||||
@@ -346,18 +346,9 @@ class website(osv.osv):
|
||||
)))
|
||||
|
||||
for values in generated:
|
||||
name = endpoint.__name__
|
||||
record = next((item for item in values.values() if isinstance(item, orm.browse_record)),
|
||||
None)
|
||||
if record:
|
||||
#name = record.display_name
|
||||
[(_, record_name)] = record.name_get()
|
||||
name = u"%s: %s" % (name, record_name)
|
||||
yield {
|
||||
'name': name,
|
||||
# rule.build returns (domain_part, rel_url)
|
||||
'url': rule.build(values, append_unknown=False)[1]
|
||||
}
|
||||
# rule.build returns (domain_part, rel_url)
|
||||
url = rule.build(values, append_unknown=False)[1]
|
||||
yield {'name': url, 'url': url }
|
||||
|
||||
def kanban(self, cr, uid, ids, model, domain, column, template, step=None, scope=None, orderby=None, context=None):
|
||||
step = step and int(step) or 10
|
||||
|
||||
Reference in New Issue
Block a user