Python django.utils.http 模块,urlquote() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用django.utils.http.urlquote()

项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def post(self, request):
        """Create a keypair.

        Create a keypair using the parameters supplied in the POST
        application/json object. The parameters are:

        :param name: the name to give the keypair
        :param public_key: (optional) a key to import

        This returns the new keypair object on success.
        """
        if 'public_key' in request.DATA:
            new = api.nova.keypair_import(request, request.DATA['name'],
                                          request.DATA['public_key'])
        else:
            new = api.nova.keypair_create(request, request.DATA['name'])
        return rest_utils.CreatedResponse(
            '/api/nova/keypairs/%s' % utils_http.urlquote(new.name),
            new.to_dict()
        )
项目:cetusshop    作者:icetusorg    | 项目源码 | 文件源码
def authorize_url(self):
        from django.utils.http import urlquote

        url = "%s?appid=%s&redirect_uri=%s&response_type=code" % (
                self.AUTHORIZE_URL, self.CLIENT_ID, urlquote(self.REDIRECT_URI)
            )

        self.SCOPE = self.SCOPE_LOGIN

        if getattr(self, 'SCOPE', None) is not None:
            if (self.SCOPE in self.SUPPORTED_SCOPES):
                url = '%s&scope=%s' % (url, self.SCOPE)
            else:
                raise SocialSitesConfigError("SCOPE must be one of (%s)." %(','.join(self.SUPPORTED_SCOPES)), None)
        else:
            raise SocialSitesConfigError("SCOPE is required!", None)

        url = url + '&state=socialoauth#wechat_redirect'
        return url
项目:DjangoCMS    作者:farhan711    | 项目源码 | 文件源码
def cms_perms(func):
    def inner(request, *args, **kwargs):
        page = request.current_page
        if page:
            if page.login_required and not request.user.is_authenticated():
                return redirect_to_login(urlquote(request.get_full_path()), settings.LOGIN_URL)
            if not page.has_view_permission(request):
                return _handle_no_page(request, "$")
        return func(request, *args, **kwargs)
    inner.__module__ = func.__module__
    inner.__doc__ = func.__doc__
    if hasattr(func, '__name__'):
        inner.__name__ = func.__name__
    elif hasattr(func, '__class__'):
        inner.__name__ = func.__class__.__name__
    return inner
项目:website    作者:hackerspace-ntnu    | 项目源码 | 文件源码
def response_forbidden(request, article, urlpath):
    if request.user.is_anonymous():
        qs = request.META.get('QUERY_STRING', '')
        if qs:
            qs = urlquote('?' + qs)
        else:
            qs = ''
        return redirect(settings.LOGIN_URL + "?next=" + request.path + qs)
    else:
        return HttpResponseForbidden(
            render_to_string(
                "wiki/permission_denied.html",
                context={'article': article,
                         'urlpath': urlpath},
                request=request))


# TODO: This decorator is too complex (C901)
项目:Wagtail-Image-Folders    作者:anteatersa    | 项目源码 | 文件源码
def test_get(self):
        """
        This tests that the view responds correctly for a user with edit permissions on this image
        """
        # Get
        response = self.client.get(reverse('wagtailimages:generate_url', args=(self.image.id, 'fill-800x600')))

        # Check response
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response['Content-Type'], 'application/json')

        # Check JSON
        content_json = json.loads(response.content.decode())

        self.assertEqual(set(content_json.keys()), set(['url', 'preview_url']))

        expected_url = 'http://localhost/images/%(signature)s/%(image_id)d/fill-800x600/' % {
            'signature': urlquote(generate_signature(self.image.id, 'fill-800x600').decode(), safe=urlquote_safechars),
            'image_id': self.image.id,
        }
        self.assertEqual(content_json['url'], expected_url)

        expected_preview_url = reverse('wagtailimages:preview', args=(self.image.id, 'fill-800x600'))
        self.assertEqual(content_json['preview_url'], expected_preview_url)
项目:Sentry    作者:NetEaseGame    | 项目源码 | 文件源码
def build_cursor_link(self, request, name, cursor):
        querystring = u'&'.join(
            u'{0}={1}'.format(urlquote(k), urlquote(v))
            for k, v in request.GET.iteritems()
            if k != 'cursor'
        )
        base_url = absolute_uri(request.path)
        if querystring:
            base_url = '{0}?{1}'.format(base_url, querystring)
        else:
            base_url = base_url + '?'

        return LINK_HEADER.format(
            uri=base_url,
            cursor=str(cursor),
            name=name,
            has_results='true' if bool(cursor) else 'false',
        )
项目:social-app-django    作者:python-social-auth    | 项目源码 | 文件源码
def process_exception(self, request, exception):
        strategy = getattr(request, 'social_strategy', None)
        if strategy is None or self.raise_exception(request, exception):
            return

        if isinstance(exception, SocialAuthBaseException):
            backend = getattr(request, 'backend', None)
            backend_name = getattr(backend, 'name', 'unknown-backend')

            message = self.get_message(request, exception)
            social_logger.error(message)

            url = self.get_redirect_uri(request, exception)
            try:
                messages.error(request, message,
                               extra_tags='social-auth ' + backend_name)
            except MessageFailure:
                if url:
                    url += ('?' in url and '&' or '?') + \
                           'message={0}&backend={1}'.format(urlquote(message),
                                                            backend_name)
            if url:
                return redirect(url)
项目:MagiCircles    作者:MagiCircles    | 项目源码 | 文件源码
def signup(request):
    if request.user.is_authenticated():
        redirectToProfile(request)
    if request.method == "POST":
        form = CreateUserForm(request.POST, request=request)
        if form.is_valid():
            new_user = models.User.objects.create_user(**form.cleaned_data)
            user = authenticate(username=form.cleaned_data['username'], password=form.cleaned_data['password'])
            preferences = models.UserPreferences.objects.create(user=user, language=request.LANGUAGE_CODE)
            login_action(request, user)
            url = '/accounts/add/{}{}'.format(
                ('?next={}'.format(urlquote(request.GET['next'])) if 'next' in request.GET else ''),
                ('&next_title={}'.format(request.GET['next_title']) if 'next' in request.GET and 'next_title' in request.GET else ''))
            return redirect(url)
    else:
        form = CreateUserForm(request=request)
    context = getGlobalContext(request)
    context['form'] = form
    context['next'] = request.GET.get('next', None)
    context['next_title'] = request.GET.get('next_title', None)
    return render(request, 'pages/signup.html', context)

############################################################
# Profile
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def test_index_container_selected(self):
        containers = (self.containers.list(), False)
        ret = (self.objects.list(), False)
        api.swift.swift_get_containers(IsA(http.HttpRequest),
                                       marker=None).AndReturn(containers)
        api.swift.swift_get_objects(IsA(http.HttpRequest),
                                    self.containers.first().name,
                                    marker=None,
                                    prefix=None).AndReturn(ret)
        self.mox.ReplayAll()

        container_name = self.containers.first().name
        res = self.client.get(
            reverse('horizon:project:containers:index',
                    args=[utils.wrap_delimiter(container_name)]))
        self.assertTemplateUsed(res, 'project/containers/index.html')
        # UTF8 encoding here to ensure there aren't problems with Nose output.
        expected = [obj.name.encode('utf8') for obj in self.objects.list()]
        self.assertQuerysetEqual(res.context['objects_table'].data,
                                 expected,
                                 lambda obj: obj.name.encode('utf8'))
        # Check if the two forms' URL are properly 'urlquote()d'.
        form_action = ' action="%s%s/" ' % (CONTAINER_INDEX_URL,
                                            CONTAINER_NAME_1_QUOTED)
        self.assertContains(res, form_action, count=2)
        self._test_invalid_paths(res)
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def test_wrap_delimiter(self):
        expected = {
            'containerA': 'containerA/',
            'containerB%': 'containerB%/',  # no urlquote() should occur
            'containerC/': 'containerC/',   # already wrapped name
            'containerD/objectA': 'containerD/objectA/'
        }
        for name, expected_name in expected.items():
            self.assertEqual(utils.wrap_delimiter(name), expected_name)
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def get_link_url(self, datum=None):
        container_name = http.urlquote(datum.name)
        args = (utils.wrap_delimiter(container_name),)
        return reverse(self.url, args=args)
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def get_pool_link(member):
    return reverse("horizon:project:loadbalancers:pooldetails",
                   args=(http.urlquote(member.pool_id),))
项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def get_member_link(member):
    return reverse("horizon:project:loadbalancers:memberdetails",
                   args=(http.urlquote(member.id),))
项目:ecs_sclm    作者:meaningful    | 项目源码 | 文件源码
def quoted_logical_path(self):
        return urlquote(self.pretty_logical_path)
项目:ecs_sclm    作者:meaningful    | 项目源码 | 文件源码
def quoted_logical_path(self):
        return urlquote(self.pretty_logical_path)
项目:CodingDojo    作者:ComputerSocietyUNB    | 项目源码 | 文件源码
def make_template_fragment_key(fragment_name, vary_on=None):
    if vary_on is None:
        vary_on = ()
    key = ':'.join(urlquote(var) for var in vary_on)
    args = hashlib.md5(force_bytes(key))
    return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())
项目:CodingDojo    作者:ComputerSocietyUNB    | 项目源码 | 文件源码
def urlencode(value, safe=None):
    """
    Escapes a value for use in a URL.

    Takes an optional ``safe`` parameter used to determine the characters which
    should not be escaped by Django's ``urlquote`` method. If not provided, the
    default safe characters will be used (but an empty string can be provided
    when *all* characters should be escaped).
    """
    kwargs = {}
    if safe is not None:
        kwargs['safe'] = safe
    return urlquote(value, **kwargs)
项目:NarshaTech    作者:KimJangHyeon    | 项目源码 | 文件源码
def make_template_fragment_key(fragment_name, vary_on=None):
    if vary_on is None:
        vary_on = ()
    key = ':'.join(urlquote(var) for var in vary_on)
    args = hashlib.md5(force_bytes(key))
    return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())
项目:pdpdmeetup    作者:mattharley    | 项目源码 | 文件源码
def get_absolute_url(self):
        return "/users/%s/" % urlquote(self.email)
项目:zing    作者:evernote    | 项目源码 | 文件源码
def get_screenshot_url(self):
        prefix = self.store.translation_project.\
            project.screenshot_search_prefix
        if prefix:
            return prefix + urlquote(self.source_f)
项目:blog_django    作者:chnpmy    | 项目源码 | 文件源码
def get_context(self):
        new_context = {
            'title': self.get_title(),
            'icon': self.icon,
            'portal_key': self.get_portal_key(),
            'columns': [('col-sm-%d' % int(12 / len(self.widgets)), ws) for ws in self.widgets],
            'has_add_widget_permission': self.has_model_perm(UserWidget, 'add') and self.widget_customiz,
            'add_widget_url': self.get_admin_url('%s_%s_add' % (UserWidget._meta.app_label, UserWidget._meta.model_name)) +
            "?user=%s&page_id=%s&_redirect=%s" % (self.user.id, self.get_page_id(), urlquote(self.request.get_full_path()))
        }
        context = super(Dashboard, self).get_context()
        context.update(new_context)
        return context
项目:Scrum    作者:prakharchoudhary    | 项目源码 | 文件源码
def make_template_fragment_key(fragment_name, vary_on=None):
    if vary_on is None:
        vary_on = ()
    key = ':'.join(urlquote(var) for var in vary_on)
    args = hashlib.md5(force_bytes(key))
    return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())
项目:dream_blog    作者:fanlion    | 项目源码 | 文件源码
def get_context(self):
        new_context = {
            'title': self.get_title(),
            'icon': self.icon,
            'portal_key': self.get_portal_key(),
            'columns': [('col-sm-%d' % int(12 / len(self.widgets)), ws) for ws in self.widgets],
            'has_add_widget_permission': self.has_model_perm(UserWidget, 'add') and self.widget_customiz,
            'add_widget_url': self.get_admin_url('%s_%s_add' % (UserWidget._meta.app_label, UserWidget._meta.model_name)) +
            "?user=%s&page_id=%s&_redirect=%s" % (self.user.id, self.get_page_id(), urlquote(self.request.get_full_path()))
        }
        context = super(Dashboard, self).get_context()
        context.update(new_context)
        return context
项目:MxOnline    作者:myTeemo    | 项目源码 | 文件源码
def get_context(self):
        new_context = {
            'title': self.get_title(),
            'icon': self.icon,
            'portal_key': self.get_portal_key(),
            'columns': [('col-sm-%d' % int(12 / len(self.widgets)), ws) for ws in self.widgets],
            'has_add_widget_permission': self.has_model_perm(UserWidget, 'add') and self.widget_customiz,
            'add_widget_url': self.get_admin_url('%s_%s_add' % (UserWidget._meta.app_label, UserWidget._meta.model_name)) +
            "?user=%s&page_id=%s&_redirect=%s" % (self.user.id, self.get_page_id(), urlquote(self.request.get_full_path()))
        }
        context = super(Dashboard, self).get_context()
        context.update(new_context)
        return context
项目:djangoblog    作者:liuhuipy    | 项目源码 | 文件源码
def get_context(self):
        new_context = {
            'title': self.get_title(),
            'icon': self.icon,
            'portal_key': self.get_portal_key(),
            'columns': [('col-sm-%d' % int(12 / len(self.widgets)), ws) for ws in self.widgets],
            'has_add_widget_permission': self.has_model_perm(UserWidget, 'add') and self.widget_customiz,
            'add_widget_url': self.get_admin_url('%s_%s_add' % (UserWidget._meta.app_label, UserWidget._meta.model_name)) +
            "?user=%s&page_id=%s&_redirect=%s" % (self.user.id, self.get_page_id(), urlquote(self.request.get_full_path()))
        }
        context = super(Dashboard, self).get_context()
        context.update(new_context)
        return context
项目:django    作者:alexsukhrin    | 项目源码 | 文件源码
def make_template_fragment_key(fragment_name, vary_on=None):
    if vary_on is None:
        vary_on = ()
    key = ':'.join(urlquote(var) for var in vary_on)
    args = hashlib.md5(force_bytes(key))
    return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())
项目:steemprojects.com    作者:noisy    | 项目源码 | 文件源码
def make_template_fragment_key(fragment_name, vary_on=None):
    if vary_on is None:
        vary_on = ()
    key = ':'.join([urlquote(var) for var in vary_on])
    args = hashlib.md5(key.encode('utf-8'))
    return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())
项目:sdining    作者:Lurance    | 项目源码 | 文件源码
def get_context(self):
        new_context = {
            'title': self.get_title(),
            'icon': self.icon,
            'portal_key': self.get_portal_key(),
            'columns': [('col-sm-%d' % int(12 / len(self.widgets)), ws) for ws in self.widgets],
            'has_add_widget_permission': self.has_model_perm(UserWidget, 'add') and self.widget_customiz,
            'add_widget_url': self.get_admin_url('%s_%s_add' % (UserWidget._meta.app_label, UserWidget._meta.model_name)) +
            "?user=%s&page_id=%s&_redirect=%s" % (self.user.id, self.get_page_id(), urlquote(self.request.get_full_path()))
        }
        context = super(Dashboard, self).get_context()
        context.update(new_context)
        return context
项目:djangocms-association    作者:python-spain    | 项目源码 | 文件源码
def __call__(self, value):
        return mark_safe('<a href="{}" target="_blank">{}</a>'.format(
            self.url_pattern.format(urlquote(value, '/@+')),
            self.value_pattern.format(escape(value))
        ))
项目:Gypsy    作者:benticarlos    | 项目源码 | 文件源码
def make_template_fragment_key(fragment_name, vary_on=None):
    if vary_on is None:
        vary_on = ()
    key = ':'.join(urlquote(var) for var in vary_on)
    args = hashlib.md5(force_bytes(key))
    return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())
项目:DjangoBlog    作者:0daybug    | 项目源码 | 文件源码
def make_template_fragment_key(fragment_name, vary_on=None):
    if vary_on is None:
        vary_on = ()
    key = ':'.join(urlquote(var) for var in vary_on)
    args = hashlib.md5(force_bytes(key))
    return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())
项目:blog-django    作者:NeverMoreee    | 项目源码 | 文件源码
def myurlquote(value):
    return urlquote(value)
项目:xadmin-markdown-editor    作者:bluenknight    | 项目源码 | 文件源码
def get_context(self):
        new_context = {
            'title': self.get_title(),
            'icon': self.icon,
            'portal_key': self.get_portal_key(),
            'columns': [('col-sm-%d' % int(12 / len(self.widgets)), ws) for ws in self.widgets],
            'has_add_widget_permission': self.has_model_perm(UserWidget, 'add') and self.widget_customiz,
            'add_widget_url': self.get_admin_url('%s_%s_add' % (UserWidget._meta.app_label, UserWidget._meta.model_name)) +
            "?user=%s&page_id=%s&_redirect=%s" % (self.user.id, self.get_page_id(), urlquote(self.request.get_full_path()))
        }
        context = super(Dashboard, self).get_context()
        context.update(new_context)
        return context
项目:heltour    作者:cyanfish    | 项目源码 | 文件源码
def review_registration(self, request, object_id):
        reg = get_object_or_404(Registration, pk=object_id)
        if not request.user.has_perm('tournament.change_registration', reg.season.league):
            raise PermissionDenied

        if request.method == 'POST':
            changelist_filters = request.POST.get('_changelist_filters', '')
            form = forms.ReviewRegistrationForm(request.POST)
            if form.is_valid():
                params = '?_changelist_filters=' + urlquote(changelist_filters)
                if 'approve' in form.data and reg.status == 'pending':
                    return redirect_with_params('admin:approve_registration', object_id=object_id, params=params)
                elif 'reject' in form.data and reg.status == 'pending':
                    return redirect_with_params('admin:reject_registration', object_id=object_id, params=params)
                elif 'edit' in form.data:
                    return redirect_with_params('admin:tournament_registration_change', object_id, params=params)
                else:
                    return redirect_with_params('admin:tournament_registration_changelist', params=params)
        else:
            changelist_filters = request.GET.get('_changelist_filters', '')
            form = forms.ReviewRegistrationForm()

        is_team = reg.season.league.competitor_type == 'team'

        context = {
            'has_permission': True,
            'opts': self.model._meta,
            'site_url': '/',
            'original': reg,
            'title': 'Review registration',
            'form': form,
            'is_team': is_team,
            'changelist_filters': changelist_filters
        }

        return render(request, 'tournament/admin/review_registration.html', context)
项目:heltour    作者:cyanfish    | 项目源码 | 文件源码
def review_request(self, request, object_id):
        obj = get_object_or_404(ModRequest, pk=object_id)
        if not request.user.has_perm('tournament.change_modrequest', obj.season.league):
            raise PermissionDenied

        if request.method == 'POST':
            changelist_filters = request.POST.get('_changelist_filters', '')
            form = forms.ReviewModRequestForm(request.POST)
            if form.is_valid():
                params = '?_changelist_filters=' + urlquote(changelist_filters)
                if 'approve' in form.data and obj.status == 'pending':
                    return redirect_with_params('admin:tournament_modrequest_approve', object_id=object_id, params=params)
                elif 'reject' in form.data and obj.status == 'pending':
                    return redirect_with_params('admin:tournament_modrequest_reject', object_id=object_id, params=params)
                elif 'edit' in form.data:
                    return redirect_with_params('admin:tournament_modrequest_change', object_id, params=params)
                else:
                    return redirect_with_params('admin:tournament_modrequest_changelist', params=params)
        else:
            changelist_filters = request.GET.get('_changelist_filters', '')
            form = forms.ReviewModRequestForm()

        context = {
            'has_permission': True,
            'opts': self.model._meta,
            'site_url': '/',
            'original': obj,
            'title': 'Review mod request',
            'form': form,
            'changelist_filters': changelist_filters
        }

        return render(request, 'tournament/admin/review_modrequest.html', context)
项目:heltour    作者:cyanfish    | 项目源码 | 文件源码
def approve_request(self, request, object_id):
        obj = get_object_or_404(ModRequest, pk=object_id)
        if not request.user.has_perm('tournament.change_modrequest', obj.season.league):
            raise PermissionDenied

        if obj.status != 'pending':
            return redirect('admin:tournament_modrequest_review', object_id)

        if request.method == 'POST':
            changelist_filters = request.POST.get('_changelist_filters', '')
            form = forms.ApproveModRequestForm(request.POST)
            if form.is_valid():
                if 'confirm' in form.data:
                    obj.approve(request.user.username, form.cleaned_data['response'])
                    self.message_user(request, 'Request approved.', messages.INFO)
                    return redirect_with_params('admin:tournament_modrequest_changelist', params='?' + changelist_filters)
                else:
                    return redirect_with_params('admin:tournament_modrequest_review', object_id, params='?_changelist_filters=' + urlquote(changelist_filters))
        else:
            changelist_filters = request.GET.get('_changelist_filters', '')
            form = forms.ApproveModRequestForm()

        context = {
            'has_permission': True,
            'opts': self.model._meta,
            'site_url': '/',
            'original': obj,
            'title': 'Confirm approval',
            'form': form,
            'changelist_filters': changelist_filters
        }

        return render(request, 'tournament/admin/approve_modrequest.html', context)
项目:wanblog    作者:wanzifa    | 项目源码 | 文件源码
def make_template_fragment_key(fragment_name, vary_on=None):
    if vary_on is None:
        vary_on = ()
    key = ':'.join(urlquote(var) for var in vary_on)
    args = hashlib.md5(force_bytes(key))
    return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())
项目:tabmaster    作者:NicolasMinghetti    | 项目源码 | 文件源码
def make_template_fragment_key(fragment_name, vary_on=None):
    if vary_on is None:
        vary_on = ()
    key = ':'.join(urlquote(var) for var in vary_on)
    args = hashlib.md5(force_bytes(key))
    return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())
项目:trydjango18    作者:lucifer-yqh    | 项目源码 | 文件源码
def make_template_fragment_key(fragment_name, vary_on=None):
    if vary_on is None:
        vary_on = ()
    key = ':'.join(urlquote(var) for var in vary_on)
    args = hashlib.md5(force_bytes(key))
    return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())
项目:django-twilio-tfa    作者:rtindru    | 项目源码 | 文件源码
def get_login_url(self, request, **kwargs):
        method = kwargs.pop('method', self.get_method())
        if method == 'js_sdk':
            next = "'%s'" % escapejs(kwargs.get('next') or '')
            process = "'%s'" % escapejs(
                kwargs.get('process') or AuthProcess.LOGIN)
            action = "'%s'" % escapejs(
                kwargs.get('action') or AuthAction.AUTHENTICATE)
            js = "allauth.facebook.login(%s, %s, %s)" % (next, action, process)
            ret = "javascript:%s" % (urlquote(js),)
        else:
            assert method == 'oauth2'
            ret = super(FacebookProvider, self).get_login_url(request,
                                                              **kwargs)
        return ret
项目:trydjango18    作者:wei0104    | 项目源码 | 文件源码
def make_template_fragment_key(fragment_name, vary_on=None):
    if vary_on is None:
        vary_on = ()
    key = ':'.join(urlquote(var) for var in vary_on)
    args = hashlib.md5(force_bytes(key))
    return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())
项目:YouPBX    作者:JoneXiong    | 项目源码 | 文件源码
def get_context(self):
        new_context = {
            'title': self.get_title(),
            'icon': self.icon,
            'portal_key': self.get_portal_key(),
            'columns': [('col-sm-%d' % int(12 / len(self.widgets)), ws) for ws in self.widgets],
            'has_add_widget_permission': self.has_model_perm(UserWidget, 'add') and self.widget_customiz,
            'add_widget_url': self.get_admin_url('%s_%s_add' % (UserWidget._meta.app_label, UserWidget._meta.module_name)) +
            "?user=%s&page_id=%s&_redirect=%s" % (self.user.id, self.get_page_id(), urlquote(self.request.get_full_path()))
        }
        context = super(Dashboard, self).get_context()
        context.update(new_context)
        return context
项目:YouPBX    作者:JoneXiong    | 项目源码 | 文件源码
def get_context(self):
        context = super(Dashboard, self).get_context()
        self.set_widgets(context)
        self.widgets = self.get_widgets()
        new_context = {
            'title': self.get_title(),
            'icon': self.icon,
            'portal_key': self.get_portal_key(),
            'columns': [('col-sm-%d' % int(12 / len(self.widgets)), ws) for ws in self.widgets],
            'has_add_widget_permission': self.has_model_perm(UserWidget, 'add') and self.widget_customiz,
            'add_widget_url': self.get_admin_url('%s_%s_add' % (UserWidget._meta.app_label, UserWidget._meta.module_name)) +
            "?user=%s&page_id=%s&_redirect=%s" % (self.user.id, self.get_page_id(), urlquote(self.request.get_full_path()))
        }
        context.update(new_context)
        return context
项目:ims    作者:ims-team    | 项目源码 | 文件源码
def make_template_fragment_key(fragment_name, vary_on=None):
    if vary_on is None:
        vary_on = ()
    key = ':'.join(urlquote(var) for var in vary_on)
    args = hashlib.md5(force_bytes(key))
    return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())
项目:lifesoundtrack    作者:MTG    | 项目源码 | 文件源码
def make_template_fragment_key(fragment_name, vary_on=None):
    if vary_on is None:
        vary_on = ()
    key = ':'.join(urlquote(var) for var in vary_on)
    args = hashlib.md5(force_bytes(key))
    return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())
项目:lifesoundtrack    作者:MTG    | 项目源码 | 文件源码
def urlencode(value, safe=None):
    """
    Escapes a value for use in a URL.

    Takes an optional ``safe`` parameter used to determine the characters which
    should not be escaped by Django's ``urlquote`` method. If not provided, the
    default safe characters will be used (but an empty string can be provided
    when *all* characters should be escaped).
    """
    kwargs = {}
    if safe is not None:
        kwargs['safe'] = safe
    return urlquote(value, **kwargs)
项目:django-open-lecture    作者:DmLitov4    | 项目源码 | 文件源码
def make_template_fragment_key(fragment_name, vary_on=None):
    if vary_on is None:
        vary_on = ()
    key = ':'.join(urlquote(var) for var in vary_on)
    args = hashlib.md5(force_bytes(key))
    return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())
项目:eduDjango    作者:yuzhou6    | 项目源码 | 文件源码
def get_context(self):
        new_context = {
            'title': self.get_title(),
            'icon': self.icon,
            'portal_key': self.get_portal_key(),
            'columns': [('col-sm-%d' % int(12 / len(self.widgets)), ws) for ws in self.widgets],
            'has_add_widget_permission': self.has_model_perm(UserWidget, 'add') and self.widget_customiz,
            'add_widget_url': self.get_admin_url('%s_%s_add' % (UserWidget._meta.app_label, UserWidget._meta.model_name)) +
            "?user=%s&page_id=%s&_redirect=%s" % (self.user.id, self.get_page_id(), urlquote(self.request.get_full_path()))
        }
        context = super(Dashboard, self).get_context()
        context.update(new_context)
        return context
项目:travlr    作者:gauravkulkarni96    | 项目源码 | 文件源码
def make_template_fragment_key(fragment_name, vary_on=None):
    if vary_on is None:
        vary_on = ()
    key = ':'.join(urlquote(var) for var in vary_on)
    args = hashlib.md5(force_bytes(key))
    return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, args.hexdigest())
项目:Django-IMOOC-Shop    作者:LBruse    | 项目源码 | 文件源码
def get_context(self):
        new_context = {
            'title': self.get_title(),
            'icon': self.icon,
            'portal_key': self.get_portal_key(),
            'columns': [('col-sm-%d' % int(12 / len(self.widgets)), ws) for ws in self.widgets],
            'has_add_widget_permission': self.has_model_perm(UserWidget, 'add') and self.widget_customiz,
            'add_widget_url': self.get_admin_url('%s_%s_add' % (UserWidget._meta.app_label, UserWidget._meta.model_name)) +
            "?user=%s&page_id=%s&_redirect=%s" % (self.user.id, self.get_page_id(), urlquote(self.request.get_full_path()))
        }
        context = super(Dashboard, self).get_context()
        context.update(new_context)
        return context