本文整理匯總了Python中xadmin.plugins.actions.ACTION_CHECKBOX_NAME屬性的典型用法代碼示例。如果您正苦於以下問題:Python actions.ACTION_CHECKBOX_NAME屬性的具體用法?Python actions.ACTION_CHECKBOX_NAME怎麽用?Python actions.ACTION_CHECKBOX_NAME使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類xadmin.plugins.actions
的用法示例。
在下文中一共展示了actions.ACTION_CHECKBOX_NAME屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: do_action
# 需要導入模塊: from xadmin.plugins import actions [as 別名]
# 或者: from xadmin.plugins.actions import ACTION_CHECKBOX_NAME [as 別名]
def do_action(self, queryset):
if not self.has_change_permission():
raise PermissionDenied
change_fields = [f for f in self.request.POST.getlist(BATCH_CHECKBOX_NAME) if f in self.batch_fields]
if change_fields and self.request.POST.get('post'):
self.form_obj = self.get_change_form(True, change_fields)(
data=self.request.POST, files=self.request.FILES)
if self.form_obj.is_valid():
self.change_models(queryset, self.form_obj.cleaned_data)
return None
else:
self.form_obj = self.get_change_form(False, self.batch_fields)()
helper = FormHelper()
helper.form_tag = False
helper.add_layout(Layout(Container(Col('full',
Fieldset("", *self.form_obj.fields.keys(), css_class="unsort no_title"), horizontal=True, span=12)
)))
self.form_obj.helper = helper
count = len(queryset)
if count == 1:
objects_name = force_str(self.opts.verbose_name)
else:
objects_name = force_str(self.opts.verbose_name_plural)
context = self.get_context()
context.update({
"title": _("Batch change %s") % objects_name,
'objects_name': objects_name,
'form': self.form_obj,
'queryset': queryset,
'count': count,
"opts": self.opts,
"app_label": self.app_label,
'action_checkbox_name': ACTION_CHECKBOX_NAME,
})
return TemplateResponse(self.request, self.batch_change_form_template or
self.get_template_list('views/batch_change_form.html'), context, current_app=self.admin_site.name)
示例2: do_action
# 需要導入模塊: from xadmin.plugins import actions [as 別名]
# 或者: from xadmin.plugins.actions import ACTION_CHECKBOX_NAME [as 別名]
def do_action(self, queryset):
if not self.has_change_permission():
raise PermissionDenied
change_fields = [f for f in self.request.POST.getlist(BATCH_CHECKBOX_NAME) if f in self.batch_fields]
if change_fields and self.request.POST.get('post'):
self.form_obj = self.get_change_form(True, change_fields)(
data=self.request.POST, files=self.request.FILES)
if self.form_obj.is_valid():
self.change_models(queryset, self.form_obj.cleaned_data)
return None
else:
self.form_obj = self.get_change_form(False, self.batch_fields)()
helper = FormHelper()
helper.form_tag = False
helper.include_media = False
helper.add_layout(Layout(Container(Col('full',
Fieldset("", *self.form_obj.fields.keys(), css_class="unsort no_title"), horizontal=True, span=12)
)))
self.form_obj.helper = helper
count = len(queryset)
if count == 1:
objects_name = force_text(self.opts.verbose_name)
else:
objects_name = force_text(self.opts.verbose_name_plural)
context = self.get_context()
context.update({
"title": _("Batch change %s") % objects_name,
'objects_name': objects_name,
'form': self.form_obj,
'queryset': queryset,
'count': count,
"opts": self.opts,
"app_label": self.app_label,
'action_checkbox_name': ACTION_CHECKBOX_NAME,
})
return TemplateResponse(self.request, self.batch_change_form_template or
self.get_template_list('views/batch_change_form.html'), context)
示例3: do_action
# 需要導入模塊: from xadmin.plugins import actions [as 別名]
# 或者: from xadmin.plugins.actions import ACTION_CHECKBOX_NAME [as 別名]
def do_action(self, queryset):
if not self.has_change_permission():
raise PermissionDenied
change_fields = [f for f in self.request.POST.getlist(BATCH_CHECKBOX_NAME) if f in self.batch_fields]
if change_fields and self.request.POST.get('post'):
self.form_obj = self.get_change_form(True, change_fields)(
data=self.request.POST, files=self.request.FILES)
if self.form_obj.is_valid():
self.change_models(queryset, self.form_obj.cleaned_data)
return None
else:
self.form_obj = self.get_change_form(False, self.batch_fields)()
helper = FormHelper()
helper.form_tag = False
helper.include_media = False
helper.add_layout(Layout(Container(Col('full',
Fieldset("", *self.form_obj.fields.keys(), css_class="unsort no_title"), horizontal=True, span=12)
)))
self.form_obj.helper = helper
count = len(queryset)
if count == 1:
objects_name = force_unicode(self.opts.verbose_name)
else:
objects_name = force_unicode(self.opts.verbose_name_plural)
context = self.get_context()
context.update({
"title": _("Batch change %s") % objects_name,
'objects_name': objects_name,
'form': self.form_obj,
'queryset': queryset,
'count': count,
"opts": self.opts,
"app_label": self.app_label,
'action_checkbox_name': ACTION_CHECKBOX_NAME,
})
return TemplateResponse(self.request, self.batch_change_form_template or
self.get_template_list('views/batch_change_form.html'), context)