Merge lp:~vauxoo/addons-vauxoo/7.0-add_public_information_sync_youtube_luiseev into lp:addons-vauxoo/7.0

Proposed by Luis Escobar V. (Vauxoo)
Status: Merged
Merged at revision: 895
Proposed branch: lp:~vauxoo/addons-vauxoo/7.0-add_public_information_sync_youtube_luiseev
Merge into: lp:addons-vauxoo/7.0
Diff against target: 54 lines (+16/-0)
1 file modified
sync_youtube/model/sign_youtube.py (+16/-0)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/7.0-add_public_information_sync_youtube_luiseev
Reviewer Review Type Date Requested Status
Jose Antonio Morales Ponce(vauxoo) - - http://www.vauxoo.com Pending
Review via email: mp+192521@code.launchpad.net

Description of the change

[IMP] Added Public Information field to pass youtube id.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sync_youtube/model/sign_youtube.py'
2--- sync_youtube/model/sign_youtube.py 2013-09-12 07:22:55 +0000
3+++ sync_youtube/model/sign_youtube.py 2013-10-24 14:59:16 +0000
4@@ -27,6 +27,8 @@
5 from openerp.osv import osv, fields
6 from openerp.tools.translate import _
7 import logging
8+import urlparse
9+import urllib2
10 _logger = logging.getLogger("SignYouTube")
11 try:
12 from gdata.youtube import service
13@@ -64,6 +66,13 @@
14 '''
15 Return the video details
16 '''
17+ youtube_id = ''
18+ if entry:
19+ youtube_url = entry.GetHtmlLink().href
20+ if youtube_url:
21+ url_data = urlparse.urlparse(youtube_url)
22+ query = urlparse.parse_qs(url_data.query)
23+ youtube_id = query.get("v") and query.get("v")[0] or ''
24 entry_data = {
25 'name': entry and entry.media.title.text or '',
26 'published': entry and entry.published.text or '',
27@@ -75,6 +84,7 @@
28 'favorites': entry and entry.statistics and entry.statistics.favorite_count or '',
29 'views': entry and entry.statistics and entry.statistics.view_count or '',
30 'private': entry.media.private and entry.media.private.text,
31+ 'public_information': entry and youtube_id or '',
32 }
33 return entry_data
34
35@@ -144,6 +154,10 @@
36 if line_ids:
37 line_brw = line.browse(
38 cr, uid, line_ids[0], context=context)
39+ line.write(cr, uid, line_ids,
40+ {
41+ 'public_information': item.get('public_information', ''), },
42+ context=context)
43 if str(line_brw.duration_seconds) == str(item.get('duration_seconds', '')):
44 line.write(cr, uid, line_ids,
45 {'update': 0,
46@@ -191,6 +205,8 @@
47 'YouTube'),
48 'description': fields.text('Description', help='Description added for this video when was '
49 'created'),
50+ 'public_information': fields.text('Public Information', help='This information accept html'
51+ 'and is the information that will be used in the portal page.'),
52 }
53 _defaults = {
54 'update': 0,