Re: Writing class-based contrib.admin actions

2013-01-29 Thread Luke Plant
On 29/01/13 12:53, Timmy O'Mahony wrote:
> At the moment, writing custom admin actions
> 
> requires an old style view function that returns a Response object. The
> signature for this is similar to a old function-based view (except with
> modeladmin before request): 
> 
> func(modeladmin, request, queryset):
> ...
> return HttpResponse()
> 
> I wanted to write an action with an intermediate page
> ,
> but using class based views (for uniformity across my app). This doesn't
> seem to be doable without writing a custom base View object

Changing the signature would be backwards incompatible (or very hacky).

You can always do:

  def my_admin_action(modeladmin, request, queryset):
  return MyView.as_view(request, modeladmin, queryset)

And then take it to the next step:

  my_admin_action = cbv_to_admin_action(MyView)


Luke


-- 
"I am going to let you move around more, just to break up the
mahogany." (True Quotes From Induhviduals, Scott Adams)

Luke Plant || http://lukeplant.me.uk/

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Writing class-based contrib.admin actions

2013-01-29 Thread Timmy O'Mahony
Thinking about this more, this might be better suited to a third party 
module that helps write admin actions - similar to django-crispy-forms etc. 

On Tuesday, 29 January 2013 13:53:19 UTC+1, Timmy O'Mahony wrote:
>
> At the moment, writing custom admin 
> actionsrequires
>  an old style view function that returns a Response object. The 
> signature for this is similar to a old function-based view (except with 
> modeladmin before request): 
>
> func(modeladmin, request, queryset):
> ...
> return HttpResponse()
>
> I wanted to write an action with an intermediate 
> page,
>  
> but using class based views (for uniformity across my app). This doesn't 
> seem to be doable without writing a custom base View object 
> that
>  interprets the 
> view args in a different order. By switching the function signature for 
> actions and putting the request first, wouldn't this it very easy to plugin 
> class based views when writing actions. 
>
> Does this make sense and is it worth a feature request (or a bit more 
> research)? 
>
> Timmy
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Writing class-based contrib.admin actions

2013-01-29 Thread Timmy O'Mahony
At the moment, writing custom admin 
actionsrequires
 an old style view function that returns a Response object. The 
signature for this is similar to a old function-based view (except with 
modeladmin before request): 

func(modeladmin, request, queryset):
...
return HttpResponse()

I wanted to write an action with an intermediate 
page,
 
but using class based views (for uniformity across my app). This doesn't 
seem to be doable without writing a custom base View object 
that
 interprets the 
view args in a different order. By switching the function signature for 
actions and putting the request first, wouldn't this it very easy to plugin 
class based views when writing actions. 

Does this make sense and is it worth a feature request (or a bit more 
research)? 

Timmy

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.