[IMP] removed history wizard, avatar handling
bzr revid: fp@tinyerp.com-20140322175329-s0uum9gircwryg09
This commit is contained in:
parent
690cd34d69
commit
d03a8e8fcd
|
@ -285,8 +285,6 @@ class Website(openerp.addons.web.controllers.main.Home):
|
|||
values = {}
|
||||
if 'website_published' in _object._all_columns:
|
||||
values['website_published'] = not obj.website_published
|
||||
if 'website_published_datetime' in _object._all_columns and values.get('website_published'):
|
||||
values['website_published_datetime'] = fields.datetime.now()
|
||||
_object.write(request.cr, request.uid, [_id],
|
||||
values, context=request.context)
|
||||
|
||||
|
|
|
@ -21,4 +21,3 @@
|
|||
|
||||
import controllers
|
||||
import models
|
||||
import wizard
|
||||
|
|
|
@ -35,7 +35,6 @@ OpenERP Blog
|
|||
'data/website_blog_data.xml',
|
||||
'views/website_blog_views.xml',
|
||||
'views/website_blog_templates.xml',
|
||||
'wizard/document_page_show_diff_view.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'security/website_blog.xml',
|
||||
],
|
||||
|
|
|
@ -109,10 +109,10 @@ class WebsiteBlog(http.Controller):
|
|||
|
||||
if blog:
|
||||
path_filter += "%s/" % blog.id
|
||||
domain += [("id", "in", [post.id for post in blog.blog_post_ids])]
|
||||
domain += [("blog_id", "=", [blog.id])]
|
||||
if tag:
|
||||
path_filter += 'tag/%s/' % tag.id
|
||||
domain += [("id", "in", [post.id for post in tag.blog_post_ids])]
|
||||
domain += [("tag_ids", "in", [tag.id])]
|
||||
if date:
|
||||
path_filter += "date/%s/" % date
|
||||
domain += [("create_date", ">=", date.split("_")[0]), ("create_date", "<=", date.split("_")[1])]
|
||||
|
|
|
@ -25,9 +25,6 @@ from openerp import SUPERUSER_ID
|
|||
from openerp.osv import osv, fields
|
||||
from openerp.tools.translate import _
|
||||
|
||||
import difflib
|
||||
|
||||
|
||||
class Blog(osv.Model):
|
||||
_name = 'blog.blog'
|
||||
_description = 'Blogs'
|
||||
|
@ -38,10 +35,6 @@ class Blog(osv.Model):
|
|||
'subtitle': fields.char('Blog Subtitle'),
|
||||
'description': fields.text('Description'),
|
||||
'image': fields.binary('Image'),
|
||||
'blog_post_ids': fields.one2many(
|
||||
'blog.post', 'blog_id',
|
||||
'Blogs',
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,12 +43,8 @@ class BlogTag(osv.Model):
|
|||
_description = 'Blog Tag'
|
||||
_inherit = ['website.seo.metadata']
|
||||
_order = 'name'
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', required=True),
|
||||
'blog_post_ids': fields.many2many(
|
||||
'blog.post', string='Posts',
|
||||
),
|
||||
}
|
||||
|
||||
class MailMessage(osv.Model):
|
||||
|
@ -68,10 +57,7 @@ class BlogPost(osv.Model):
|
|||
_name = "blog.post"
|
||||
_description = "Blog Post"
|
||||
_inherit = ['mail.thread', 'website.seo.metadata']
|
||||
_order = 'write_date DESC'
|
||||
# maximum number of characters to display in summary
|
||||
_shorten_max_char = 250
|
||||
|
||||
_order = 'id DESC'
|
||||
_columns = {
|
||||
'name': fields.char('Title', required=True, translate=True),
|
||||
'sub_title' : fields.char('Sub Title', translate=True),
|
||||
|
@ -88,9 +74,6 @@ class BlogPost(osv.Model):
|
|||
'website_published': fields.boolean(
|
||||
'Publish', help="Publish on the website"
|
||||
),
|
||||
'website_published_datetime': fields.datetime(
|
||||
'Publish Date'
|
||||
),
|
||||
'website_message_ids': fields.one2many(
|
||||
'mail.message', 'res_id',
|
||||
domain=lambda self: [
|
||||
|
@ -99,11 +82,6 @@ class BlogPost(osv.Model):
|
|||
string='Website Messages',
|
||||
help="Website communication history",
|
||||
),
|
||||
'history_ids': fields.one2many(
|
||||
'blog.post.history', 'post_id',
|
||||
'History', help='Last post modifications',
|
||||
deprecated= 'Will be removed in v9.'
|
||||
),
|
||||
# creation / update stuff
|
||||
'create_date': fields.datetime(
|
||||
'Created on',
|
||||
|
@ -121,73 +99,24 @@ class BlogPost(osv.Model):
|
|||
'res.users', 'Last Contributor',
|
||||
select=True, readonly=True,
|
||||
),
|
||||
'visits': fields.integer('No of Visitors'),
|
||||
'visits': fields.integer('No of Views'),
|
||||
'author_image': fields.related('create_uid','partner_id', 'image_small', string='Author Photo', type='binary')
|
||||
}
|
||||
_defaults = {
|
||||
'website_published': False,
|
||||
'visits': 0
|
||||
}
|
||||
|
||||
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
|
||||
return super(BlogPost, self).create(cr, uid, vals, context=create_context)
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
default = default or {}
|
||||
default.update({
|
||||
'website_published': False,
|
||||
'website_published_datetime': False,
|
||||
})
|
||||
return super(BlogPost, self).copy(cr, uid, id, default=default, context=context)
|
||||
|
||||
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 = "Blog Post 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)
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
|||
blog_blog_all,blog.blog,model_blog_blog,,1,0,0,0
|
||||
blog_post_all,blog.post,model_blog_post,,1,1,0,0
|
||||
blog_post,blog.post,model_blog_post,base.group_document_user,1,1,1,1
|
||||
blog_post_history,blog.post.history,model_blog_post_history,base.group_document_user,1,0,1,0
|
||||
blog_tag,blog.tag,model_blog_tag,,1,0,0,0
|
||||
blog_tag_edition,blog.tag,model_blog_tag,base.group_document_user,1,1,1,1
|
||||
blog_message_post,mail_message,mail.model_mail_message,base.group_public,1,1,1,0
|
||||
|
|
|
|
@ -125,7 +125,7 @@
|
|||
<div t-foreach="blog_posts" t-as="blog_post" class="mb32">
|
||||
|
||||
<img class="img-circle pull-right mt16"
|
||||
t-att-src="'/website/image?model=res.users&field=image_small&id='+str(blog_post.create_uid.id)"
|
||||
t-att-src="'/website/image?model=blog.post&field=author_image&id='+str(blog_post.id)"
|
||||
style="width: 50px;"/>
|
||||
|
||||
<a t-attf-href="/blogpost/#{ slug(blog_post) }?#{ tag and 'tag=%s' % tag.id or '' }#{tag and date and '&' or ''}#{ date and 'date=%s' % date or ''}">
|
||||
|
@ -190,7 +190,7 @@
|
|||
<h1 t-field="blog_post.name" id="blog_post_name" class="mt32"/>
|
||||
<h2 t-field="blog_post.sub_title" class="text-muted"/>
|
||||
<div>
|
||||
<img class="img-circle" t-att-src="'/website/image?model=res.users&field=image_small&id='+str(blog_post.create_uid.id)" style="width: 30px; margin-right: 10px;"/>
|
||||
<img class="img-circle" t-att-src="'/website/image?model=blog.post&field=author_image&id='+str(blog_post.id)" style="width: 30px; margin-right: 10px;"/>
|
||||
<small id="blog_author" t-field="blog_post.create_uid.name"/><br/>
|
||||
</div>
|
||||
<div t-if="blog_post.content_image" id="blog_angle_down">
|
||||
|
@ -228,7 +228,7 @@
|
|||
<h1 t-field="next_post.name"/>
|
||||
<h2 t-field="next_post.sub_title"/>
|
||||
<div>
|
||||
<img class="img-circle" t-att-src="'/website/image?model=res.users&field=image_small&id='+str(next_post.create_uid.id)" style="width: 30px; margin-right: 10px;"/>
|
||||
<img class="img-circle" t-att-src="'/website/image?model=blog.post&field=author_image&id='+str(next_post.id)" style="width: 30px; margin-right: 10px;"/>
|
||||
<small id="blog_author" t-field="next_post.create_uid.name"/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import document_page_show_diff
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -1,61 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.tools.translate import _
|
||||
|
||||
|
||||
class showdiff(osv.osv_memory):
|
||||
""" Disp[ay Difference for History """
|
||||
|
||||
_name = 'blog.post.history.show_diff'
|
||||
|
||||
def get_diff(self, cr, uid, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
history = self.pool.get('blog.post.history')
|
||||
ids = context.get('active_ids', [])
|
||||
|
||||
diff = ""
|
||||
if len(ids) == 2:
|
||||
if ids[0] > ids[1]:
|
||||
diff = history.getDiff(cr, uid, ids[1], ids[0])
|
||||
else:
|
||||
diff = history.getDiff(cr, uid, ids[0], ids[1])
|
||||
|
||||
elif len(ids) == 1:
|
||||
old = history.browse(cr, uid, ids[0])
|
||||
nids = history.search(cr, uid, [('post_id', '=', old.post_id.id)])
|
||||
nids.sort()
|
||||
diff = history.getDiff(cr, uid, ids[0], nids[-1])
|
||||
else:
|
||||
raise osv.except_osv(_('Warning!'), _('You need to select minimum one or maximum two history revisions!'))
|
||||
return diff
|
||||
|
||||
_columns = {
|
||||
'diff': fields.text('Diff', readonly=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'diff': get_diff
|
||||
}
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -1,39 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Create Index Form view -->
|
||||
<record id="view_wiki_show_diff" model="ir.ui.view">
|
||||
<field name="name">Show Difference</field>
|
||||
<field name="model">blog.post.history.show_diff</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Difference" version="7.0">
|
||||
<field name="diff" widget="html" options='{"safe": True}'/>
|
||||
<footer>
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<!-- Create Index Action -->
|
||||
<record id="action_view_wiki_show_diff" model="ir.actions.act_window">
|
||||
<field name="name">Difference</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">blog.post.history.show_diff</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
<!-- Create Index Action Window -->
|
||||
<act_window
|
||||
id="action_view_wiki_show_diff_values"
|
||||
key2="client_action_multi"
|
||||
name="Difference"
|
||||
res_model="blog.post.history.show_diff"
|
||||
src_model="blog.post.history"
|
||||
view_mode="form"
|
||||
target="new"
|
||||
view_type="form"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue