Ticket #10595: patch_django_10595.20090324-2.diff
File patch_django_10595.20090324-2.diff, 5.4 KB (added by , 16 years ago) |
---|
-
django/contrib/admin/options.py
207 207 for inline_class in self.inlines: 208 208 inline_instance = inline_class(self.model, self.admin_site) 209 209 self.inline_instances.append(inline_instance) 210 if 'action_checkbox' not in self.list_display :210 if 'action_checkbox' not in self.list_display and self.actions is not None: 211 211 self.list_display = ['action_checkbox'] + list(self.list_display) 212 212 if not self.list_display_links: 213 213 for name in self.list_display: … … 421 421 """ 422 422 actions = {} 423 423 for klass in [self.admin_site] + self.__class__.mro()[::-1]: 424 for action in getattr(klass, 'actions', []): 424 class_actions = getattr(klass, 'actions', []) 425 if not class_actions: 426 continue # avoid iteration over None value 427 for action in class_actions: 425 428 func, name, description = self.get_action(action) 426 429 actions[name] = (func, name, description) 427 430 return actions … … 948 951 media = self.media 949 952 950 953 # Build the action form and populate it with available actions. 951 action_form = self.action_form(auto_id=None) 952 action_form.fields['action'].choices = self.get_action_choices(request) 954 if self.actions is None: 955 action_form = False 956 actions_on_top = False 957 actions_on_bottom = False 958 else: 959 action_form = self.action_form(auto_id=None) 960 action_form.fields['action'].choices = self.get_action_choices(request) 961 actions_on_top = self.actions_on_top 962 actions_on_bottom = self.actions_on_bottom 953 963 954 964 context = { 955 965 'title': cl.title, … … 960 970 'root_path': self.admin_site.root_path, 961 971 'app_label': app_label, 962 972 'action_form': action_form, 963 'actions_on_top': self.actions_on_top,964 'actions_on_bottom': self.actions_on_bottom,973 'actions_on_top': actions_on_top, 974 'actions_on_bottom': actions_on_bottom, 965 975 } 966 976 context.update(extra_context or {}) 967 977 return render_to_response(self.change_list_template or [ -
django/contrib/admin/templates/admin/change_list.html
9 9 <script type="text/javascript" src="../../jsi18n/"></script> 10 10 {% endif %} 11 11 {{ media }} 12 {% if not actions_on_top and not actions_on_bottom %} 13 <style> 14 #changelist table thead th:first-child {width: inherit} 15 </style> 16 {% endif %} 12 17 {% endblock %} 13 18 14 19 {% block bodyclass %}change-list{% endblock %} -
tests/regressiontests/admin_views/tests.py
939 939 } 940 940 response = self.client.post('/test_admin/admin/admin_views/externalsubscriber/', action_data) 941 941 self.failUnlessEqual(response.status_code, 302) 942 943 def test_model_without_action(self): 944 "Tests a ModelAdmin without any action" 945 response = self.client.get('/test_admin/admin/admin_views/oldsubscriber/') 946 self.assertEquals(response.context["action_form"], False) 947 self.assertEquals(response.context["actions_on_top"], False) 948 self.assertEquals(response.context["actions_on_bottom"], False) -
tests/regressiontests/admin_views/models.py
221 221 class ExternalSubscriber(Subscriber): 222 222 pass 223 223 224 class OldSubscriber(Subscriber): 225 pass 226 224 227 def external_mail(request, selected): 225 228 EmailMessage( 226 229 'Greetings from a function action', … … 236 239 class ExternalSubscriberAdmin(admin.ModelAdmin): 237 240 actions = [external_mail, redirect_to] 238 241 242 class OldSubscriberAdmin(admin.ModelAdmin): 243 actions = None 244 239 245 admin.site.register(Article, ArticleAdmin) 240 246 admin.site.register(CustomArticle, CustomArticleAdmin) 241 247 admin.site.register(Section, inlines=[ArticleInline]) … … 246 252 admin.site.register(Persona, PersonaAdmin) 247 253 admin.site.register(Subscriber, SubscriberAdmin) 248 254 admin.site.register(ExternalSubscriber, ExternalSubscriberAdmin) 255 admin.site.register(OldSubscriber, OldSubscriberAdmin) 249 256 250 257 # We intentionally register Promo and ChapterXtra1 but not Chapter nor ChapterXtra2. 251 258 # That way we cover all four cases: -
docs/ref/contrib/admin/actions.txt
237 237 238 238 admin.site.add_action(export_selected_objects) 239 239 240 Removing actions 241 ---------------- 242 243 If you set ``None`` in ``actions``, this tells the :class:`ModelAdmin` to do 244 not display any dropdown menu nor checkboxes related to admin actions. 245