def positions_by_category_view(self, request, category_id, extra_context=None):

        model = self.model
        self.user = request.user

        try:
            category = Category.objects.get(id=category_id)
        except Category.DoesNotExist:
            # FIXME: redirect
            return HttpResponseRedirect(reverse('newman:index'))

        names = ['featured_secondary_1', 'featured_secondary_2', 'featured_secondary_3', 'poll', 'tipoftheday',
                 'special', 'recipeoftheday', 'featured_small_1', 'featured_small_2',
                 'featured_small_3', ]

        positions = model.objects.filter(category=category_id, name__in=names)

        count = positions.count()

        PositionForm = self.get_form(request)

        if request.method == 'POST':
            forms = [PositionForm(request.POST, prefix=str(positions[x].id),
                                  instance=positions[x]) for x in range(count)]
            if all([form.is_valid() for form in forms]):
                for form in forms:
                    new_object = self.save_form(request, form, change=True)
                    self.save_model(request, new_object, form, change=True)
                    change_message = self.construct_change_message(request, form, None)
                    self.log_change(request, new_object, change_message)

                msg = unicode(_('Positions were changed successfully.'))

                return JsonResponse(msg, data={'category_id': category_id})
        else:
            forms = [PositionForm(prefix=str(positions[x].id),
                                  instance=positions[x]) for x in range(count)]

        adminForms = [helpers.AdminForm(forms[x], self.get_fieldsets(request, positions[x]),
                                self.prepopulated_fields) for x in range(count)]

        errors = []
        for form in forms:
            errors.extend(helpers.AdminErrorList(form, []))

        media = self.media
        if len(adminForms) > 0:
            media += adminForms[0].media

        raw_media = self.prepare_media(media)

        context = {
            'multiple_edit': True,
            'add': False,
            'title': _('Positions in %s') % category.title,
            'category': category,
            'adminforms': adminForms,
            'errors': errors,
            'media': raw_media,
            'is_popup': request.REQUEST.has_key('_popup'),
        }
        context.update(extra_context or {})

        # render change form
        opts = self.model._meta
        app_label = opts.app_label
        ordered_objects = opts.get_ordered_objects()

        context.update({
            'app_label': app_label,
            'change': True,
            'has_add_permission': False,
            'has_change_permission': True,
            'has_delete_permission': False,
            'has_file_field': False,
            'has_absolute_url': hasattr(self.model, 'get_absolute_url'),
            'ordered_objects': ordered_objects,
            'opts': opts,
            'content_type_id': ContentType.objects.get_for_model(self.model).id,
            'save_as': self.save_as,
            'save_on_top': self.save_on_top,
            'save_url': reverse('newman:positions-by-category', args=[category_id]),
        })
        return render_to_response("newman/%s/multi_change_form.html" % app_label,
                            context, context_instance=template.RequestContext(request))
dataset/ETHPy150Open ella/ella/ella/positions/newman_admin.py/PositionAdmin.positions_by_category_view/original