[MERGE] Merge parents
bzr revid: rim@openerp.com-20131106073413-dl8x48eymbs20wg4
This commit is contained in:
@@ -156,6 +156,7 @@
|
||||
}).fail(function (err, data) {
|
||||
website.error(data, '/web#model='+$a.data('object')+'&id='+$a.data('id'));
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$(document).on('click', '.js_publish_management .js_publish_btn', function () {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import test_views, test_converter
|
||||
import test_views, test_converter, test_requests
|
||||
|
||||
checks = [ test_views, test_converter, ]
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import unittest2
|
||||
|
||||
class URLCase(unittest2.TestCase):
|
||||
"""
|
||||
URLCase moved out of test_requests, otherwise discovery attempts to
|
||||
instantiate and run it
|
||||
"""
|
||||
def __init__(self, user, url, result):
|
||||
super(URLCase, self).__init__()
|
||||
self.user = user
|
||||
self.url = url
|
||||
self.result = result
|
||||
|
||||
@property
|
||||
def username(self):
|
||||
return self.user or "Anonymous Coward"
|
||||
|
||||
def __str__(self):
|
||||
return "%s (as %s)" % (self.url, self.username)
|
||||
|
||||
__repr__ = __str__
|
||||
|
||||
def shortDescription(self):
|
||||
return ""
|
||||
|
||||
def runTest(self):
|
||||
code = self.result.getcode()
|
||||
self.assertIn(
|
||||
code, xrange(200, 300),
|
||||
"Fetching %s as %s returned an error response (%d)" % (
|
||||
self.url, self.username, code))
|
||||
@@ -0,0 +1,115 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import collections
|
||||
import urllib
|
||||
import urlparse
|
||||
import unittest2
|
||||
import urllib2
|
||||
|
||||
import lxml.html
|
||||
|
||||
from openerp import tools
|
||||
|
||||
from . import cases
|
||||
|
||||
__all__ = ['load_tests', 'CrawlSuite']
|
||||
|
||||
class RedirectHandler(urllib2.HTTPRedirectHandler):
|
||||
"""
|
||||
HTTPRedirectHandler is predicated upon HTTPErrorProcessor being used and
|
||||
works by intercepting 3xy "errors".
|
||||
|
||||
Inherit from it to handle 3xy non-error responses instead, as we're not
|
||||
using the error processor
|
||||
"""
|
||||
|
||||
def http_response(self, request, response):
|
||||
code, msg, hdrs = response.code, response.msg, response.info()
|
||||
|
||||
if 300 <= code < 400:
|
||||
return self.parent.error(
|
||||
'http', request, response, code, msg, hdrs)
|
||||
|
||||
return response
|
||||
|
||||
https_response = http_response
|
||||
|
||||
class CrawlSuite(unittest2.TestSuite):
|
||||
""" Test suite crawling an openerp CMS instance and checking that all
|
||||
internal links lead to a 200 response.
|
||||
|
||||
If a username and a password are provided, authenticates the user before
|
||||
starting the crawl
|
||||
"""
|
||||
|
||||
def __init__(self, user=None, password=None):
|
||||
super(CrawlSuite, self).__init__()
|
||||
|
||||
self.opener = urllib2.OpenerDirector()
|
||||
self.opener.add_handler(urllib2.UnknownHandler())
|
||||
self.opener.add_handler(urllib2.HTTPHandler())
|
||||
self.opener.add_handler(urllib2.HTTPSHandler())
|
||||
self.opener.add_handler(RedirectHandler())
|
||||
self.opener.add_handler(urllib2.HTTPCookieProcessor())
|
||||
|
||||
self._authenticate(user, password)
|
||||
self.user = user
|
||||
|
||||
def _request(self, path):
|
||||
return self.opener.open(urlparse.urlunsplit([
|
||||
'http', 'localhost:%s' % tools.config['xmlrpc_port'],
|
||||
path, '', ''
|
||||
]))
|
||||
|
||||
def _authenticate(self, user, password):
|
||||
if user is None: return
|
||||
|
||||
url = 'http://localhost:{port}/login?{query}'.format(
|
||||
port=tools.config['xmlrpc_port'],
|
||||
query=urllib.urlencode({
|
||||
'db': tools.config['db_name'],
|
||||
'login': user,
|
||||
'key': password,
|
||||
})
|
||||
)
|
||||
auth = self.opener.open(url)
|
||||
assert auth.getcode() < 400, "Auth failure %d" % auth.getcode()
|
||||
|
||||
def _wrapped_run(self, result, debug=False):
|
||||
paths = collections.deque(['/'])
|
||||
seen = set(paths)
|
||||
|
||||
while paths:
|
||||
url = paths.popleft()
|
||||
r = self._request(url)
|
||||
cases.URLCase(self.user, url, r).run(result)
|
||||
|
||||
if r.info().gettype() != 'text/html':
|
||||
continue
|
||||
|
||||
doc = lxml.html.fromstring(r.read())
|
||||
for link in doc.xpath('//a[@href]'):
|
||||
href = link.get('href')
|
||||
|
||||
# avoid repeats, even for links we won't crawl no need to
|
||||
# bother splitting them if we've already ignored them
|
||||
# previously
|
||||
if href in seen: continue
|
||||
seen.add(href)
|
||||
|
||||
parts = urlparse.urlsplit(href)
|
||||
|
||||
if parts.netloc or \
|
||||
not parts.path.startswith('/') or \
|
||||
parts.path == '/web' or\
|
||||
parts.path.startswith('/web/') or \
|
||||
(parts.scheme and parts.scheme not in ('http', 'https')):
|
||||
continue
|
||||
|
||||
paths.append(href)
|
||||
|
||||
def load_tests(loader, base, _):
|
||||
base.addTest(CrawlSuite())
|
||||
# blog duplicate (&al?) are on links
|
||||
#base.addTest(CrawlSuite('admin', tools.config['admin_passwd']))
|
||||
#base.addTest(CrawlSuite('demo', 'demo'))
|
||||
return base
|
||||
@@ -266,9 +266,6 @@
|
||||
<a href="#" class="js_publish_btn css_unpublish">Unpublish</a>
|
||||
<a href="#" class="js_publish_btn css_publish">Publish</a>
|
||||
</li>
|
||||
<li t-if="publish_duplicate">
|
||||
<a t-att-href="publish_duplicate">Duplicate</a>
|
||||
</li>
|
||||
<li t-if="publish_edit">
|
||||
<a t-att-href="'/web#model=%s&id=%s' % (object._name, object.id)"
|
||||
title='Edit in backend'>Edit</a>
|
||||
@@ -432,7 +429,7 @@ User-agent: *
|
||||
Sitemap: <t t-esc="url_root"/>sitemap.xml
|
||||
</template>
|
||||
|
||||
<template id="sitemap" name="Site Map" page="True">
|
||||
<template id="sitemap" name="Site Map">
|
||||
<t t-call="website.layout">
|
||||
<ul>
|
||||
<li t-foreach="pages" t-as="page">
|
||||
|
||||
@@ -21,7 +21,14 @@
|
||||
<t t-call="website.publish_management">
|
||||
<t t-set="object" t-value="blog_post"/>
|
||||
<t t-set="publish_edit" t-value="True"/>
|
||||
<t t-set="publish_duplicate" t-value="'/blog/#{blog_post.id}/duplicate'"/>
|
||||
<li>
|
||||
<a href="#" t-attf-data-href="/blog/#{blog_post.id}/duplicate">Duplicate</a>
|
||||
<script>
|
||||
var $a=$("[data-href$='/duplicate']");
|
||||
$a.attr("href", $a.data('href')).removeAttr('data-href');
|
||||
$a.next("script").remove();
|
||||
</script>
|
||||
</li>
|
||||
</t>
|
||||
</div>
|
||||
<h2 class="text-center">
|
||||
@@ -78,7 +85,14 @@
|
||||
<t t-call="website.publish_management">
|
||||
<t t-set="object" t-value="blog_post"/>
|
||||
<t t-set="publish_edit" t-value="True"/>
|
||||
<t t-set="publish_duplicate" t-value="'/blog/%s/duplicate' % (blog_post.id)"/>
|
||||
<li>
|
||||
<a href="#" t-attf-data-href="/blog/#{blog_post.id}/duplicate">Duplicate</a>
|
||||
<script>
|
||||
var $a=$("[data-href$='/duplicate']");
|
||||
$a.attr("href", $a.data('href')).removeAttr('data-href');
|
||||
$a.next("script").remove();
|
||||
</script>
|
||||
</li>
|
||||
</t>
|
||||
</div>
|
||||
<div class="clearfix"/>
|
||||
@@ -175,7 +189,7 @@
|
||||
</template>
|
||||
|
||||
<!-- Page -->
|
||||
<template id="index" name="Blog" page="True">
|
||||
<template id="index" name="Blog">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="head">
|
||||
<script type="text/javascript" src="/website_blog/static/src/js/website_blog.js"></script>
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="contactus_thanks" name="Contact us" page="True">
|
||||
<template id="contactus_thanks" name="Contact us">
|
||||
<t t-call="website.layout">
|
||||
<div id="wrap">
|
||||
<div class="oe_structure"/>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</template>
|
||||
|
||||
<!-- Page -->
|
||||
<template id="index" name="Events" page="True">
|
||||
<template id="index" name="Events">
|
||||
<t t-call="website.layout">
|
||||
<div id="wrap">
|
||||
<div class="container">
|
||||
|
||||
@@ -11,4 +11,4 @@ class hr(osv.osv):
|
||||
}
|
||||
|
||||
def img(self, cr, uid, ids, field='image_small', context=None):
|
||||
return "/web/binary/image?model=%s&field=%s&id=%s" % (self._name, field, ids[0])
|
||||
return "/website/image?model=%s&field=%s&id=%s" % (self._name, field, ids[0])
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="index" name="Jobs" page="True">
|
||||
<template id="index" name="Jobs">
|
||||
<t t-call="website.layout">
|
||||
<div id="wrap">
|
||||
<div class="oe_structure"/>
|
||||
|
||||
@@ -263,10 +263,11 @@ class Ecommerce(http.Controller):
|
||||
filter[index.index(cat_id)].append( cat[2] )
|
||||
post.pop(key)
|
||||
|
||||
return request.redirect("/shop/?filter=%s%s%s" % (
|
||||
return request.redirect("/shop/?filter=%s%s%s%s" % (
|
||||
simplejson.dumps(filter).replace(" ", ""),
|
||||
add_filter and "&add_filter=%s" % add_filter or "",
|
||||
post and "&%s" % urllib.urlencode(post) or ""
|
||||
post.get("search") and "&search=%s" % post.get("search") or "",
|
||||
post.get("category") and "&category=%s" % post.get("category") or ""
|
||||
))
|
||||
|
||||
def attributes_to_ids(self, attributes):
|
||||
@@ -351,8 +352,8 @@ class Ecommerce(http.Controller):
|
||||
category_list = sorted(category_list, key=lambda category: category[1])
|
||||
|
||||
category = None
|
||||
if post.get('category_id') and int(post.get('category_id')):
|
||||
category = category_obj.browse(request.cr, request.uid, int(post.get('category_id')), context=request.context)
|
||||
if post.get('category') and int(post.get('category')):
|
||||
category = category_obj.browse(request.cr, request.uid, int(post.get('category')), context=request.context)
|
||||
|
||||
request.context['pricelist'] = self.get_pricelist()
|
||||
product = product_obj.browse(request.cr, request.uid, product_id, context=request.context)
|
||||
|
||||
@@ -9,4 +9,5 @@ access_product_product_price_type_public,product.price.type.public,product.model
|
||||
access_sale_order_public,sale.order.public,model_sale_order,base.group_public,1,0,0,0
|
||||
access_sale_order_line_public,sale.order.line.public,model_sale_order_line,base.group_public,1,0,0,0
|
||||
access_product_attribute,product.attribute.public,website_sale.model_product_attribute,base.group_public,1,0,0,0
|
||||
access_product_attribute_value,product.attribute.value.public,website_sale.model_product_attribute_value,base.group_public,1,0,0,0
|
||||
access_product_attribute_value,product.attribute.value.public,website_sale.model_product_attribute_value,base.group_public,1,0,0,0
|
||||
access_product_attribute_product,product.attribute.product.public,website_sale.model_product_attribute_product,base.group_public,1,0,0,0
|
||||
|
@@ -64,7 +64,7 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template id="products" name="Products" page="True">
|
||||
<template id="products" name="Products">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="head">
|
||||
<script type="text/javascript" src="/web/static/lib/jquery.ui/js/jquery-ui-1.9.1.custom.js"></script>
|
||||
@@ -235,7 +235,7 @@
|
||||
<div class="col-sm-5">
|
||||
<ol class="breadcrumb">
|
||||
<li><a t-href="/shop">Products</a></li>
|
||||
<li t-if="search.get('category')"><a t-att-href="'/shop/" t-keep-query="category,search,facettes"><span t-field="category.name"/></a></li>
|
||||
<li t-if="search.get('category')"><a t-href="/shop/" t-keep-query="category,search,facettes"><span t-field="category.name"/></a></li>
|
||||
<li class="active"><span t-field="product.name"></span></li>
|
||||
</ol>
|
||||
</div><div class="col-sm-3">
|
||||
@@ -344,7 +344,7 @@
|
||||
|
||||
<!-- Page Shop my cart -->
|
||||
|
||||
<template id="mycart" name="Your Cart" page="True">
|
||||
<template id="mycart" name="Your Cart">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="head">
|
||||
<script type="text/javascript" src="/website_sale/static/src/js/website_sale.js"></script>
|
||||
@@ -422,7 +422,7 @@
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">
|
||||
<a t-href="./add_cart/?remove=True&order_line_id=#{ line.id }" class="mb8 js_add_cart_json">
|
||||
<a t-href="./add_cart/?remove=True&order_line_id=#{ line.id }" class="mb8 js_add_cart_json">
|
||||
<span class="icon-minus"/>
|
||||
</a>
|
||||
</span>
|
||||
@@ -439,7 +439,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class='pull-right mb16' id="mycart_total">
|
||||
<table class='pull-right mb16' id="mycart_total" t-if="website_sale_order">
|
||||
<colgroup>
|
||||
<col width="100"/>
|
||||
<col width="120"/>
|
||||
@@ -622,7 +622,7 @@
|
||||
<div class="col-md-8 oe_mycart">
|
||||
<h3 class="page-header mt16">Billing Information
|
||||
<small t-if="user_id.id == website.public_user.id"> or
|
||||
<a t-if="not partner" t-attf-href="/web#action=redirect&url=#{ request.httprequest.host_url }/shop/checkout/">sign in</a>
|
||||
<a t-if="not partner" t-attf-href="/web#action=redirect&url=#{ request.httprequest.url }">sign in</a>
|
||||
</small>
|
||||
</h3>
|
||||
<div class="row">
|
||||
@@ -639,7 +639,7 @@
|
||||
<input type="email" name="email" class="form-control" t-att-value="checkout.get('email')"/>
|
||||
</div>
|
||||
<div t-attf-class="form-group #{ error.get('phone') and 'has-error' or ''} col-lg-6">
|
||||
<label class="control-label" for="phone">Telephone</label>
|
||||
<label class="control-label" for="phone">Phone</label>
|
||||
<input type="tel" name="phone" class="form-control" t-att-value="checkout.get('phone')"/>
|
||||
</div>
|
||||
|
||||
@@ -695,7 +695,7 @@
|
||||
<input type="text" name="shipping_name" class="form-control" t-att-value="checkout.get('shipping_name', '')"/>
|
||||
</div>
|
||||
<div t-attf-class="form-group #{error.get('shipping_phone') and 'has-error' or ''} col-lg-6">
|
||||
<label class="control-label" for="contact_name">Telephone</label>
|
||||
<label class="control-label" for="contact_name">Phone</label>
|
||||
<input type="tel" name="shipping_phone" class="form-control" t-att-value="checkout.get('shipping_phone', '')"/>
|
||||
</div>
|
||||
<div t-attf-class="form-group #{error.get('shipping_street') and 'has-error' or ''} col-lg-6">
|
||||
|
||||
Reference in New Issue
Block a user