On 1/20/07, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 1/20/07, Robert Myers <[EMAIL PROTECTED]> wrote:
> > However, my latest brainstorm idea is to place an admin-urls.py
> > file in each app which would work just like the generic views and allow you
> > to specify nearly everything. The defaults of course would be the standard
> > options or urls in the admin contrib, but give you hooks for everything even
> > the list of objects. For example you could override the change list to
> > display only "active" objects.
> >
> > Roughly looking like this:
> >
> > user_dict = {
> > 'query_set': User.objects.filter(active=True),
> > 'list_display':
> > ('user','first_name','last_name','email'),
> > 'list_filter':
> > ('staff_member','department','clue_level'),
> > 'search_fields': ('first_name', 'last_name', 'department__name'),
> > 'list_per_page': 1000,
> > 'login_required': True,
> > "permission_test': my_special_user_passes_test,
> > }
> > urlpatterns = patterns('django.contrib.admin',
> > ('r^(?P<model>user), model_admin_view, user_dict),
> > )
>
> The newforms-admin branch already has some of those extra hooks, so
> that should make you very happy. :-)
>
> > The only part that I'm still hung on is how to specify the URL's cleanly so
> > that both user specified and the defaults work smoothly together. But I
> > think it should not be too hard to do.
>
> This is exactly what I'm trying to solve. How does the URLconf
> interact with the "class Admin" so that not too much extra code is
> required?
why not create a function to do that for you..
urls.py is after all a python module, so you could just introduce a function
urlpatterns = admin_urls_for_model(
MyModel,
field_list=[ 'field' ],
exclude_actions=[ admin.EDIT ],
perms_required={
admin.EDIT : 'can_change_MyModel',
admin.LIST : 'something_else'
}
)
or mimic the patterns:
urlpatterns = admin_urls( 'MyModel',
(r'path/', 'add', option_dict ),
(r'path/list/', 'list', option_dict ),
(r'path/', 'edit', option_dict ),
)
where MyModel could be omitted and specified in url...
the default values could be taken from the model (for backwards
compatibility) and/or anyplace else...
just my 2c's
>
> Adrian
>
> --
> Adrian Holovaty
> holovaty.com | djangoproject.com
>
> >
>
--
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#: 107471613
Phone: +420 606 678585
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---