Alex
> --
> You received this message because you are subscribed to the Google Groups "django-admin-tools" group.
> To post to this group, send email to django-ad...@googlegroups.com.
> To unsubscribe from this group, send email to django-admin-to...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-admin-tools?hl=en.
>
>
You could also implement a callable, i.e. "custom_dashboard_factory()",
that would return the Dashboard class conditionally, given the current site.
Then you just have to set the ADMIN_TOOLS_INDEX_DASHBOARD to your
factory function.
--
David
Le 22/06/2010 15:49, Alex Robbins a �crit :
honestly I've never tried django-admin-tools with multiple admin sites
(with AdminSite instances), so I'm not sure it will work.
What I was thinking is something like this:
someapp/utils.py
"""
from someapp.admin import siteA, siteB
from someapp import dashboards
def custom_dashboard_factory():
if sometest(siteA, siteB):
return dashboards.SiteACustomDashboard()
return dashboards.SiteBCustomDashboard()
"""
someapp/settings.py
"""
ADMIN_TOOLS_INDEX_DASHBOARD = 'someapp.utils.custom_dashboard_factory'
"""
But again, I'm not sure if it will work and especially my solution
doesn't give access to the current request object which I guess is
needed to know what's the current admin site...
I don't what to speak for him but I think that what Alex proposes is
something like:
someapp.dashboards.py
"""
from admin_tools.dashboard import Dashboard
class MyDashboard(Dashboard):
def init_with_context(self, request):
if sometest(request):
self.append(module_for_siteA_1)
self.append(module_for_siteA_2)
# etc...
else:
self.append(module_for_siteB_1)
self.append(module_for_siteB_2)
# etc...
"""
Here you have access to the request...
I hope it's a bit more clear ;)
--
David
2010/7/12 patrickk <sehma...@gmail.com>:
--
David JL <izim...@gmail.com>
It would help us if you could tell us what the problem is. How did the
first method fail? What did you try? What were the errors? How did the
second method fail? What did you try....etc.
David was correct about my approach. I was thinking you'd do this:
someapp.dashboards.py
"""
from admin_tools.dashboard import Dashboard
class MyDashboard(Dashboard):
def init_with_context(self, request):
if sometest(request):
self.append(module_for_siteA_1)
self.append(module_for_siteA_2)
# etc...
else:
self.append(module_for_siteB_1)
self.append(module_for_siteB_2)
# etc...
"""
and then sometest would look at the request's url to decide which
admin site it was in.
def sometest(request):
return request.path.startswith('/url/to/admin_site_A/')
I agree it would be nice to explicitly assign dashboards to admin
instances, but it isn't implemented that way right now and everyone is
busy. Definitely make an enhancement issue for that. It would be good,
but it might be a (long) while.
Good luck!
Alex
I'll have to get back to you on that (after more thinking).
Alex
Regards,
--
David
2010/7/13 Alex Robbins <alexander...@gmail.com>:
--
David JL <izim...@gmail.com>
grappelli_admin_tools can do this now
(http://bitbucket.org/fetzig/grappelli-admin-tools/).
@everybody: ATTENTION grappelli_admin_tools is a fork especially for
django-grappelli. we thought it would be nice to sort and group the
apps/models as we want and admin_tools.dashboard seems to do that very
good. so grappelli_admin_tools is an customized admin_tools.dashboard
only (no menu, no theming). => can't make any assumptions about the
other parts of admin_tools.
how to get multiple AdminSite's workin':
1) new settings:
ADMIN_TOOLS_INDEX_DASHBOARD = {
'www.admin.main_site': 'www.dashboard.CustomIndexDashboard',
...
the name of the AdminSite has to be equal to its name in the namespace
(will maybe change this).
i.e. main_site = AdminSite("main_site")
2) added functionality to all functions which get
ADMIN_TOOLS_INDEX_DASHBOARD and ADMIN_TOOLS_APP_INDEX_DASHBOARD (if
dict then...)
3) checked for all reverse('admin:... calls and replaced "admin" with
result of get_admin_site_name(context)
don't know if i missed some stuff, but it seems to work fine with two
AdminSite instances, and works still with one instance too :)
please send me feedback.
@izi/david/half programmer half amazing: great! it's such a pleasure
to hack into your code. hope you like the feature.
greets,
klemens
--
klemens mantzos
http://fetzig.at/
sorry for the delay...
I'll have to check this out, I don't have a multi admin site test
project currently but I will do.
> @izi/david/half programmer half amazing: great! it's such a pleasure
> to hack into your code. hope you like the feature.
>
Thanks ! and I'd like to forward the compliment to the people who are
contributing: alex, mike, just to name a few.
Now, to be honest, I'm not sure the grappelli-admin-tools fork is a good
idea... I'm sure the changes could be merged upstream, as long as they
do not break things.
What do you (grappelli) guys think about working on a clean patch
against the current code ?
Regards,
--
David
Hi Patrick,
Maybe you could just override / extend the admin-tools templates simply
by creating a admin_tools directory in the grappelli/templates/
directory, and if a patch for the python part of admin_tools is still
needed, we could apply it upstream. It's better to have to maintain some
templates than a complete fork.
The only requirement I can think of is that "admin_tools" will have to
be placed before "grappelli" in the INSTALLED_APPS.
Regards,
--
David
>> read more �
>>
>
Sorry Patrick, of course I meant *after*... ;)
But as Mikhail noted there will be some trouble with the django admin
templates, because both admin-tools and grappelli override them...
Hence, Mikhail's proposal seems to be the way to go.
I'll try to install grappelli + admin-tools on a virtualenv and see how
it goes.
Regards,
--
David
Ok, I like the last option Mikhail proposed, that is:
- leave admin_tools templates in the directory they are located now,
- change the renderers to first look for a
admin_tools/{dashboard,menu}/overrides/<template_name>.html, if it
exists, use it, if not use
admin_tools/{dashboard,menu}/<template_name>.html.
For grappelli admin tools that would mean to just create a
admin_tools/{dashboard,menu}/overrides/, and put the templates there.
Once we've done this, we'll sort out the things that possibly need to be
modified upstream in the python code, to achieve complete integration.
What do you all thing about the idea ? Am I missing some drawbacks of
this solution ?
Regards,
--
David
GREAT.
except of the multiple AdminSite() support python code is the same.
> --
> You received this message because you are subscribed to the Google Groups
> "django-admin-tools" group.
> To post to this group, send email to django-ad...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-admin-to...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-admin-tools?hl=en.
>
>
--
klemens mantzos
http://fetzig.at/
Hi Klemens,
your solution for this (multiple admin sites) looks great and backwards
compatible, I see no reason to not merge it upstream.
I'm super busy with work at the moment unfortunately :( so I won't have
time to do the changes before two weeks or so...
If anyone want to work on a fork of the current code and integrate those
changes (it will be excellent if doc/tests were updated also !) it will
be very appreciated.
maybe i'll do it sooner. will talk with patrick about that. let you know.
greetings,
not only the templates/admin_tools templates are custom in
grappelli-admin-tools.
templates/admin/... too.
(to just load grappelli first in INSTALLED_APPS wouldn't do. we have
i.e. admin/base.html for grappelli and a different admin/base.html for
grappelli+admin_tools.)
any suggestions how to fix that?
regards,
klemens
> --
> You received this message because you are subscribed to the Google Groups
> "django-admin-tools" group.
> To post to this group, send email to django-ad...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-admin-to...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-admin-tools?hl=en.
>
>
--
klemens mantzos
http://fetzig.at/
INSTALLED_APPS = (
...
'grappelli',
'admin_tools.theming',
'admin_tools.menu',
'admin_tools.dashboard',
'django.contrib.admin',
...
)
all admin_tools/{dashboard,menu}/overrides/ templates are in grappelli.
grappelli has additionally an admin/for_admin_tools/ directory (or
however you wanna name it).
i.e. grappelli has an admin/base_site.html. this template checks via
template_tag if admin_tools is in the INSTALLED_APPS. if true it
extends from admin/for_admin_tools/. if not it renderes the "grappelli
without admin-tools" version of the template.
any suggestions?
regards,
klemens