python类quote()的实例源码

utils.py 文件源码 项目:confer-backend 作者: coala 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def get_geo(address):
    result = (None, None)
    if address.replace(',', '').strip():

        address = quote(address.lower().encode("utf-8"))
        sensor = "false"
        url = '{url}?address={address}&sensor={sensor}'.format(url=settings.GOOGLE_GEOCODE_ENDPOINT,
                                                               address=address,
                                                               sensor=sensor)

        response = requests.get(url)
        response.raise_for_status()
        result = response.json()
        if result['status'] == 'OK':
            lat = str(result['results'][0]['geometry']['location']['lat'])
            lng = str(result['results'][0]['geometry']['location']['lng'])
            result = (lat, lng)

        else:
            result = (None, None)

    return result
pageadmin.py 文件源码 项目:DjangoCMS 作者: farhan711 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def revision_view(self, request, object_id, version_id, extra_context=None):
        if not is_installed('reversion'):
            return HttpResponseBadRequest('django reversion not installed')

        if not self.has_change_permission(request, Page.objects.get(pk=object_id)):
            raise PermissionDenied

        page = get_object_or_404(self.model, pk=object_id)
        if not page.publisher_is_draft:
            page = page.publisher_draft
        if not page.has_change_permission(request):
            return HttpResponseForbidden(force_text(_("You do not have permission to change this page")))
        try:
            version = Version.objects.get(pk=version_id)
            clean = page._apply_revision(version.revision, set_dirty=True)
            if not clean:
                messages.error(request, _("Page reverted but slug stays the same because of url collisions."))
            with create_revision():
                adapter = self.revision_manager.get_adapter(page.__class__)
                self.revision_context_manager.add_to_context(self.revision_manager, page, adapter.get_version_data(page))
                self.revision_context_manager.set_comment(_("Reverted to previous version, saved on %(datetime)s") % {"datetime": localize(version.revision.date_created)})
        except IndexError as e:
            return HttpResponseBadRequest(e.message)

        return HttpResponseRedirect(admin_reverse('cms_page_change', args=(quote(object_id),)))
wagtail_hooks.py 文件源码 项目:longclaw 作者: JamesRamm 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_buttons_for_obj(self, obj, exclude=None, classnames_add=None,
                            classnames_exclude=None):
        if exclude is None:
            exclude = []
        if classnames_add is None:
            classnames_add = []
        if classnames_exclude is None:
            classnames_exclude = []

        ph = self.permission_helper
        usr = self.request.user
        pk = quote(getattr(obj, self.opts.pk.attname))
        btns = []
        if ph.user_can_inspect_obj(usr, obj):
            btns.append(self.detail_button(
                pk, classnames_add, classnames_exclude))
            btns.append(self.cancel_button(
                pk, classnames_add, classnames_exclude))

        return btns
models.py 文件源码 项目:django-actions-logger 作者: shtalinberg 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def get_admin_url(self):
        """
        Returns the admin URL to edit the object represented by this log entry.
        """
        if self.content_type and self.object_id:
            url_name = 'admin:%s_%s_change' % (self.content_type.app_label, self.content_type.model)
            try:
                return reverse(url_name, args=(quote(self.object_id),))
            except NoReverseMatch:
                pass
        return None
models.py 文件源码 项目:CodingDojo 作者: ComputerSocietyUNB 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def get_admin_url(self):
        """
        Returns the admin URL to edit the object represented by this log entry.
        """
        if self.content_type and self.object_id:
            url_name = 'admin:%s_%s_change' % (self.content_type.app_label, self.content_type.model)
            try:
                return reverse(url_name, args=(quote(self.object_id),))
            except NoReverseMatch:
                pass
        return None
admin_urls.py 文件源码 项目:CodingDojo 作者: ComputerSocietyUNB 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def admin_urlquote(value):
    return quote(value)
models.py 文件源码 项目:NarshaTech 作者: KimJangHyeon 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get_admin_url(self):
        """
        Returns the admin URL to edit the object represented by this log entry.
        """
        if self.content_type and self.object_id:
            url_name = 'admin:%s_%s_change' % (self.content_type.app_label, self.content_type.model)
            try:
                return reverse(url_name, args=(quote(self.object_id),))
            except NoReverseMatch:
                pass
        return None
admin_urls.py 文件源码 项目:NarshaTech 作者: KimJangHyeon 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def admin_urlquote(value):
    return quote(value)
models.py 文件源码 项目:Scrum 作者: prakharchoudhary 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_admin_url(self):
        """
        Returns the admin URL to edit the object represented by this log entry.
        """
        if self.content_type and self.object_id:
            url_name = 'admin:%s_%s_change' % (self.content_type.app_label, self.content_type.model)
            try:
                return reverse(url_name, args=(quote(self.object_id),))
            except NoReverseMatch:
                pass
        return None
admin_urls.py 文件源码 项目:Scrum 作者: prakharchoudhary 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def admin_urlquote(value):
    return quote(value)
wagtail_hooks.py 文件源码 项目:wagtail-experiments 作者: torchbox 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def report_button(self, pk, classnames_add=[], classnames_exclude=[]):
        classnames = classnames_add
        cn = self.finalise_classname(classnames, classnames_exclude)
        return {
            'url': reverse('experiments:report', args=(quote(pk), )),
            'label': _('Show report'),
            'classname': cn,
            'title': _('Report for this %s') % self.verbose_name,
        }
wagtail_hooks.py 文件源码 项目:wagtail-experiments 作者: torchbox 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_buttons_for_obj(self, obj, exclude=[], classnames_add=[],
                            classnames_exclude=[]):
        ph = self.permission_helper
        pk = quote(getattr(obj, self.opts.pk.attname))
        btns = super(ExperimentButtonHelper, self).get_buttons_for_obj(obj, exclude, classnames_add, classnames_exclude)

        if 'report' not in exclude and ph.user_can_edit_obj(self.request.user, obj):
            btns.append(
                self.report_button(pk, classnames_add, classnames_exclude)
            )
        return btns
base.py 文件源码 项目:tumanov_castleoaks 作者: Roamdev 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def url_for_result(self, result):
        pk = getattr(result, self.pk_attname)
        return reverse(
            'admin:%s_%s_change' % (result._meta.app_label, result._meta.model_name),
            args=(quote(pk),),
            current_app=self.model_admin.admin_site.name
        )
models.py 文件源码 项目:Gypsy 作者: benticarlos 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def get_admin_url(self):
        """
        Returns the admin URL to edit the object represented by this log entry.
        """
        if self.content_type and self.object_id:
            url_name = 'admin:%s_%s_change' % (self.content_type.app_label, self.content_type.model)
            try:
                return reverse(url_name, args=(quote(self.object_id),))
            except NoReverseMatch:
                pass
        return None
admin_urls.py 文件源码 项目:Gypsy 作者: benticarlos 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def admin_urlquote(value):
    return quote(value)
models.py 文件源码 项目:DjangoBlog 作者: 0daybug 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_admin_url(self):
        """
        Returns the admin URL to edit the object represented by this log entry.
        """
        if self.content_type and self.object_id:
            url_name = 'admin:%s_%s_change' % (self.content_type.app_label, self.content_type.model)
            try:
                return reverse(url_name, args=(quote(self.object_id),))
            except NoReverseMatch:
                pass
        return None
admin_urls.py 文件源码 项目:DjangoBlog 作者: 0daybug 项目源码 文件源码 阅读 78 收藏 0 点赞 0 评论 0
def admin_urlquote(value):
    return quote(value)
models.py 文件源码 项目:wanblog 作者: wanzifa 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_admin_url(self):
        """
        Returns the admin URL to edit the object represented by this log entry.
        """
        if self.content_type and self.object_id:
            url_name = 'admin:%s_%s_change' % (self.content_type.app_label, self.content_type.model)
            try:
                return reverse(url_name, args=(quote(self.object_id),))
            except NoReverseMatch:
                pass
        return None
admin_urls.py 文件源码 项目:wanblog 作者: wanzifa 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def admin_urlquote(value):
    return quote(value)
models.py 文件源码 项目:tabmaster 作者: NicolasMinghetti 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get_admin_url(self):
        """
        Returns the admin URL to edit the object represented by this log entry.
        """
        if self.content_type and self.object_id:
            url_name = 'admin:%s_%s_change' % (self.content_type.app_label, self.content_type.model)
            try:
                return reverse(url_name, args=(quote(self.object_id),))
            except NoReverseMatch:
                pass
        return None
admin_urls.py 文件源码 项目:tabmaster 作者: NicolasMinghetti 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def admin_urlquote(value):
    return quote(value)
models.py 文件源码 项目:trydjango18 作者: lucifer-yqh 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_admin_url(self):
        """
        Returns the admin URL to edit the object represented by this log entry.
        """
        if self.content_type and self.object_id:
            url_name = 'admin:%s_%s_change' % (self.content_type.app_label, self.content_type.model)
            try:
                return reverse(url_name, args=(quote(self.object_id),))
            except NoReverseMatch:
                pass
        return None
admin_urls.py 文件源码 项目:trydjango18 作者: lucifer-yqh 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def admin_urlquote(value):
    return quote(value)
models.py 文件源码 项目:trydjango18 作者: wei0104 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def get_admin_url(self):
        """
        Returns the admin URL to edit the object represented by this log entry.
        """
        if self.content_type and self.object_id:
            url_name = 'admin:%s_%s_change' % (self.content_type.app_label, self.content_type.model)
            try:
                return reverse(url_name, args=(quote(self.object_id),))
            except NoReverseMatch:
                pass
        return None
admin_urls.py 文件源码 项目:trydjango18 作者: wei0104 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def admin_urlquote(value):
    return quote(value)
models.py 文件源码 项目:ims 作者: ims-team 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def get_admin_url(self):
        """
        Returns the admin URL to edit the object represented by this log entry.
        """
        if self.content_type and self.object_id:
            url_name = 'admin:%s_%s_change' % (self.content_type.app_label, self.content_type.model)
            try:
                return reverse(url_name, args=(quote(self.object_id),))
            except NoReverseMatch:
                pass
        return None
admin_urls.py 文件源码 项目:ims 作者: ims-team 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def admin_urlquote(value):
    return quote(value)
models.py 文件源码 项目:lifesoundtrack 作者: MTG 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def get_admin_url(self):
        """
        Returns the admin URL to edit the object represented by this log entry.
        """
        if self.content_type and self.object_id:
            url_name = 'admin:%s_%s_change' % (self.content_type.app_label, self.content_type.model)
            try:
                return reverse(url_name, args=(quote(self.object_id),))
            except NoReverseMatch:
                pass
        return None
admin_urls.py 文件源码 项目:lifesoundtrack 作者: MTG 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def admin_urlquote(value):
    return quote(value)
admin.py 文件源码 项目:django-clubhouse 作者: chazmead 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def url_for_result(self, result):
        pk_attname = result._meta.pk.attname
        pk = getattr(result, pk_attname)
        return reverse('admin:%s_%s_change' % (result._meta.app_label,
                                               result._meta.model_name),
                       args=(quote(pk),),
                       current_app=self.model_admin.admin_site.name)


问题


面经


文章

微信
公众号

扫码关注公众号