Example #1
0
 def get_action_choices(self, request, default_choices=BLANK_CHOICE_DASH):
     # Изменение placeholder у выпадающего списка
     choices = [("", _("Action"))]
     for func, name, description in self.get_actions(request).values():
         choice = (name, description % model_format_dict(self.opts))
         choices.append(choice)
     return choices
def admin_get_actions(admin, request):
    request.data_browser = {"calculated_fields": set(), "fields": set()}
    res = {}
    for func, name, desc in admin.get_actions(request).values():
        if not getattr(func, "ddb_hide", False):
            desc %= model_format_dict(admin.opts)
            res[name] = func, desc
    return res
Example #3
0
def admin_get_actions(admin, request):
    assert hasattr(request, "data_browser"), request

    res = {}
    for func, name, desc in admin.get_actions(request).values():
        if not getattr(func, "ddb_hide", False):
            desc %= model_format_dict(admin.opts)
            res[name] = func, desc
    return res
Example #4
0
    def get_action_choices(self, request, default_choices=BLANK_CHOICE_DASH):
        # Change the string formatting operation to the ``str.format()`` method.
        choices = [] + default_choices
        model_verbose_names = model_format_dict(self.opts)
        for func, name, description in six.itervalues(
                self.get_actions(request)):
            choice = (name, description.format(**model_verbose_names))
            choices.append(choice)

        return choices
Example #5
0
 def get_action_choices(self, request, default_choices=BLANK_CHOICE_DASH):
     """
     Return a list of choices for use in a form object.  Each choice is a tuple (name, description).
     """
     actions_exclude = self.actions_exclude if hasattr(self, 'actions_exclude') else []
     choices = [] + default_choices
     for func, name, description in six.itervalues(self.get_actions(request)):
         if name in actions_exclude:
             continue
         choice = (name, description % model_format_dict(self.opts))
         choices.append(choice)
     return choices
Example #6
0
    def report_change(self, request, queryset, affected_rows, log_message,
                      user_message, user_message_plural):
        kwargs = model_format_dict(self.opts)
        for obj in queryset:
            self.log_change(request, obj,
                            log_message.format(record=obj, **kwargs))

        if affected_rows == 1:
            kwargs['record'] = queryset.get()
            self.message_user(request, user_message.format(**kwargs))
        else:
            kwargs['record_count'] = affected_rows
            self.message_user(request, user_message_plural.format(**kwargs))