Ejemplo n.º 1
0
    def view(self, db, token, action, id, view='calendar'):
        registry = ecore.modules.registry.RegistryManager.get(db)
        meeting_pool = registry.get('calendar.event')
        attendee_pool = registry.get('calendar.attendee')
        partner_pool = registry.get('res.partner')
        with registry.cursor() as cr:
            attendee = attendee_pool.search_read(
                cr, ecore.SUPERUSER_ID, [('access_token', '=', token)], [])

            if attendee and attendee[0] and attendee[0].get('partner_id'):
                partner_id = int(attendee[0].get('partner_id')[0])
                tz = partner_pool.read(cr, ecore.SUPERUSER_ID, partner_id,
                                       ['tz'])['tz']
            else:
                tz = False

            attendee_data = meeting_pool.get_attendee(cr, ecore.SUPERUSER_ID,
                                                      id, dict(tz=tz))

        if attendee:
            attendee_data['current_attendee'] = attendee[0]

        values = dict(init="""
                ecore.define('calendar.invitation_page', function (require) {
                    require('base_calendar.base_calendar').showCalendarInvitation('%s', '%s', '%s', '%s', '%s');
                });
            """ % (db, action, id, 'form', json.dumps(attendee_data)))
        return request.render('web.webclient_bootstrap', values)
Ejemplo n.º 2
0
    def FieldTextHtml(self, model=None, res_id=None, field=None, callback=None, **kwargs):
        cr, uid, context = request.cr, request.uid, request.context

        kwargs.update(
            model=model,
            res_id=res_id,
            field=field,
            datarecord=json.loads(kwargs['datarecord']),
            debug='debug' in kwargs)

        for k in kwargs:
            if isinstance(kwargs[k], basestring) and kwargs[k].isdigit():
                kwargs[k] = int(kwargs[k])

        trans = dict(
            lang=kwargs.get('lang', context.get('lang')),
            translatable=kwargs.get('translatable'),
            edit_translations=kwargs.get('edit_translations'),
            editable=kwargs.get('enable_editor'))

        context.update(trans)
        kwargs.update(trans)

        record = None
        if model and kwargs.get('res_id'):
            record = request.registry[model].browse(cr, uid, kwargs.get('res_id'), context)

        kwargs.update(content=record and getattr(record, field) or "")

        return request.render(kwargs.get("template") or "web_editor.FieldTextHtml", kwargs, uid=request.uid)
Ejemplo n.º 3
0
    def view(self, db, token, action, id, view='calendar'):
        registry = ecore.modules.registry.RegistryManager.get(db)
        meeting_pool = registry.get('calendar.event')
        attendee_pool = registry.get('calendar.attendee')
        partner_pool = registry.get('res.partner')
        with registry.cursor() as cr:
            attendee = attendee_pool.search_read(cr, ecore.SUPERUSER_ID, [('access_token', '=', token)], [])

            if attendee and attendee[0] and attendee[0].get('partner_id'):
                partner_id = int(attendee[0].get('partner_id')[0])
                tz = partner_pool.read(cr, ecore.SUPERUSER_ID, partner_id, ['tz'])['tz']
            else:
                tz = False

            attendee_data = meeting_pool.get_attendee(cr, ecore.SUPERUSER_ID, id, dict(tz=tz))

        if attendee:
            attendee_data['current_attendee'] = attendee[0]

        values = dict(
            init = """
                ecore.define('calendar.invitation_page', function (require) {
                    require('base_calendar.base_calendar').showCalendarInvitation('%s', '%s', '%s', '%s', '%s');
                });
            """ % (db, action, id, 'form', json.dumps(attendee_data))
        )
        return request.render('web.webclient_bootstrap', values)
Ejemplo n.º 4
0
class AuthSignupHome(ecore.addons.web.controllers.main.Home):
    @http.route()
    def web_login(self, *args, **kw):
        ensure_db()
        response = super(AuthSignupHome, self).web_login(*args, **kw)
        response.qcontext.update(self.get_auth_signup_config())
        if request.httprequest.method == 'GET' and request.session.uid and request.params.get(
                'redirect'):
            # Redirect if already logged in and redirect param is present
            return http.redirect_with_hash(request.params.get('redirect'))
        return response

    @http.route('/web/signup', type='http', auth='public', website=True)
    def web_auth_signup(self, *args, **kw):
        qcontext = self.get_auth_signup_qcontext()

        if not qcontext.get('token') and not qcontext.get('signup_enabled'):
            raise werkzeug.exceptions.NotFound()

        if 'error' not in qcontext and request.httprequest.method == 'POST':
            try:
                self.do_signup(qcontext)
                return super(AuthSignupHome, self).web_login(*args, **kw)
            except (SignupError, AssertionError), e:
                qcontext['error'] = _(e.message)

        return request.render('auth_signup.signup', qcontext)
Ejemplo n.º 5
0
 def loader(self, channel_id, **kwargs):
     username = kwargs.get("username", _("Visitor"))
     channel = request.env['im_livechat.channel'].sudo().browse(channel_id)
     info = request.env['im_livechat.channel'].match_rules(
         request, channel.id, username=username)
     return request.render('im_livechat.loader', {
         'info': info,
         'web_session_required': True
     }) if info else False
Ejemplo n.º 6
0
Archivo: main.py Proyecto: LiberTang0/5
    def a(self, debug=False, **k):
        cr, uid, context, session = request.cr, request.uid, request.context, request.session

        # if user not logged in, log him in
        PosSession = request.registry['pos.session']
        pos_session_ids = PosSession.search(cr, uid, [('state','=','opened'),('user_id','=',session.uid)], context=context)
        if not pos_session_ids:
            return werkzeug.utils.redirect('/web#action=point_of_sale.action_pos_session_opening')
        PosSession.login(cr, uid, pos_session_ids, context=context)
        
        return request.render('point_of_sale.index')
Ejemplo n.º 7
0
Archivo: main.py Proyecto: ecoreos/hz
 def jobs_apply(self, job, **kwargs):
     error = {}
     default = {}
     if 'website_hr_recruitment_error' in request.session:
         error = request.session.pop('website_hr_recruitment_error')
         default = request.session.pop('website_hr_recruitment_default')
     return request.render("website_hr_recruitment.apply", {
         'job': job,
         'error': error,
         'default': default,
     })
Ejemplo n.º 8
0
 def jobs_apply(self, job, **kwargs):
     error = {}
     default = {}
     if 'website_hr_recruitment_error' in request.session:
         error = request.session.pop('website_hr_recruitment_error')
         default = request.session.pop('website_hr_recruitment_default')
     return request.render("website_hr_recruitment.apply", {
         'job': job,
         'error': error,
         'default': default,
     })
Ejemplo n.º 9
0
 def add_rating(self, token, rate, **kwargs):
     Rating = request.env['rating.rating']
     rating = Rating.search([('access_token', '=', token)])
     if rating:
         is_rated = bool(rating.rating != -1)
         if not is_rated:
             request.env['rating.rating'].apply_rating(rate, token=token)
         # redirect to the form view if logged person
         if request.session.uid and not is_rated:
             record = request.env[rating.res_model].browse(rating.res_id)
             return werkzeug.utils.redirect('/web#model=%s&id=%s&view_type=form' % (record._name, record.id))
         return request.render('rating.rating_external_page_view', {'rating': rate, 'is_rated': is_rated})
     return request.not_found()
Ejemplo n.º 10
0
 def authorize_form_feedback(self, **post):
     _logger.info('Authorize: entering form_feedback with post data %s', pprint.pformat(post))
     return_url = '/'
     if post:
         request.env['payment.transaction'].sudo().form_feedback(post, 'authorize')
         return_url = post.pop('return_url', '/')
     base_url = request.env['ir.config_parameter'].get_param('web.base.url')
     # Authorize.Net is expecting a response to the POST sent by their server.
     # This response is in the form of a URL that Authorize.Net will pass on to the
     # client's browser to redirect them to the desired location need javascript.
     return request.render('payment_authorize.payment_authorize_redirect', {
         'return_url': '%s' % urlparse.urljoin(base_url, return_url)
     })
Ejemplo n.º 11
0
 def add_rating(self, token, rate, **kwargs):
     Rating = request.env['rating.rating']
     rating = Rating.search([('access_token', '=', token)])
     if rating:
         is_rated = bool(rating.rating != -1)
         if not is_rated:
             request.env['rating.rating'].apply_rating(rate, token=token)
         # redirect to the form view if logged person
         if request.session.uid and not is_rated:
             record = request.env[rating.res_model].browse(rating.res_id)
             return werkzeug.utils.redirect(
                 '/web#model=%s&id=%s&view_type=form' %
                 (record._name, record.id))
         return request.render('rating.rating_external_page_view', {
             'rating': rate,
             'is_rated': is_rated
         })
     return request.not_found()
Ejemplo n.º 12
0
Archivo: main.py Proyecto: ecoreos/hz
    def FieldTextHtml(self,
                      model=None,
                      res_id=None,
                      field=None,
                      callback=None,
                      **kwargs):
        cr, uid, context = request.cr, request.uid, request.context

        kwargs.update(model=model,
                      res_id=res_id,
                      field=field,
                      datarecord=json.loads(kwargs['datarecord']),
                      debug='debug' in kwargs)

        for k in kwargs:
            if isinstance(kwargs[k], basestring) and kwargs[k].isdigit():
                kwargs[k] = int(kwargs[k])

        trans = dict(lang=kwargs.get('lang', context.get('lang')),
                     translatable=kwargs.get('translatable'),
                     edit_translations=kwargs.get('edit_translations'),
                     editable=kwargs.get('enable_editor'))

        context.update(trans)
        kwargs.update(trans)

        record = None
        if model and kwargs.get('res_id'):
            record = request.registry[model].browse(cr, uid,
                                                    kwargs.get('res_id'),
                                                    context)

        kwargs.update(content=record and getattr(record, field) or "")

        return request.render(kwargs.get("template")
                              or "web_editor.FieldTextHtml",
                              kwargs,
                              uid=request.uid)
Ejemplo n.º 13
0
    @http.route('/website/info', type='http', auth="public", website=True)
    def website_info(self):
        try:
            request.website.get_template('website.info').name
        except Exception, e:
            return request.registry['ir.http']._handle_exception(e, 404)
        irm = request.env['ir.module.module'].sudo()
        apps = irm.search([('state','=','installed'),('application','=',True)])
        modules = irm.search([('state','=','installed'),('application','=',False)])
        values = {
            'apps': apps,
            'modules': modules,
            'version': ecore.service.common.exp_version()
        }
        return request.render('website.info', values)

    #------------------------------------------------------
    # Edit
    #------------------------------------------------------
    @http.route('/website/add/<path:path>', type='http', auth="user", website=True)
    def pagenew(self, path, noredirect=False, add_menu=None):
        xml_id = request.registry['website'].new_page(request.cr, request.uid, path, context=request.context)
        if add_menu:
            request.registry['website.menu'].create(
                request.cr, request.uid, {
                    'name': path,
                    'url': "/page/" + xml_id[8:],
                    'parent_id': request.website.menu_id.id,
                    'website_id': request.website.id,
                }, context=request.context)
Ejemplo n.º 14
0
Archivo: main.py Proyecto: ecoreos/hz
    @http.route('/website/info', type='http', auth="public", website=True)
    def website_info(self):
        try:
            request.website.get_template('website.info').name
        except Exception, e:
            return request.registry['ir.http']._handle_exception(e, 404)
        irm = request.env['ir.module.module'].sudo()
        apps = irm.search([('state','=','installed'),('application','=',True)])
        modules = irm.search([('state','=','installed'),('application','=',False)])
        values = {
            'apps': apps,
            'modules': modules,
            'version': ecore.service.common.exp_version()
        }
        return request.render('website.info', values)

    #------------------------------------------------------
    # Edit
    #------------------------------------------------------
    @http.route('/website/add/<path:path>', type='http', auth="user", website=True)
    def pagenew(self, path, noredirect=False, add_menu=None, template=False):
        if template:
            xml_id = request.registry['website'].new_page(request.cr, request.uid, path, template=template, context=request.context)
        else:
            xml_id = request.registry['website'].new_page(request.cr, request.uid, path, context=request.context)
        if add_menu:
            request.registry['website.menu'].create(
                request.cr, request.uid, {
                    'name': path,
                    'url': "/page/" + xml_id[8:],
Ejemplo n.º 15
0
 def jobs_detail(self, job, **kwargs):
     return request.render("website_hr_recruitment.detail", {
         'job': job,
         'main_object': job,
     })
Ejemplo n.º 16
0
Archivo: main.py Proyecto: ecoreos/hz
class Website(ecore.addons.web.controllers.main.Home):
    #------------------------------------------------------
    # View
    #------------------------------------------------------
    @http.route('/', type='http', auth="public", website=True)
    def index(self, **kw):
        page = 'homepage'
        try:
            main_menu = request.env.ref('website.main_menu')
        except Exception:
            pass
        else:
            first_menu = main_menu.child_id and main_menu.child_id[0]
            if first_menu:
                if first_menu.url and (not (first_menu.url.startswith(('/page/', '/?', '/#')) or (first_menu.url == '/'))):
                    return request.redirect(first_menu.url)
                if first_menu.url and first_menu.url.startswith('/page/'):
                    return request.registry['ir.http'].reroute(first_menu.url)
        return self.page(page)

    #------------------------------------------------------
    # Login - overwrite of the web login so that regular users are redirected to the backend 
    # while portal users are redirected to the frontend by default
    #------------------------------------------------------
    @http.route(website=True, auth="public")
    def web_login(self, redirect=None, *args, **kw):
        r = super(Website, self).web_login(redirect=redirect, *args, **kw)
        if not redirect and request.params['login_success']:
            if request.registry['res.users'].has_group(request.cr, request.uid, 'base.group_user'):
                redirect = '/web?' + request.httprequest.query_string
            else:
                redirect = '/'
            return http.redirect_with_hash(redirect)
        return r

    @http.route('/website/lang/<lang>', type='http', auth="public", website=True, multilang=False)
    def change_lang(self, lang, r='/', **kwargs):
        if lang == 'default':
            lang = request.website.default_lang_code
            r = '/%s%s' % (lang, r or '/')
        redirect = werkzeug.utils.redirect(r or ('/%s' % lang), 303)
        redirect.set_cookie('website_lang', lang)
        return redirect

    @http.route('/page/<page:page>', type='http', auth="public", website=True, cache=300)
    def page(self, page, **opt):
        values = {
            'path': page,
            'deletable': True, # used to add 'delete this page' in content menu
        }
        # /page/website.XXX --> /page/XXX
        if page.startswith('website.'):
            return request.redirect('/page/' + page[8:], code=301)
        elif '.' not in page:
            page = 'website.%s' % page

        try:
            request.website.get_template(page)
        except ValueError, e:
            # page not found
            if request.website.is_publisher():
                values.pop('deletable')
                page = 'website.page_404'
            else:
                return request.registry['ir.http']._handle_exception(e, 404)

        return request.render(page, values)
Ejemplo n.º 17
0
Archivo: main.py Proyecto: ecoreos/hz
 def robots(self):
     return request.render('website.robots', {'url_root': request.httprequest.url_root}, mimetype='text/plain')
Ejemplo n.º 18
0
    def a(self, debug=False, **k):
        if not request.session.uid:
            return http.local_redirect('/web/login?redirect=/stock/barcode/')

        return request.render('stock.barcode_index')
Ejemplo n.º 19
0
                else:
                    login = qcontext.get('login')
                    assert login, "No login provided."
                    res_users = request.registry.get('res.users')
                    res_users.reset_password(request.cr, ecore.SUPERUSER_ID,
                                             login)
                    qcontext['message'] = _(
                        "An email has been sent with credentials to reset your password"
                    )
            except SignupError:
                qcontext['error'] = _("Could not reset your password")
                _logger.exception('error when resetting password')
            except Exception, e:
                qcontext['error'] = _(e.message)

        return request.render('auth_signup.reset_password', qcontext)

    def get_auth_signup_config(self):
        """retrieve the module config (which features are enabled) for the login page"""

        icp = request.registry.get('ir.config_parameter')
        return {
            'signup_enabled':
            icp.get_param(request.cr, ecore.SUPERUSER_ID,
                          'auth_signup.allow_uninvited') == 'True',
            'reset_password_enabled':
            icp.get_param(request.cr, ecore.SUPERUSER_ID,
                          'auth_signup.reset_password') == 'True',
        }

    def get_auth_signup_qcontext(self):
Ejemplo n.º 20
0
                    self.do_signup(qcontext)
                    return super(AuthSignupHome, self).web_login(*args, **kw)
                else:
                    login = qcontext.get('login')
                    assert login, "No login provided."
                    res_users = request.registry.get('res.users')
                    res_users.reset_password(request.cr, ecore.SUPERUSER_ID, login)
                    qcontext['message'] = _("An email has been sent with credentials to reset your password")
            except SignupError:
                qcontext['error'] = _("Could not reset your password")
                _logger.exception('error when resetting password')
            except Exception, e:
                qcontext['error'] = _(e.message)


        return request.render('auth_signup.reset_password', qcontext)

    def get_auth_signup_config(self):
        """retrieve the module config (which features are enabled) for the login page"""

        icp = request.registry.get('ir.config_parameter')
        return {
            'signup_enabled': icp.get_param(request.cr, ecore.SUPERUSER_ID, 'auth_signup.allow_uninvited') == 'True',
            'reset_password_enabled': icp.get_param(request.cr, ecore.SUPERUSER_ID, 'auth_signup.reset_password') == 'True',
        }

    def get_auth_signup_qcontext(self):
        """ Shared helper returning the rendering context for signup and reset password """
        qcontext = request.params.copy()
        qcontext.update(self.get_auth_signup_config())
        if qcontext.get('token'):
Ejemplo n.º 21
0
 def support_page(self, channel_id, **kwargs):
     channel = request.env['im_livechat.channel'].sudo().browse(channel_id)
     return request.render('im_livechat.support_page', {'channel': channel})
Ejemplo n.º 22
0
 def robots(self):
     return request.render('website.robots', {'url_root': request.httprequest.url_root}, mimetype='text/plain')
Ejemplo n.º 23
0
 def support_page(self, channel_id, **kwargs):
     channel = request.env['im_livechat.channel'].sudo().browse(channel_id)
     return request.render('im_livechat.support_page', {'channel': channel})
Ejemplo n.º 24
0
 def loader(self, channel_id, **kwargs):
     username = kwargs.get("username", _("Visitor"))
     channel = request.env['im_livechat.channel'].sudo().browse(channel_id)
     info = request.env['im_livechat.channel'].match_rules(request, channel.id, username=username)
     return request.render('im_livechat.loader', {'info': info, 'web_session_required': True}) if info else False
Ejemplo n.º 25
0
Archivo: main.py Proyecto: ecoreos/hz
 def jobs_detail(self, job, **kwargs):
     return request.render("website_hr_recruitment.detail", {
         'job': job,
         'main_object': job,
     })