本文整理匯總了Python中xadmin.util.unquote方法的典型用法代碼示例。如果您正苦於以下問題:Python util.unquote方法的具體用法?Python util.unquote怎麽用?Python util.unquote使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xadmin.util
的用法示例。
在下文中一共展示了util.unquote方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: init_request
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import unquote [as 別名]
def init_request(self, object_id, *args, **kwargs):
"The 'delete' admin view for this model."
self.obj = self.get_object(unquote(object_id))
if not self.has_delete_permission(self.obj):
raise PermissionDenied
if self.obj is None:
raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_text(self.opts.verbose_name), 'key': escape(object_id)})
using = router.db_for_write(self.model)
# Populate deleted_objects, a data structure of all related objects that
# will also be deleted.
(self.deleted_objects, model_count, self.perms_needed, self.protected) = get_deleted_objects(
[self.obj], self.opts, self.request.user, self.admin_site, using)
示例2: init_request
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import unquote [as 別名]
def init_request(self, object_id, *args, **kwargs):
"The 'delete' admin view for this model."
self.obj = self.get_object(unquote(object_id))
if not self.has_delete_permission(self.obj):
raise PermissionDenied
if self.obj is None:
raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_text(self.opts.verbose_name), 'key': escape(object_id)})
using = router.db_for_write(self.model)
# Populate deleted_objects, a data structure of all related objects that
# will also be deleted.
if django_version > (2, 1):
(self.deleted_objects, model_count, self.perms_needed, self.protected) = get_deleted_objects(
[self.obj], self.opts, self.admin_site)
else:
(self.deleted_objects, model_count, self.perms_needed, self.protected) = get_deleted_objects(
[self.obj], self.opts, self.request.user, self.admin_site, using)
示例3: init_request
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import unquote [as 別名]
def init_request(self, object_id, *args, **kwargs):
"The 'delete' admin view for this model."
self.obj = self.get_object(unquote(object_id))
if not self.has_delete_permission(self.obj):
raise PermissionDenied
if self.obj is None:
raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_str(self.opts.verbose_name), 'key': escape(object_id)})
using = router.db_for_write(self.model)
# Populate deleted_objects, a data structure of all related objects that
# will also be deleted.
(self.deleted_objects, self.model_count, self.perms_needed, self.protected) = get_deleted_objects(
[self.obj], self.opts, self.request.user, self.admin_site, using)
示例4: init_request
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import unquote [as 別名]
def init_request(self, object_id, *args, **kwargs):
"The 'delete' admin view for this model."
self.obj = self.get_object(unquote(object_id))
if not self.has_delete_permission(self.obj):
raise PermissionDenied
if self.obj is None:
raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_unicode(self.opts.verbose_name), 'key': escape(object_id)})
using = router.db_for_write(self.model)
# Populate deleted_objects, a data structure of all related objects that
# will also be deleted.
(self.deleted_objects, model_count, self.perms_needed, self.protected) = get_deleted_objects(
[self.obj], self.opts, self.request.user, self.admin_site, using)
示例5: init_request
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import unquote [as 別名]
def init_request(self, object_id, *args, **kwargs):
self.obj = self.get_object(unquote(object_id))
if not self.has_view_permission(self.obj):
raise PermissionDenied
if self.obj is None:
raise Http404(_('%(name)s object with primary key %(key)r does not exist.') %
{'name': force_text(self.opts.verbose_name), 'key': escape(object_id)})
示例6: init_request
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import unquote [as 別名]
def init_request(self, object_id, *args, **kwargs):
self.obj = self.get_object(unquote(object_id))
if not self.has_view_permission(self.obj):
raise PermissionDenied
if self.obj is None:
raise Http404(
_('%(name)s object with primary key %(key)r does not exist.') %
{'name': force_text(self.opts.verbose_name), 'key': escape(object_id)})
self.org_obj = self.obj
示例7: init_request
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import unquote [as 別名]
def init_request(self, object_id, *args, **kwargs):
self.org_obj = self.get_object(unquote(object_id))
if not self.has_change_permission(self.org_obj):
raise PermissionDenied
if self.org_obj is None:
raise Http404(_('%(name)s object with primary key %(key)r does not exist.') %
{'name': force_text(self.opts.verbose_name), 'key': escape(object_id)})
# comm method for both get and post
self.prepare_form()
示例8: get
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import unquote [as 別名]
def get(self, request, object_id, *args, **kwargs):
object_id = unquote(object_id)
self.obj = self.get_object(object_id)
if not self.has_change_permission(self.obj):
raise PermissionDenied
return self.get_response()
示例9: post
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import unquote [as 別名]
def post(self, request, object_id):
if not self.has_change_permission(request):
raise PermissionDenied
self.obj = self.get_object(unquote(object_id))
self.form = self.change_password_form(self.obj, request.POST)
if self.form.is_valid():
self.form.save()
self.message_user(_('Password changed successfully.'), 'success')
return HttpResponseRedirect(self.model_admin_url('change', self.obj.pk))
else:
return self.get_response()
示例10: init_request
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import unquote [as 別名]
def init_request(self, object_id, *args, **kwargs):
self.org_obj = self.get_object(unquote(object_id))
# For list view get new field display html
self.pk_attname = self.opts.pk.attname
if not self.has_change_permission(self.org_obj):
raise PermissionDenied
if self.org_obj is None:
raise Http404(_('%(name)s object with primary key %(key)r does not exist.') %
{'name': force_text(self.opts.verbose_name), 'key': escape(object_id)})