def pad_generate_url(self, cr, uid, context=None): company = self.pool.get('res.users').browse(cr, SUPERUSER_ID, uid, context=context).company_id pad = { "server": company.pad_server, "key": company.pad_key, } # make sure pad server in the form of http://hostname if not pad["server"]: return pad if not pad["server"].startswith('http'): pad["server"] = 'http://' + pad["server"] pad["server"] = pad["server"].rstrip('/') # generate a salt s = string.ascii_uppercase + string.digits salt = ''.join([ s[random.SystemRandom().randint(0, len(s) - 1)] for i in range(10) ]) #path # etherpad hardcodes pad id length limit to 50 path = '-%s-%s' % (self._name, salt) path = '%s%s' % (cr.dbname.replace('_', '-')[0:50 - len(path)], path) # contruct the url url = '%s/p/%s' % (pad["server"], path) #if create with content if "field_name" in context and "model" in context and "object_id" in context: myPad = EtherpadLiteClient(pad["key"], pad["server"] + '/api') try: myPad.createPad(path) except urllib2.URLError: raise UserError( _("Pad creation failed, either there is a problem with your pad server URL or with your connection." )) #get attr on the field model model = self.pool[context["model"]] field = model._fields[context['field_name']] real_field = field.pad_content_field #get content of the real field for record in model.browse(cr, uid, [context["object_id"]]): if record[real_field]: myPad.setText( path, (html2plaintext(record[real_field]).encode('utf-8'))) #Etherpad for html not functional #myPad.setHTML(path, record[real_field]) return { "server": pad["server"], "path": path, "url": url, }
def pad_generate_url(self, cr, uid, context=None): company = self.pool.get('res.users').browse(cr, SUPERUSER_ID, uid, context=context).company_id pad = { "server" : company.pad_server, "key" : company.pad_key, } # make sure pad server in the form of http://hostname if not pad["server"]: return pad if not pad["server"].startswith('http'): pad["server"] = 'http://' + pad["server"] pad["server"] = pad["server"].rstrip('/') # generate a salt s = string.ascii_uppercase + string.digits salt = ''.join([s[random.randint(0, len(s) - 1)] for i in range(10)]) #path # etherpad hardcodes pad id length limit to 50 path = '-%s-%s' % (self._name, salt) path = '%s%s' % (cr.dbname.replace('_','-')[0:50 - len(path)], path) # contruct the url url = '%s/p/%s' % (pad["server"], path) #if create with content if "field_name" in context and "model" in context and "object_id" in context: myPad = EtherpadLiteClient( pad["key"], pad["server"]+'/api') try: myPad.createPad(path) except urllib2.URLError: raise osv.except_osv(_("Error"), _("Pad creation failed, \ either there is a problem with your pad server URL or with your connection.")) #get attr on the field model model = self.pool[context["model"]] field = model._fields[context['field_name']] real_field = field.pad_content_field #get content of the real field for record in model.browse(cr, uid, [context["object_id"]]): if record[real_field]: myPad.setText(path, (html2plaintext(record[real_field]).encode('utf-8'))) #Etherpad for html not functional #myPad.setHTML(path, record[real_field]) return { "server": pad["server"], "path": path, "url": url, }
def pad_generate_url(self, cr, uid, context=None): company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id pad = { "server": company.pad_server, "key": company.pad_key, } # make sure pad server in the form of http://hostname if not pad["server"]: return pad if not pad["server"].startswith('http'): pad["server"] = 'http://' + pad["server"] pad["server"] = pad["server"].rstrip('/') # generate a salt s = string.ascii_uppercase + string.digits salt = ''.join([s[random.randint(0, len(s) - 1)] for i in range(10)]) #path path = '%s-%s-%s' % (cr.dbname.replace('_', '-'), self._name, salt) # contruct the url url = '%s/p/%s' % (pad["server"], path) #if create with content if "field_name" in context and "model" in context and "object_id" in context: myPad = EtherpadLiteClient(pad["key"], pad["server"] + '/api') myPad.createPad(path) #get attr on the field model model = self.pool[context["model"]] field = model._all_columns[context['field_name']] real_field = field.column.pad_content_field #get content of the real field for record in model.browse(cr, uid, [context["object_id"]]): if record[real_field]: myPad.setText(path, html2plaintext(record[real_field])) #Etherpad for html not functional #myPad.setHTML(path, record[real_field]) return { "server": pad["server"], "path": path, "url": url, }
def pad_generate_url(self, cr, uid, context=None): company = self.pool.get("res.users").browse(cr, uid, uid, context=context).company_id pad = {"server": company.pad_server, "key": company.pad_key} # make sure pad server in the form of http://hostname if not pad["server"]: return pad if not pad["server"].startswith("http"): pad["server"] = "http://" + pad["server"] pad["server"] = pad["server"].rstrip("/") # generate a salt s = string.ascii_uppercase + string.digits salt = "".join([s[random.randint(0, len(s) - 1)] for i in range(10)]) # path path = "%s-%s-%s" % (cr.dbname.replace("_", "-"), self._name, salt) # contruct the url url = "%s/p/%s" % (pad["server"], path) # if create with content if "field_name" in context and "model" in context and "object_id" in context: myPad = EtherpadLiteClient(pad["key"], pad["server"] + "/api") try: myPad.createPad(path) except urllib2.URLError: raise osv.except_osv( _("Error"), _( "Pad creation failed, \ either there is a problem with your pad server URL or with your connection." ), ) # get attr on the field model model = self.pool[context["model"]] field = model._all_columns[context["field_name"]] real_field = field.column.pad_content_field # get content of the real field for record in model.browse(cr, uid, [context["object_id"]]): if record[real_field]: myPad.setText(path, html2plaintext(record[real_field])) # Etherpad for html not functional # myPad.setHTML(path, record[real_field]) return {"server": pad["server"], "path": path, "url": url}
def pad_generate_url(self, cr, uid, context=None): company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id; pad = { "server" : company.pad_server, "key" : company.pad_key or "4DxmsNIbnQUVQMW9S9tx2oLOSjFdrx1l", } # make sure pad server in the form of http://hostname if not pad["server"]: return '' if not pad["server"].startswith('http'): pad["server"] = 'http://' + pad["server"] pad["server"] = pad["server"].rstrip('/') # generate a salt s = string.ascii_uppercase + string.digits salt = ''.join([s[random.randint(0, len(s) - 1)] for i in range(10)]) #path path = '%s-%s-%s' % (cr.dbname.replace('_','-'), self._name, salt) # contruct the url url = '%s/p/%s' % (pad["server"], path) #if create with content if "field_name" in context and "model" in context and "object_id" in context: myPad = EtherpadLiteClient( pad["key"], pad["server"]+'/api') myPad.createPad(path) #get attr on the field model model = self.pool.get(context["model"]) field = model._all_columns[context['field_name']] real_field = field.column.pad_content_field #get content of the real field for record in model.browse(cr, uid, [context["object_id"]]): if record[real_field]: myPad.setText(path, html2plaintext(record[real_field])) #Etherpad for html not functional #myPad.setHTML(path, record[real_field]) return { "server": pad["server"], "path": path, "url": url, }