Beispiel #1
0
    def process_request(self, request):
        domain = get_domain_by_request(request)
        request.bucket_name = settings.AWS_BUCKET_NAME

        try:
            account = Account.get_by_domain(domain)
        except Account.DoesNotExist:
            logger = logging.getLogger(__name__)
            logger.error('The account do not exists: %s' % domain)
            return HttpResponseForbidden('')

        request.account = account

        preferences = account.get_preferences()
        preferences.load_all()
        preferences['account_id'] = account.id
        request.preferences = preferences

        bucket_name = preferences['account_bucket_name']
        if bucket_name:
            request.bucket_name = bucket_name

        is_signin = False  #Deprecado
        is_login = False  #Deprecado
        is_activate = False  #Deprecado
        is_jsi18n = request.path.startswith('/jsi18n')

        language = request.preferences['account_language']
        if language:
            request.session['django_language'] = language
            request.auth_manager.language = language

        # TODO: Esto debería ir en una url y hacer el redirect
        if settings.DOMAINS['microsites'] == domain:
            if request.META.get('REQUEST_URI') == '/':
                return redirect(
                    get_domain_with_protocol('microsites') + "/home")

        # hacemos que el User sea un AccountAnonymousUser
        # lo creamos con el account y el lenguaje que tenga el account_language
        request.user = AccountAnonymousUser(request.account,
                                            preferences['account_language'])

        return None
Beispiel #2
0
    def process_request(self, request):
        domain = get_domain_by_request(request)
        request.bucket_name = settings.AWS_BUCKET_NAME

        try:
            account = Account.get_by_domain(domain)
        except Account.DoesNotExist:
            logger = logging.getLogger(__name__)
            logger.error('The account do not exists: %s' % domain)
            return HttpResponseForbidden('') 

        request.account = account

        preferences = account.get_preferences()
        preferences.load_all()
        preferences['account_id'] = account.id
        request.preferences = preferences

        bucket_name = preferences['account_bucket_name']
        if bucket_name:
            request.bucket_name = bucket_name

        is_signin = False #Deprecado
        is_login = False #Deprecado
        is_activate = False #Deprecado
        is_jsi18n = request.path.startswith('/jsi18n')

        language = request.preferences['account_language']
        if language:
            request.session['django_language'] = language
            request.auth_manager.language = language

        # TODO: Esto debería ir en una url y hacer el redirect
        if settings.DOMAINS['microsites'] == domain:
            if request.META.get('REQUEST_URI') == '/':
                return redirect(get_domain_with_protocol('microsites') + "/home")

        # hacemos que el User sea un AccountAnonymousUser
        # lo creamos con el account y el lenguaje que tenga el account_language
        request.user = AccountAnonymousUser(request.account, preferences['account_language'])

        return None
Beispiel #3
0
    def process_request(self, request):
        """
        Checks user, role and account
        """

        # for anonymous users
        request.session['django_language'] = settings.LANGUAGES[0][0]

        if request.META.has_key('HTTP_ACCEPT_LANGUAGE'):
            user_language = request.META['HTTP_ACCEPT_LANGUAGE'].split(
                ',')[0].split('-')[0]
            if user_language in [
                    language[0] for language in settings.LANGUAGES
            ]:
                request.session['django_language'] = user_language

        request.auth_manager = AuthManager(
            language=request.session['django_language'],
            account=Account.get_by_domain(get_domain_by_request(request)))

        # el user se arma en middlerware.ioc ya que necesitamos el account para completar el user
        request.user = None
        return None
Beispiel #4
0
    def process_request(self, request):
        domain = get_domain_by_request(request)
        request.bucket_name = settings.AWS_BUCKET_NAME

        try:
            account = Account.get_by_domain(domain)
        except Account.DoesNotExist:
            logger = logging.getLogger(__name__)
            logger.error('The account do not exists: %s' % domain)
            raise AccountDoesNotExist

        request.account = account

        preferences = account.get_preferences()
        preferences.load_all()
        preferences['account_id'] = account.id
        request.preferences = preferences

        bucket_name = preferences['account_bucket_name']
        if bucket_name:
            request.bucket_name = bucket_name

        is_signin = False #Deprecado
        is_login = False #Deprecado
        is_activate = False #Deprecado
        is_jsi18n = request.path.startswith('/jsi18n')

        language = request.preferences['account_language']
        if language:
            request.session['django_language'] = language
            request.auth_manager.language = language

        if settings.DOMAINS['microsites'] == domain:
            if request.META.get('REQUEST_URI') == '/':
                return redirect(get_domain_with_protocol('microsites') + "/home")

        return None
Beispiel #5
0
    def resolve_account(self, request):
        domain = get_domain_by_request(request)

        # creo que en algun punto desreferencia a Account
        from core.models import Account
        return Account.get_by_domain(domain)
Beispiel #6
0
    def resolve_account(self, request):
        domain = get_domain_by_request(request)

        # creo que en algun punto desreferencia a Account
        from core.models import Account
        return Account.get_by_domain(domain)