#NEWLINE# def get_actions_urls( model , url_name = None , **kwargs ) : #NEWLINE# #INDENT# '\n    Get automatically the actions urls for a model.\n\n    ' #NEWLINE# from ionyweb.administration.actions.views import ActionAdminListView , ActionAdminDetailView , ActionAdminOrderView #NEWLINE# app_label = model . _meta . app_label #NEWLINE# if ( url_name is None ) : #NEWLINE# #INDENT# module_name = model . _meta . module_name #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# module_name = url_name #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# DetailView = kwargs . pop ( 'detail_view_class' ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# DetailView = ActionAdminDetailView #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# ListView = kwargs . pop ( 'list_view_class' ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# ListView = ActionAdminListView #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# prefix_url = kwargs . pop ( 'prefix_url' ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# prefix_url = '' #NEWLINE# #UNINDENT# def filter_kwargs( exclude_args , kwargs ) : #NEWLINE# #INDENT# new_kwargs = kwargs . copy ( ) #NEWLINE# for arg in exclude_args : #NEWLINE# #INDENT# if ( arg in new_kwargs ) : #NEWLINE# #INDENT# del new_kwargs [ arg ] #NEWLINE# #UNINDENT# #UNINDENT# return new_kwargs #NEWLINE# #UNINDENT# list_kwargs = filter_kwargs ( [ 'form_class' ] , kwargs ) #NEWLINE# detail_kwargs = filter_kwargs ( [ 'ordering' , 'sortable' , 'sortable_field' , 'list_display' ] , kwargs ) #NEWLINE# urlpatterns = patterns ( '' , url ( ( '^%s%s_list/$' % ( prefix_url , module_name ) ) , ListView . as_view ( model = model , ** list_kwargs ) , name = ( 'wa-%s-%s_list-action' % ( app_label , module_name ) ) ) , url ( ( '^%s%s/(?P<object_pk>[0-9]*)/$' % ( prefix_url , module_name ) ) , DetailView . as_view ( model = model , ** detail_kwargs ) , name = ( 'wa-%s-%s-action' % ( app_label , module_name ) ) ) , url ( ( '^%s%s/$' % ( prefix_url , module_name ) ) , DetailView . as_view ( model = model , ** detail_kwargs ) , name = ( 'wa-%s-%s-creation-action' % ( app_label , module_name ) ) ) ) #NEWLINE# if kwargs . get ( 'sortable' , False ) : #NEWLINE# #INDENT# urlpatterns += patterns ( '' , url ( ( '^%s%s_order/$' % ( prefix_url , module_name ) ) , ActionAdminOrderView . as_view ( model = model ) , name = ( 'wa-%s-%s_order-action' % ( app_label , module_name ) ) ) ) #NEWLINE# #UNINDENT# return urlpatterns