def twitter_wall_callback(self, wall, **kwargs): """ Return to this method if authorize app is success or cancel(denied kwargs) """ if not kwargs.get('denied'): auth = Oauth(wall.stream_id.twitter_api_key, wall.stream_id.twitter_api_secret) access_token_response = Oauth._access_token(auth, kwargs.get('oauth_token'), kwargs.get('oauth_verifier')) wall.write({ 'twitter_access_token': access_token_response['oauth_token'], 'twitter_access_token_secret': access_token_response['oauth_token_secret'], 'auth_user': access_token_response['user_id'] }) wall.stream_id.restart() return http.local_redirect('/twitter_wall/view/%s' % (wall.id)) return http.local_redirect('/twitter_walls')
def index(self, **kw): uid = request.session.uid plan_id = int(kw.get('plan_id')) if not uid: url = '/web/login?redirect=/trial' query = {'plan_id': str(plan_id)} return http.local_redirect(path=url, query=query) partner = request.env['res.users'].browse(uid).partner_id trial_plan = request.env['saas_portal.plan'].sudo().browse(plan_id) support_team = request.env.ref('saas_portal.main_support_team') try: trial_plan.create_new_database(partner_id=partner.id, user_id=uid, notify_user=True, trial=True, support_team_id=support_team.id) except MaximumTrialDBException: url = request.env['ir.config_parameter'].sudo().get_param( 'saas_portal.page_for_maximumtrialdb', '/') return werkzeug.utils.redirect(url) values = { 'plan': trial_plan, } return request.render('saas_portal.try_trial', values)
def invest_post(self, **vals): parm = { 'name': vals.get('name',False), 'phone': vals.get('phone',False), 'address': vals.get('address',False), 'email': vals.get('email',False), 'comment': vals.get('content',False), 'is_investment': True, } request.registry['res.partner'].create(request.cr, SUPERUSER_ID, parm) # # #获取需要发送消息的用户 # user_obj = request.registry['res.users'] # users = user_obj.search(request.cr, SUPERUSER_ID,[('role_option','=',1)], context=request.context) # # if users: # #发送通知给管理员 # message=u"有新招商客户,姓名:%s" % (vals.get('company_name',False)) # push_obj = request.registry['born.push'] # # for user in users: # vals_message={ # 'title':u'有新的公司注册', # 'phone':vals.get('phone',''), # 'content':message, # 'type':'boss', # 'state':'done', # 'user_id':user, # 'message_type':'1', # } # push_id = push_obj.create(request.cr, SUPERUSER_ID,vals_message,context=request.context) # push_obj.send_message(request.cr, SUPERUSER_ID,push_id,context=request.context) return http.local_redirect('/site/invest_success',keep_hash=True)
def twitter_wall_view(self, wall, page=1, **kwargs): """ Storify and Live view of wall (include pagination in storify) """ if not wall.auth_user: return http.local_redirect('/twitter_wall/authenticate/%s' % wall.id) TwitterTweet = request.env['twitter.tweet'] domain = [('agent_id', '=', wall.id)] pager = request.website.pager(url='/twitter_wall/view/%s' % (wall.id), total=TwitterTweet.search_count(domain), page=page, step=self._tweet_per_page, scope=self._tweet_per_page) tweets = TwitterTweet.search(domain, limit=self._tweet_per_page, offset=pager['offset'], order='id desc') self._set_viewed_wall(wall) return request.website.render('website_twitter_wall.twitter_wall_view', { 'wall': wall, 'tweets': tweets, 'pager': pager })
def index(self, **kw): uid = request.session.uid plan_id = int(kw.get('plan_id')) if not uid: url = '/web/login?redirect=/trial' query = {'plan_id': str(plan_id)} return http.local_redirect(path=url, query=query) partner = request.env['res.users'].browse(uid).partner_id trial_plan = request.env['saas_portal.plan'].sudo().browse(plan_id) support_team = request.env.ref('saas_portal.main_support_team') db_creation_allowed = True try: trial_plan.create_new_database(partner_id=partner.id, user_id=uid, notify_user=True, trial=True, support_team_id=support_team.id) except MaximumDBException: db_creation_allowed = False values = { 'plan': trial_plan, 'db_creation_allowed': db_creation_allowed, } return request.render('saas_portal.try_trial', values)
def twitter_wall_delete(self, wall): """ Delete wall """ wall.unlink() return http.local_redirect('/twitter_walls')
def selector(self, **kw): return http.local_redirect('/')
def manager(self, **kw): return http.local_redirect('/')
def edit_email_pos_receipt(self, **kw): request.env.user.partner_id.write({ 'email_pos_receipt': kw.get('email_pos_receipt', False), }) return http.local_redirect('/profile')
def edit_address(self, **kw): new_value = {} for field in list(x for x in UPDATE_ADDRESS if x in kw): new_value.update({field: kw.get(field, False)}) request.env.user.partner_id.write(new_value) return http.local_redirect('/profile')
def site(self, **post): return http.local_redirect('/index', query=request.params, keep_hash=True)
def signup(self, **vals): is_alone= vals.get('is_alone','0'), is_alone=is_alone[0] if is_alone=='0': is_alone=True else: is_alone=False sms_obj = request.registry.get('born.sms') sms=sms_obj.search(request.cr, SUPERUSER_ID, [('phone', '=', vals.get('phone',False)),('security_code', '=', vals.get('code',False)),('state', 'in', ('send','finished'))], offset=0, limit=1, order=" id desc", context=request.context) sms_id= sms and sms[0] or False if not sms_id: return http.local_redirect('/site/index') res = request.registry.get('res.country').search(request.cr, SUPERUSER_ID, [('code', '=', 'CN')], context=request.context) country_id= res and res[0] or False email_active_key=str(uuid.uuid4()) post = { 'name': vals.get('company_name',False), 'contact_name': vals.get('contact_name',False), 'street':vals.get('street',False), 'phone':vals.get('phone',False), 'email':vals.get('email',False), 'admin': vals.get('email',False), 'brand':vals.get('brand',False), 'born_uuid':str(uuid.uuid4()), 'currency_id':8, 'is_register':True, 'is_alone':is_alone, 'password': vals.get('password',0), 'country_id':country_id, 'state_id':vals.get('state_id',False), 'area_id':vals.get('area_id',False), 'subdivide_id':vals.get('subdivide_id',False), 'business_id': int(vals.get('industry')) if vals.get('industry') else False, 'sub_business_id': int(vals.get('industry_category')) if vals.get('industry_category') else False, 'email_active_key':email_active_key, } company_id=request.registry['res.company'].create(request.cr, SUPERUSER_ID, post, request.context) #创建用户 user_parm = { 'company_id': company_id, 'born_uuid':str(uuid.uuid4()), 'login':vals.get('phone',False), 'name': vals.get('contact_name',False), 'company_ids': False, 'active':True, 'share':False, 'is_register':True, 'approved':'unapproved', 'password': vals.get('password',0), 'pp': vals.get('password',0), } user_id = request.registry['res.users'].create(request.cr, SUPERUSER_ID, user_parm, request.context) parm = { 'phone':vals.get('phone',False), 'email':vals.get('email',False), 'admin':vals.get('email',False), 'currency_id':8, 'is_register':True, 'password': vals.get('password',False), 'user_id': user_id, } request.registry['res.company'].write(request.cr, SUPERUSER_ID, company_id, parm) # 读取公司生成的客户ID再次更新 records = request.registry['res.company'].read(request.cr, SUPERUSER_ID, company_id, ['partner_id']) parm = { 'email': vals.get('email',False), 'born_uuid':str(uuid.uuid4()), 'phone': vals.get('phone',False), } request.registry['res.partner'].write(request.cr, SUPERUSER_ID, records['partner_id'][0], parm) args={'param1':vals.get('company_name',False)} ret=sms_obj.send_message_for_call(request.cr, SUPERUSER_ID,vals.get('phone',False),'91005639',args,1,'', request.context) _logger.info(ret) try: #发送邮件 tmpl_obj = request.registry['email.template'] #发送通知邮件 template_notice = request.registry['ir.model.data'].get_object(request.cr, SUPERUSER_ID, 'site', 'company_signup_notice_email') tmpl_obj.send_mail(request.cr, SUPERUSER_ID, template_notice.id, company_id, force_send=True, raise_exception=True) except: _logger.info(u'发送邮件失败%s' % (vals.get('company_name',False))) pass #获取需要发送消息的用户 user_obj = request.registry['res.users'] users = user_obj.search(request.cr, SUPERUSER_ID,[('role_option','=',1)], context=request.context) if users: #发送通知给管理员 message=u"有新的公司在线注册了WE-ERP软件,公司名称:%s" % (vals.get('company_name',False)) push_obj = request.registry['born.push'] for user in users: vals_message={ 'title':u'有新的公司注册', 'phone':vals.get('phone',''), 'content':message, 'type':'boss', 'state':'done', 'user_id':user, 'message_type':'1', } push_id = push_obj.create(request.cr, SUPERUSER_ID,vals_message,context=request.context) push_obj.send_message(request.cr, SUPERUSER_ID,push_id,context=request.context) return http.local_redirect('/site/success',keep_hash=True)