django.utils.six.moves.urllib.parse.urlsplit._replace.geturl

Here are the examples of the python api django.utils.six.moves.urllib.parse.urlsplit._replace.geturl taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

6 Examples 7

Example 1

Project: django-xmpp-account
Source File: middleware.py
View license
    def get_context(self, request, message):
        host = request.META['REMOTE_ADDR']

        context = {
            'EXCEPTION': message,
            'HOST': host,
            'REGISTER_URL': request.build_absolute_uri('/'),
        }
        if 'CANONICAL_HOST' in request.site:
            context['REGISTER_URL'] = urlsplit(context['REGISTER_URL'])._replace(
                netloc=request.site['CANONICAL_HOST']).geturl()

        return context

Example 2

Project: django-xmpp-account
Source File: middleware.py
View license
    def get_context(self, request, message):
        host = request.META['REMOTE_ADDR']

        context = {
            'EXCEPTION': message,
            'HOST': host,
            'REGISTER_URL': request.build_absolute_uri('/'),
        }
        if 'CANONICAL_HOST' in request.site:
            context['REGISTER_URL'] = urlsplit(context['REGISTER_URL'])._replace(
                netloc=request.site['CANONICAL_HOST']).geturl()

        return context

Example 3

Project: django-xmpp-account
Source File: views.py
View license
    def get_context_data(self, **kwargs):
        context = super(AntiSpamFormView, self).get_context_data(**kwargs)
        context['menuitem'] = getattr(self, 'menuitem', None)

        # Social media
        action_url = self.action_url
        if action_url is not None:
            action_url = reverse(action_url)
        context['ACTION_URL'] = self.request.build_absolute_uri(action_url)
        context['REGISTER_URL'] = self.request.build_absolute_uri('/')

        if 'CANONICAL_HOST' in self.request.site:
            context['ACTION_URL'] = urlsplit(context['ACTION_URL'])._replace(
                netloc=self.request.site['CANONICAL_HOST']).geturl()
            context['REGISTER_URL'] = urlsplit(context['REGISTER_URL'])._replace(
                netloc=self.request.site['CANONICAL_HOST']).geturl()

        context['OPENGRAPH_TITLE'] = self.opengraph_title % self.request.site
        context['OPENGRAPH_DESCRIPTION'] = self.opengraph_description % self.request.site
        context['TWITTER_TEXT'] = getattr(self, 'twitter_text', context['OPENGRAPH_TITLE'])

        form = context['form']
        if settings.GPG and hasattr(form, 'cleaned_data') and 'gpg_key' in form.fields:
            if form['gpg_key'].errors or form['fingerprint'].errors or \
                    form.cleaned_data.get('fingerprint') or form.cleaned_data.get('gpg_key'):
                context['show_gpg'] = True
        return context

Example 4

Project: django-xmpp-account
Source File: views.py
View license
    def get_context_data(self, **kwargs):
        context = super(AntiSpamFormView, self).get_context_data(**kwargs)
        context['menuitem'] = getattr(self, 'menuitem', None)

        # Social media
        action_url = self.action_url
        if action_url is not None:
            action_url = reverse(action_url)
        context['ACTION_URL'] = self.request.build_absolute_uri(action_url)
        context['REGISTER_URL'] = self.request.build_absolute_uri('/')

        if 'CANONICAL_HOST' in self.request.site:
            context['ACTION_URL'] = urlsplit(context['ACTION_URL'])._replace(
                netloc=self.request.site['CANONICAL_HOST']).geturl()
            context['REGISTER_URL'] = urlsplit(context['REGISTER_URL'])._replace(
                netloc=self.request.site['CANONICAL_HOST']).geturl()

        context['OPENGRAPH_TITLE'] = self.opengraph_title % self.request.site
        context['OPENGRAPH_DESCRIPTION'] = self.opengraph_description % self.request.site
        context['TWITTER_TEXT'] = getattr(self, 'twitter_text', context['OPENGRAPH_TITLE'])

        form = context['form']
        if settings.GPG and hasattr(form, 'cleaned_data') and 'gpg_key' in form.fields:
            if form['gpg_key'].errors or form['fingerprint'].errors or \
                    form.cleaned_data.get('fingerprint') or form.cleaned_data.get('gpg_key'):
                context['show_gpg'] = True
        return context

Example 5

Project: django-xmpp-account
Source File: views.py
View license
    def get_context_data(self, **kwargs):
        context = super(XMPPAccountView, self).get_context_data(**kwargs)
        context['menuitem'] = self.purpose

        # Social media
        action_path = reverse('xmpp_accounts:%s' % self.purpose)
        context['ACTION_URL'] = self.request.build_absolute_uri(action_path)
        context['REGISTER_URL'] = self.request.build_absolute_uri(
            reverse('xmpp_accounts:register'))
        context['OPENGRAPH_TITLE'] = _messages[self.purpose]['opengraph_title'] % self.request.site
        context['OPENGRAPH_DESCRIPTION'] = _messages[self.purpose]['opengraph_description'] \
                                            % self.request.site
        context['TWITTER_TEXT'] = _messages[self.purpose].get('twitter_text',
                                                              context['OPENGRAPH_TITLE'])

        if 'CANONICAL_HOST' in self.request.site:
            context['ACTION_URL'] = urlsplit(context['ACTION_URL'])._replace(
                netloc=self.request.site['CANONICAL_HOST']).geturl()
            context['REGISTER_URL'] = urlsplit(context['REGISTER_URL'])._replace(
                netloc=self.request.site['CANONICAL_HOST']).geturl()

        # TODO: Yes, that's ugly!
        form = context['form']
        if settings.GPG and hasattr(form, 'cleaned_data') and 'gpg_key' in form.fields:
            if form['gpg_key'].errors or form['fingerprint'].errors or \
                    form.cleaned_data.get('fingerprint') or form.cleaned_data.get('gpg_key'):
                context['show_gpg'] = True
        return context

Example 6

Project: django-xmpp-account
Source File: views.py
View license
    def get_context_data(self, **kwargs):
        context = super(XMPPAccountView, self).get_context_data(**kwargs)
        context['menuitem'] = self.purpose

        # Social media
        action_path = reverse('xmpp_accounts:%s' % self.purpose)
        context['ACTION_URL'] = self.request.build_absolute_uri(action_path)
        context['REGISTER_URL'] = self.request.build_absolute_uri(
            reverse('xmpp_accounts:register'))
        context['OPENGRAPH_TITLE'] = _messages[self.purpose]['opengraph_title'] % self.request.site
        context['OPENGRAPH_DESCRIPTION'] = _messages[self.purpose]['opengraph_description'] \
                                            % self.request.site
        context['TWITTER_TEXT'] = _messages[self.purpose].get('twitter_text',
                                                              context['OPENGRAPH_TITLE'])

        if 'CANONICAL_HOST' in self.request.site:
            context['ACTION_URL'] = urlsplit(context['ACTION_URL'])._replace(
                netloc=self.request.site['CANONICAL_HOST']).geturl()
            context['REGISTER_URL'] = urlsplit(context['REGISTER_URL'])._replace(
                netloc=self.request.site['CANONICAL_HOST']).geturl()

        # TODO: Yes, that's ugly!
        form = context['form']
        if settings.GPG and hasattr(form, 'cleaned_data') and 'gpg_key' in form.fields:
            if form['gpg_key'].errors or form['fingerprint'].errors or \
                    form.cleaned_data.get('fingerprint') or form.cleaned_data.get('gpg_key'):
                context['show_gpg'] = True
        return context