~openerp-community/openobject-addons/openerp-evernote

« back to all changes in this revision

Viewing changes to openerp_evernote/openerp_evernote.py

  • Committer: Kalpana Hemnani
  • Date: 2014-06-23 06:44:53 UTC
  • Revision ID: k.hemnani.serpentcs@gmail.com-20140623064453-ro1xxec739rwo3dz
[IMP]openerp_evernote:improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
        
52
52
        if not url:
53
53
            raise osv.except_osv(('Warning!'), ('Please enter  url !'))
54
 
        if url[0:16] != 'evernote:///view':
 
54
        if url[0:16] != 'https://www.ever':
55
55
            raise osv.except_osv(('Warning!'), ('Please check url !'))
56
56
            
57
57
        guid = re.findall('[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}', url)
59
59
        if not guid:
60
60
            raise osv.except_osv(('Warning!'), ('Please check url !'))
61
61
      
62
 
        auth_token = "S=s1:U=72d01:E=1479a33c4dd:C=140428298df:P=1cd:A=en-devtoken:V=2:H=f85f82d8927640558388d21d02819d7f"
 
62
        eve_config_obj = self.pool.get('evernote.configuration')
 
63
        auth_token = eve_config_obj.browse(cr,uid,1,context=context).auth_token
 
64
        
 
65
#         auth_token = "S=s411:U=45ed069:E=18fb45c2014:C=14647706903:P=1dd:A=en-w32-xauth-new:V=2:H=f8d727f0a58a18a43a0d5ac8350f1a94"
63
66
        try:
64
 
            client = EvernoteClient(token=auth_token, sandbox=False)
 
67
            client = EvernoteClient(token=auth_token, sandbox=True)
65
68
        except : 
66
69
            raise osv.except_osv(('Warning!'), ('Please check token information!'))
67
70
        
68
71
                
69
72
        note = client.get_note_store().getNote(guid[0], True, True, True, True)
70
 
        noteStore = client.get_note_store()
71
 
        getnote = noteStore.getNote(guid[0], True, True, True, True)
72
 
        note_created = getnote.created
 
73
#         noteStore = client.get_note_store()
 
74
#         getnote = noteStore.getNote(guid[0], True, True, True, True)
 
75
        note_created = note.created
73
76
        note_date = time.strftime('%Y-%m-%d', time.gmtime(note_created / 1000))
74
 
        xml = etree.fromstring(getnote.content)
 
77
        xml = etree.fromstring(note.content)
75
78
        content = xml.text
76
79
        title = note.title
77
 
                
78
80
        return {'value' : {'name' : title, 'description': content , 'date' : note_date}}
79
81
 
80
82
openerp_evernote()
179
181
   
180
182
    def create_note(self, cr, uid, ids, context=None):
181
183
        
182
 
        auth_token = "S=s1:U=72d01:E=1479a33c4dd:C=140428298df:P=1cd:A=en-devtoken:V=2:H=f85f82d8927640558388d21d02819d7f"
 
184
        eve_config_obj = self.pool.get('evernote.configuration')
 
185
        auth_token = eve_config_obj.browse(cr,uid,1,context=context).auth_token
183
186
        try:
184
187
            client = EvernoteClient(token=auth_token, sandbox=False)
185
188
        except :