From: Thibault Delavallée Date: Fri, 11 Oct 2013 09:39:13 +0000 (+0200) Subject: [CLEAN] [IMP] website_blog: module cleaning + website template improvements X-Git-Tag: InsPy_master01~73^2~1247 X-Git-Url: http://git.inspyration.org/?a=commitdiff_plain;h=c120a9de7a083d2ef6951f6da58e1fdfd0e9a88e;hp=5c7e3be8abd24e366cac4bb79bd199e3c88c9e88;p=odoo%2Fodoo.git [CLEAN] [IMP] website_blog: module cleaning + website template improvements [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 --- diff --git a/addons/website_blog/__init__.py b/addons/website_blog/__init__.py index f184fc8..2d54250 100644 --- a/addons/website_blog/__init__.py +++ b/addons/website_blog/__init__.py @@ -20,5 +20,5 @@ ############################################################################## import controllers -import website_blog +import models import wizard diff --git a/addons/website_blog/__openerp__.py b/addons/website_blog/__openerp__.py index 987ee74..91e32de 100644 --- a/addons/website_blog/__openerp__.py +++ b/addons/website_blog/__openerp__.py @@ -32,16 +32,16 @@ OpenERP Blog 'author': 'OpenERP SA', 'depends': ['knowledge', 'website_mail'], 'data': [ - 'website_blog_data.xml', + 'data/website_blog_data.xml', 'views/website_blog_classic.xml', 'views/website_blog_templates.xml', # 'wizard/document_page_create_menu_view.xml', 'wizard/document_page_show_diff_view.xml', 'security/ir.model.access.csv', - 'security/website_mail.xml', + 'security/website_blog.xml', ], 'demo': [ - 'website_blog_demo.xml' + 'data/website_blog_demo.xml' ], 'test': [ 'test/document_page_test00.yml' diff --git a/addons/website_blog/data/website_blog_data.xml b/addons/website_blog/data/website_blog_data.xml new file mode 100644 index 0000000..194ce82 --- /dev/null +++ b/addons/website_blog/data/website_blog_data.xml @@ -0,0 +1,71 @@ + + + + + + + Website Blogs + self + /blog + + + + open + + + + + News + Presentation of new OpenERP features + +Summary of the feature + +Long explanation + +Conclusion + +Additional ressources + + + + + + New Post + blog.post + + New Post + + + Post Published + blog.post + + Post Published + + + + New Post + blog.category + + + category_id + + + + + + + Jobs + Job Announces + + + + + + + + + diff --git a/addons/website_blog/data/website_blog_demo.xml b/addons/website_blog/data/website_blog_demo.xml new file mode 100644 index 0000000..3ddea7b --- /dev/null +++ b/addons/website_blog/data/website_blog_demo.xml @@ -0,0 +1,349 @@ + + + + + + + + functional + + + pos + + + + + OpenERP v8 New Features + + + +
+
+
+ +
+
+

+ OpenERP's Point of Sale introduces a super clean + interface with no installation required that runs + online and offline on modern hardwares. +

+ It's full integration with the company inventory + and accounting, gives you real time statistics + without the hassle of integrating several applications. +

+
+
+
+ +
+
+
+
+

+ Linked with Project Management +

+

Infinitely flexible. Incredibly easy to use.

+
+
+

+ OpenERP's collaborative and realtime project + management helps your team get work done. Keep + track of everything, from the big picture to the + minute details, from the customer contract to the + billing. +

+ Organize projects around your own processes. Work + on tasks and issues using the kanban view, schedule + tasks using the gantt chart and control deadlines + in the calendar view. Every project may have it's + own stages allowing teams to optimize their job. +

+
+
+
+
+
+
+
+
+

Work with the hardware you already have...

+
+
+ +
+
+

+ No installation required +

+

+ OpenERP's Point of Sale introduces a super clean + interface with no installation required that runs + online and offline on modern hardware. Laptops, + tablets, industrial POS, it runs on everything. +

+

+ Get more information » +

+
+
+
+
+ +]]> +
+
+ + + New Hardware Integration + + + + +
+
+
+ +
+
+

+ New Features Launched +

+

+ OpenERP's Point of Sale introduces a super clean + interface with no installation required that runs + online and offline on modern hardware. Laptops, + tablets, industrial POS, it runs on everything. +

+
+
+
+ +
+
+
+
+

Our Offers

+
+ +
+
+ +
+

Beginner

+

+ Starter package +

+
+
+

$450.00

+
per month
+
+ + +
    +
  • Battery: 8 hours
  • +
  • Screen: 2.5 inch
  • +
  • Weight: 1.1 ounces
  • +
  • No support
  • +
+ +
+
+
+
+ +
+

Professional

+

+ Enterprise package +

+
+
+

$590.00

+
per month
+
+ + +
    +
  • Battery: 12 hours
  • +
  • Screen: 2.8 inch
  • +
  • Weight: 1.2 ounces
  • +
  • Limited support
  • +
+ +
+
+
+
+ +
+

Expert

+

+ The top of the top +

+
+
+

$890.00

+
per month
+
+ + +
    +
  • Battery: 20 hours
  • +
  • Screen: 2.8 inch
  • +
  • Weight: 1.2 ounces
  • +
  • Unlimited support
  • +
+ +
+ +
+
+
+
+ + +]]> +
+
+ + + Touchscreen Point of Sale + + + +The brand new OpenERP touchscreen point of sale available with 6.1 allows you +to manage your shop sales very easily. It's fully web based so that you don't +have to install or deploy any software and all the sales shops can be easily +consolidated. It works in connected and disconnected modes so that you can +continue to sell if you lose your internet connection.

+ +

Here's a summary of its main features and benefits:

+
    +
  • 100% WEB based
  • +
  • available for any touchscreen device (ipod, ipad, any tablet)mobile (with portable devices)
  • +
  • no installation required
  • +
  • no synchronization needed, completely integrated
  • +
  • continue working even when your connection is down if you close your browser, data won't be lost
  • +
  • fully web based with a clean interface smart interface
  • +
+

You have different options to select your products. You can do it through the +barcode reader, just browse through the categories you have put in place (ie. +drinks, snacks, meals, etc.), or text search in case neither of the other +options work for you. If you need to use the POS for your restaurant, for +example, your employees can record at the same time multiple tickets without +having to wait to do one transaction at a time. Along, to facilitate payment, +the application allows multiple payment methods.

+

The POS application is so simple and accessible to use that your shop or +restaurant will never need any other tool to manage orders. Due to its smart +and user-friendly interface you don't need any training to learn how to use it. +Think of it as an out-of-the-box solution to boost your business' productivity. +

+]]> +
+
+ + + Announcig a New Partnership + + + +
+
+
+ +
+
+

+ We are proud to announce a new partnership with + the company OpenERP. Their open source application suite + will allow us to reach new market, specifically in + the accounting area. +

+ The full integration with the company inventory + and accounting, will give our customers real time statistics + without the hassle of integrating several applications. +

+
+
+
+ +
+
+
+
+

+ Linked with Project Management +

+

Infinitely flexible. Incredibly easy to use.

+
+
+

+ OpenERP's collaborative and realtime project + management helps your team get work done. Keep + track of everything, from the big picture to the + minute details, from the customer contract to the + billing. +

+ Organize projects around your own processes. Work + on tasks and issues using the kanban view, schedule + tasks using the gantt chart and control deadlines + in the calendar view. Every project may have it's + own stages allowing teams to optimize their job. +

+
+
+
+
+
+
+
+
+

Work with the hardware you already have...

+
+
+ +
+
+

+ No installation required +

+

+ OpenERP's Point of Sale introduces a super clean + interface with no installation required that runs + online and offline on modern hardware. Laptops, + tablets, industrial POS, it runs on everything. +

+

+ Get more information » +

+
+
+
+
+ +]]> +
+
+ + +
+
diff --git a/addons/website_blog/models/__init__.py b/addons/website_blog/models/__init__.py new file mode 100644 index 0000000..fb5368a --- /dev/null +++ b/addons/website_blog/models/__init__.py @@ -0,0 +1 @@ +import website_blog diff --git a/addons/website_blog/models/website_blog.py b/addons/website_blog/models/website_blog.py new file mode 100644 index 0000000..001029d --- /dev/null +++ b/addons/website_blog/models/website_blog.py @@ -0,0 +1,206 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-Today OpenERP SA (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + + +from openerp import tools +from openerp import SUPERUSER_ID +from openerp.osv import osv, fields +from openerp.tools.translate import _ + +import difflib + + +class BlogCategory(osv.Model): + _name = 'blog.category' + _description = 'Blog Category' + _inherit = ['mail.thread'] + _order = 'name' + + _columns = { + 'name': fields.char('Name', required=True), + 'description': fields.text('Description'), + 'template': fields.html('Template'), + 'blog_post_ids': fields.one2many( + 'blog.post', 'category_id', + 'Blogs', + ), + } + + +class BlogTag(osv.Model): + _name = 'blog.tag' + _description = 'Blog Tag' + _order = 'name' + + _columns = { + 'name': fields.char('Name', required=True), + 'blog_post_ids': fields.many2many( + 'blog.post', string='Posts', + ), + } + + +class BlogPost(osv.Model): + _name = "blog.post" + _description = "Blog Post" + _inherit = ['mail.thread'] + _order = 'name' + # maximum number of characters to display in summary + _shorten_max_char = 250 + + def get_shortened_content(self, cr, uid, ids, name, arg, context=None): + res = {} + for page in self.browse(cr, uid, ids, context=context): + try: + body_short = tools.html_email_clean( + page.content, + remove=True, + shorten=True, + max_length=self._shorten_max_char, + expand_options={ + 'oe_expand_container_tag': 'div', + 'oe_expand_container_class': 'oe_mail_expand text-center', + 'oe_expand_container_content': '', + 'oe_expand_a_href': '/blog/%d/%d' % (page.category_id.id, page.id), + 'oe_expand_a_class': 'oe_mail_expand btn btn-info', + 'oe_expand_separator_node': 'br', + }, + protect_sections=True, + ) + except Exception: + body_short = False + res[page.id] = body_short + return res + + _columns = { + 'name': fields.char('Title', required=True), + 'category_id': fields.many2one( + 'blog.category', 'Category', + required=True, ondelete='cascade', + ), + 'tag_ids': fields.many2many( + 'blog.tag', string='Tags', + ), + 'content': fields.html('Content'), + 'shortened_content': fields.function( + get_shortened_content, + type='html', + string='Shortened Content', + help="Shortened content of the page that serves as a summary" + ), + # website control + 'website_published': fields.boolean( + 'Publish', help="Publish on the website" + ), + 'website_published_datetime': fields.datetime( + 'Publish Date' + ), + # TDE TODO FIXME: when website_mail/mail_thread.py inheritance work -> this field won't be necessary + 'website_message_ids': fields.one2many( + 'mail.message', 'res_id', + domain=lambda self: [ + '&', ('model', '=', self._name), ('type', '=', 'comment') + ], + string='Website Messages', + help="Website communication history", + ), + # technical stuff: history, menu (to keep ?) + 'history_ids': fields.one2many( + 'blog.post.history', 'post_id', + 'History', help='Last post modifications' + ), + 'menu_id': fields.many2one('ir.ui.menu', "Menu", readonly=True), + # creation / update stuff + 'create_date': fields.datetime( + 'Created on', + select=True, readonly=True, + ), + 'create_uid': fields.many2one( + 'res.users', 'Author', + select=True, readonly=True, + ), + 'write_date': fields.datetime( + 'Last Modified on', + select=True, readonly=True, + ), + 'write_uid': fields.many2one( + 'res.users', 'Last Contributor', + select=True, readonly=True, + ), + } + + def create_history(self, cr, uid, ids, vals, context=None): + for i in ids: + history = self.pool.get('blog.post.history') + if vals.get('content'): + res = { + 'content': vals.get('content', ''), + 'post_id': i, + } + history.create(cr, uid, res) + + def create(self, cr, uid, vals, context=None): + if context is None: + context = {} + create_context = dict(context, mail_create_nolog=True) + post_id = super(BlogPost, self).create(cr, uid, vals, context=create_context) + self.create_history(cr, uid, [post_id], vals, context) + return post_id + + def write(self, cr, uid, ids, vals, context=None): + result = super(BlogPost, self).write(cr, uid, ids, vals, context) + self.create_history(cr, uid, ids, vals, context) + return result + + def img(self, cr, uid, ids, field='image_small', context=None): + post = self.browse(cr, SUPERUSER_ID, ids[0], context=context) + return "/website/image?model=%s&field=%s&id=%s" % ('res.users', field, post.create_uid.id) + + +class BlogPostHistory(osv.Model): + _name = "blog.post.history" + _description = "Document Page History" + _order = 'id DESC' + _rec_name = "create_date" + + _columns = { + 'post_id': fields.many2one('blog.post', 'Blog Post'), + 'summary': fields.char('Summary', size=256, select=True), + 'content': fields.text("Content"), + 'create_date': fields.datetime("Date"), + 'create_uid': fields.many2one('res.users', "Modified By"), + } + + def getDiff(self, cr, uid, v1, v2, context=None): + history_pool = self.pool.get('blog.post.history') + text1 = history_pool.read(cr, uid, [v1], ['content'])[0]['content'] + text2 = history_pool.read(cr, uid, [v2], ['content'])[0]['content'] + line1 = line2 = '' + if text1: + line1 = text1.splitlines(1) + if text2: + line2 = text2.splitlines(1) + if (not line1 and not line2) or (line1 == line2): + raise osv.except_osv(_('Warning!'), _('There are no changes in revisions.')) + diff = difflib.HtmlDiff() + return diff.make_table(line1, line2, "Revision-%s" % (v1), "Revision-%s" % (v2), context=True) + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/website_blog/security/website_blog.xml b/addons/website_blog/security/website_blog.xml new file mode 100644 index 0000000..97efcb8 --- /dev/null +++ b/addons/website_blog/security/website_blog.xml @@ -0,0 +1,13 @@ + + + + + + Blog Post: public: published only + + [('website_published', '=', True)] + + + + + diff --git a/addons/website_blog/security/website_mail.xml b/addons/website_blog/security/website_mail.xml deleted file mode 100644 index 97efcb8..0000000 --- a/addons/website_blog/security/website_mail.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - Blog Post: public: published only - - [('website_published', '=', True)] - - - - - diff --git a/addons/website_blog/tests/test_controllers.py b/addons/website_blog/tests/test_controllers.py index d1c28ca..33b37ae 100644 --- a/addons/website_blog/tests/test_controllers.py +++ b/addons/website_blog/tests/test_controllers.py @@ -19,11 +19,11 @@ # ############################################################################## -from openerp.addons.mail.tests.test_mail_base import TestMailBase +from openerp.addons.mail.tests.common import TestMail from openerp.tools import mute_logger, email_split -class TestControllers(TestMailBase): +class TestControllers(TestMail): def test_00(self): cr, uid = self.cr, self.uid diff --git a/addons/website_blog/views/website_blog_templates.xml b/addons/website_blog/views/website_blog_templates.xml index 1fe8b50..c0565ce 100644 --- a/addons/website_blog/views/website_blog_templates.xml +++ b/addons/website_blog/views/website_blog_templates.xml @@ -13,12 +13,12 @@ -