diff options
Diffstat (limited to 'lib/grappelli/templates/admin_tools')
24 files changed, 625 insertions, 0 deletions
diff --git a/lib/grappelli/templates/admin_tools/dashboard/css.html b/lib/grappelli/templates/admin_tools/dashboard/css.html new file mode 100644 index 0000000..0c69fd1 --- /dev/null +++ b/lib/grappelli/templates/admin_tools/dashboard/css.html @@ -0,0 +1,2 @@ +{% for css in css_files %} +<link rel="stylesheet" href="{{ media_url }}/{{ css }}" type="text/css" media="screen, projection"/>{% endfor %} diff --git a/lib/grappelli/templates/admin_tools/dashboard/dashboard.html b/lib/grappelli/templates/admin_tools/dashboard/dashboard.html new file mode 100644 index 0000000..76aaa1e --- /dev/null +++ b/lib/grappelli/templates/admin_tools/dashboard/dashboard.html @@ -0,0 +1,79 @@ +{% load i18n admin_tools_dashboard_tags %} + +<script type="text/javascript" src="{{ media_url }}/admin_tools/js/utils.js"></script> + +<script type="text/javascript" charset="utf-8"> + // Load js files syncronously and conditionally + + var js_files = [ + { + src : '{{ media_url }}/admin_tools/js/jquery/jquery.min.js', + test: function() { return typeof(jQuery) == 'undefined'; } + }, + { + src : '{{ media_url }}/admin_tools/js/jquery/jquery-ui.min.js', + test: function() { return typeof(jQuery.ui) == 'undefined'; } + }, + { + src : '{{ media_url }}/admin_tools/js/json.min.js', + test: function() { return typeof(JSON.stringify) == 'undefined'; } + }, + { + src : '{{ media_url }}/admin_tools/js/jquery/jquery.cookie.min.js', + test: function() { return typeof(jQuery.cookie) == 'undefined'; } + }, + { + src : '{{ media_url }}/admin_tools/js/jquery/jquery.dashboard.js', + test: function() { return true; } + }, + { + src : '{{ media_url }}/admin_tools/js/dashboard.js', + test: function() { return true; } + }{% for js in dashboard.Media.js %}, + { + src : '{{ media_url }}/{{ js }}', + test: function() { return true; } + }{% endfor %} + ]; + + loadScripts(js_files, function(){ + jQuery(function($) { + init_dashboard( + '{{ dashboard.get_id }}', + {{ dashboard.columns }}, + {% autoescape off %}{{ dashboard_preferences }}{% endautoescape %}, + '{% url admin-tools-dashboard-set-preferences %}' + ); + }); + }); +</script> + +{% if dashboard.Media.js %} + {% for js in dashboard.Media.js %} + <script type="text/javascript" src="{{ media_url }}/{{ js }}"></script> + {% endfor %} +{% endif %} + +<div class="container-grid"> + <div class="column span-12"> + {% for module in dashboard.children %} + {% if "column_1" in module.css_classes %} + {% admin_tools_render_dashboard_module module forloop.counter %} + {% endif %} + {% endfor %} + </div> + <div class="column span-6"> + {% for module in dashboard.children %} + {% if "column_2" in module.css_classes %} + {% admin_tools_render_dashboard_module module forloop.counter %} + {% endif %} + {% endfor %} + </div> + <div class="column span-6 last"> + {% for module in dashboard.children %} + {% if "column_3" in module.css_classes %} + {% admin_tools_render_dashboard_module module forloop.counter %} + {% endif %} + {% endfor %} + </div> +</div> diff --git a/lib/grappelli/templates/admin_tools/dashboard/dashboard.txt b/lib/grappelli/templates/admin_tools/dashboard/dashboard.txt new file mode 100644 index 0000000..4417070 --- /dev/null +++ b/lib/grappelli/templates/admin_tools/dashboard/dashboard.txt @@ -0,0 +1,141 @@ +from django.utils.translation import ugettext_lazy as _ +from django.core.urlresolvers import reverse +from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard + +# to activate your index dashboard add the following to your settings.py: +# +# ADMIN_TOOLS_INDEX_DASHBOARD = '{{ project }}.{{ file }}.CustomIndexDashboard' + +class CustomIndexDashboard(Dashboard): + """ + Custom index dashboard for {{ project }}. + """ + def __init__(self, **kwargs): + Dashboard.__init__(self, **kwargs) + + # append a link list module for "quick links" + #self.children.append(modules.LinkList( + # title=_('Quick links'), + # layout='inline', + # draggable=False, + # deletable=False, + # collapsible=False, + # children=[ + # { + # 'title': _('Return to site'), + # 'url': '/', + # }, + # { + # 'title': _('Change password'), + # 'url': reverse('admin:password_change'), + # }, + # { + # 'title': _('Log out'), + # 'url': reverse('admin:logout') + # }, + # ] + #)) + + self.children.append(modules.LinkList( + column=1, + title=_('Media Management'), + children=[ + { + 'title': _('Django FileBrowser'), + 'url': '/admin/filebrowser/browse/', + 'external': False, + }, + ] + )) + + # append an app list module for "Administration" + self.children.append(modules.AppList( + title=_('Administration'), + include_list=('django.contrib',), + css_classes=['collapse', 'open'], + )) + + # append an app list module for "Applications" + self.children.append(modules.AppList( + title=_('Applications'), + exclude_list=('django.contrib',), + css_classes=['collapse', 'open'], + )) + + # append a recent actions module + self.children.append(modules.RecentActions( + column=2, + title=_('Recent Actions'), + limit=5 + )) + + # append a feed module + self.children.append(modules.Feed( + column=2, + title=_('Latest Django News'), + feed_url='http://www.djangoproject.com/rss/weblog/', + limit=5 + )) + + # append another link list module for "support". + self.children.append(modules.LinkList( + column=2, + title=_('Support'), + children=[ + { + 'title': _('Django documentation'), + 'url': 'http://docs.djangoproject.com/', + 'external': True, + }, + { + 'title': _('Django "django-users" mailing list'), + 'url': 'http://groups.google.com/group/django-users', + 'external': True, + }, + { + 'title': _('Django irc channel'), + 'url': 'irc://irc.freenode.net/django', + 'external': True, + }, + ] + )) + + def init_with_context(self, context): + """ + Use this method if you need to access the request context. + """ + pass + + +# to activate your app index dashboard add the following to your settings.py: +# +# ADMIN_TOOLS_APP_INDEX_DASHBOARD = '{{ project }}.{{ file }}.CustomAppIndexDashboard' + +class CustomAppIndexDashboard(AppIndexDashboard): + """ + Custom app index dashboard for {{ project }}. + """ + def __init__(self, *args, **kwargs): + AppIndexDashboard.__init__(self, *args, **kwargs) + + # we disable title because its redundant with the model list module + self.title = '' + + # append a model list module + self.children.append(modules.ModelList( + title=_(self.app_title), + models=self.models, + )) + + # append a recent actions module + self.children.append(modules.RecentActions( + column=2, + title=_('Recent Actions'), + include_list=self.get_app_content_types(), + )) + + def init_with_context(self, context): + """ + Use this method if you need to access the request context. + """ + pass diff --git a/lib/grappelli/templates/admin_tools/dashboard/dashboard_app_index.txt b/lib/grappelli/templates/admin_tools/dashboard/dashboard_app_index.txt new file mode 100644 index 0000000..0574dfc --- /dev/null +++ b/lib/grappelli/templates/admin_tools/dashboard/dashboard_app_index.txt @@ -0,0 +1,29 @@ +from django.utils.translation import ugettext_lazy as _ +from django.core.urlresolvers import reverse +from admin_tools.dashboard import modules, AppIndexDashboard + +# create your custom modules here if you want, for example: +# +# class CustomDashboardModule(modules.DashboardModule): +# pass +# +{% if warning %} +# WARNING: you've changed the default file name 'dashboard.py' to '{{ file }}.py', +# so, you will need to tell django-admin-tools about this, just add this line +# to your settings.py file: +# ADMIN_TOOLS_APP_INDEX_DASHBOARD_MODULE = '{{ file }}' +{% endif %} +# Your {{ app }} dashboard class +class {{ app|capfirst }}Dashboard(AppIndexDashboard): + """ + Document your custom app index dashboard. + """ + def __init__(self, app_title, models, *args, **kwargs): + super(CustomAppIndexDashboard, self).__init__(*args, **kwargs) + + # append your modules here, example: + # self.append(modules.RecentActionsDashboardModule( + # title=_('Recent Actions'), + # limit=5, + # include_list=models, + # )) diff --git a/lib/grappelli/templates/admin_tools/dashboard/dummy.html b/lib/grappelli/templates/admin_tools/dashboard/dummy.html new file mode 100644 index 0000000..f04fcf5 --- /dev/null +++ b/lib/grappelli/templates/admin_tools/dashboard/dummy.html @@ -0,0 +1 @@ +{% extends template %} diff --git a/lib/grappelli/templates/admin_tools/dashboard/module.html b/lib/grappelli/templates/admin_tools/dashboard/module.html new file mode 100644 index 0000000..85f55f8 --- /dev/null +++ b/lib/grappelli/templates/admin_tools/dashboard/module.html @@ -0,0 +1,7 @@ +{% if not module.is_empty %} + {% block module_content %} + {% for child in module.children %} + {{ child }} + {% endfor %} + {% endblock %} +{% endif %} diff --git a/lib/grappelli/templates/admin_tools/dashboard/modules/app_list.html b/lib/grappelli/templates/admin_tools/dashboard/modules/app_list.html new file mode 100644 index 0000000..8cbd4a7 --- /dev/null +++ b/lib/grappelli/templates/admin_tools/dashboard/modules/app_list.html @@ -0,0 +1,58 @@ +{% extends "admin_tools/dashboard/module.html" %} +{% load i18n %} +{% block module_content %} + <div class="module {% for item in module.css_classes %}{{ item }} {% endfor %}"{% if index %} id="module_{{ index }}{% if subindex %}_{{ subindex }}{% endif %}"{% endif %}> + + {% if module.title %} + {% if subindex %} + <h3>{{ module.title }}</h3> + {% else %} + <h2>{{ module.title }}</h2> + {% endif %} + {% endif %} + +{% spaceless %} + {% if module.pre_content %} + <p>{{ module.pre_content }}</p> + {% endif %} + {% for child in module.children %} + + <div class="module"> + {% if subindex %} + <h4><a href="{{ child.url }}">{{ child.title }}</a></h4> + {% else %} + <h3><a href="{{ child.url }}">{{ child.title }}</a></h3> + {% endif %} + + {% for model in child.models %} + <div class="row"> + {% if model.change_url %} + <a href="{{ model.change_url }}">{{ model.title }}</a> + {% else %} + {{ model.title }} + {% endif %} + {% if model.add_url or model.change_url %} + <ul class="actions"> + {% if model.add_url %} + <li class="add-link"> + <a href="{{ model.add_url }}">{% trans "Add" %}</a> + </li> + {% endif %} + {% if model.change_url %} + <li class="change-link"> + <a href="{{ model.change_url }}">{% trans "Change" %}</a> + </li> + {% endif %} + </ul> + {% endif %} + </div> + {% endfor %} + + </div> + {% endfor %} + {% if module.post_content %} + <p>{{ module.post_content }}</p> + {% endif %} +{% endspaceless %} +</div> +{% endblock %} diff --git a/lib/grappelli/templates/admin_tools/dashboard/modules/column.html b/lib/grappelli/templates/admin_tools/dashboard/modules/column.html new file mode 100644 index 0000000..8df8268 --- /dev/null +++ b/lib/grappelli/templates/admin_tools/dashboard/modules/column.html @@ -0,0 +1,9 @@ +{% extends "dashboard/module.html" %} +{% load i18n admin_tools_dashboard_tags %} +{% block module_content %} + <div class="column {{ module.className }}"> + {% for child in module.children %} + {% admin_tools_render_dashboard_module child forloop.counter %} + {% endfor %} + </div> +{% endblock %}
\ No newline at end of file diff --git a/lib/grappelli/templates/admin_tools/dashboard/modules/feed.html b/lib/grappelli/templates/admin_tools/dashboard/modules/feed.html new file mode 100644 index 0000000..3deec4e --- /dev/null +++ b/lib/grappelli/templates/admin_tools/dashboard/modules/feed.html @@ -0,0 +1,21 @@ +{% extends "admin_tools/dashboard/module.html" %} +{% block module_content %} +{% if subindex %} + <div class="module feed {% for item in module.css_classes %}{{ item }} {% endfor %}"> + <h3>{{ module.title }}</h2> +{% else %} + <div class="module feed {% for item in module.css_classes %}{{ item }} {% endfor %}"> + <h2>{{ module.title }}</h2> +{% endif %} + <ul> + {% spaceless %} + {% for child in module.children %} + <li> + {% if child.date %}<span class="date mini quiet">{{ child.date|date }} </span>{% endif %} + {% if child.warning %}<span class="warning">{{ child.title }}</span>{% else %}<a class="external" href="{{ child.url }}">{{ child.title }}</a>{% endif %} + </li> + {% endfor %} + {% endspaceless %} + </ul> +</div> +{% endblock %} diff --git a/lib/grappelli/templates/admin_tools/dashboard/modules/group.html b/lib/grappelli/templates/admin_tools/dashboard/modules/group.html new file mode 100644 index 0000000..144c82f --- /dev/null +++ b/lib/grappelli/templates/admin_tools/dashboard/modules/group.html @@ -0,0 +1,33 @@ +{% extends "admin_tools/dashboard/module.html" %} +{% load admin_tools_dashboard_tags %} +{% block module_content %} +<div class="group group-{{ module.display }} {% for item in module.css_classes %}{{ item }} {% endfor %}"> + {% spaceless %} + {% if module.title %} + <h2>{{ module.title }}</h2> + {% endif %} + {% ifequal module.display "tabs" %} + <div class="group-{{ module.display }}-container"> + <ul> + {% for sub_module in module.children %} + {% if not sub_module.is_empty %}<li class="group-tabs-link"><a href="#module_{{ index }}_{{ forloop.counter }}">{{ sub_module.title }}</a></li>{% endif %} + {% endfor %} + </ul> + {% for sub_module in module.children %} + {% admin_tools_render_dashboard_module sub_module index forloop.counter %} + {% endfor %} + </div> + {% endifequal %} + {% ifequal module.display "accordion" %} + {% for sub_module in module.children %} + {% if not sub_module.is_empty %}<span class="group-accordion-header"><a href="#">{{ sub_module.title }}</a></span>{% endif %} + {% admin_tools_render_dashboard_module sub_module index forloop.counter %} + {% endfor %} + {% else %} + + {% endifequal %} + + + {% endspaceless %} +</div> +{% endblock %} diff --git a/lib/grappelli/templates/admin_tools/dashboard/modules/link_list.html b/lib/grappelli/templates/admin_tools/dashboard/modules/link_list.html new file mode 100644 index 0000000..97b357e --- /dev/null +++ b/lib/grappelli/templates/admin_tools/dashboard/modules/link_list.html @@ -0,0 +1,21 @@ +{% extends "admin_tools/dashboard/module.html" %} +{% block module_content %} + <div class="module link-list {% for item in module.css_classes %}{{ item }} {% endfor %}"> +{% if module.title %} + {% if subindex %} + <h3>{{ module.title }}</h3> + {% else %} + <h2>{{ module.title }}</h2> + {% endif %} +{% endif %} + <ul> + {% spaceless %} + {% for child in module.children %} + <li> + <a class="{% if child.external %}external{% else %}internal{% endif %}" href="{{ child.url }}" {% if child.description %} title="{{ child.description }}"{% endif %}>{{ child.title }}</a> + </li> + {% endfor %} + {% endspaceless %} + </ul> + </div> +{% endblock %} diff --git a/lib/grappelli/templates/admin_tools/dashboard/modules/model_list.html b/lib/grappelli/templates/admin_tools/dashboard/modules/model_list.html new file mode 100644 index 0000000..7431f8f --- /dev/null +++ b/lib/grappelli/templates/admin_tools/dashboard/modules/model_list.html @@ -0,0 +1,26 @@ +{% extends "admin_tools/dashboard/module.html" %} +{% load i18n %} +{% block module_content %} + <div class="module {% for item in module.css_classes %}{{ item }} {% endfor %}"> + {% if module.title %} + {% if subindex %} + <h3>{{ module.title }}</h3> + {% else %} + <h2>{{ module.title }}</h2> + {% endif %} + {% endif %} + + {% for child in module.children %} + <div class="row"> + {% if child.change_url %}<a href="{{ child.change_url }}">{{ child.title }}</a>{% else %}{{ child.title }}{% endif %} + + {% if child.add_url or child.change_url %} + <ul class="actions"> + {% if child.add_url %}<li class="add-link"><a href="{{ child.add_url }}">{% trans "Add" %}</a></li>{% endif %} + {% if child.change_url %}<li class="change-link"><a href="{{ child.change_url }}">{% trans "Change" %}</a></li>{% endif %} + </ul> + {% endif %} + </div> + {% endfor %} + </div> +{% endblock %} diff --git a/lib/grappelli/templates/admin_tools/dashboard/modules/module_group.html b/lib/grappelli/templates/admin_tools/dashboard/modules/module_group.html new file mode 100644 index 0000000..8e0f256 --- /dev/null +++ b/lib/grappelli/templates/admin_tools/dashboard/modules/module_group.html @@ -0,0 +1,10 @@ +{% extends "dashboard/module.html" %} +{% load i18n admin_tools_dashboard_tags %} +{% block module_content %} + <div class="group collapsible open"> + <h2 class="collapsible-handler">{{ module.title }}</h2> + {% for sub_module in module.children %} + {% admin_tools_render_dashboard_module sub_module forloop.counter %} + {% endfor %} + </div> +{% endblock %} diff --git a/lib/grappelli/templates/admin_tools/dashboard/modules/recent_actions.html b/lib/grappelli/templates/admin_tools/dashboard/modules/recent_actions.html new file mode 100644 index 0000000..0b7bb9e --- /dev/null +++ b/lib/grappelli/templates/admin_tools/dashboard/modules/recent_actions.html @@ -0,0 +1,26 @@ +{% extends "admin_tools/dashboard/module.html" %} +{% load i18n %} +{% block module_content %} +{% if subindex %} + <div class="module actions {% for item in module.css_classes %}{{ item }} {% endfor %}"> + <h3>{% trans 'Recent Actions' %}</h2> + <div class="module"> + <h4>{% trans 'My Actions' %}</h3> +{% else %} + <div class="module actions {% for item in module.css_classes %}{{ item }} {% endfor %}"> + <h2>{% trans 'Recent Actions' %}</h2> + <div class="module"> + <h3>{% trans 'My Actions' %}</h3> +{% endif %} + {% if module.children %} + <ul> + {% for entry in module.children %} + <li class="{% if entry.is_addition %}add-link{% endif %}{% if entry.is_change %}change-link{% endif %}{% if entry.is_deletion %}delete-link{% endif %}">{% if not entry.is_deletion %}<a href="{{ entry.get_admin_url }}">{% endif %}{{ entry.object_repr }}{% if not entry.is_deletion %}</a>{% endif %}<br /><span class="mini quiet">{% filter capfirst %}{% trans entry.content_type.name %}{% endfilter %}</span></li> + {% endfor %} + </ul> + {% else %} + <p>{% trans 'None Available' %}</p> + {% endif %} + </div> +</div> +{% endblock %} diff --git a/lib/grappelli/templates/admin_tools/dashboard/preferences_form.html b/lib/grappelli/templates/admin_tools/dashboard/preferences_form.html new file mode 100644 index 0000000..7da463a --- /dev/null +++ b/lib/grappelli/templates/admin_tools/dashboard/preferences_form.html @@ -0,0 +1,10 @@ +{% extends "admin/base_site.html" %} + +{% block content %} + +<form action="." method="POST"> + {{ form.as_p }} + <p><input type="submit" value="Save" /></p> +</form> + +{% endblock %} diff --git a/lib/grappelli/templates/admin_tools/menu/add_bookmark_form.html b/lib/grappelli/templates/admin_tools/menu/add_bookmark_form.html new file mode 100644 index 0000000..e0fcf2a --- /dev/null +++ b/lib/grappelli/templates/admin_tools/menu/add_bookmark_form.html @@ -0,0 +1,9 @@ +{% url admin-tools-menu-add-bookmark as form_url %} +{% if form_url %} + <form id="bookmark-form" action="{{ form_url }}" method="POST"> + <input type="hidden" name="next" value="{% firstof url request.get_full_path|urlencode %}" /> + <input type="hidden" name="url" value="{% firstof url request.get_full_path|urlencode %}" /> + <input type="hidden" name="title" value="{{ title }}" /> + <button id="bookmark-button" type="submit"></button> + </form> +{% endif %} diff --git a/lib/grappelli/templates/admin_tools/menu/css.html b/lib/grappelli/templates/admin_tools/menu/css.html new file mode 100644 index 0000000..71aefdb --- /dev/null +++ b/lib/grappelli/templates/admin_tools/menu/css.html @@ -0,0 +1 @@ +<!-- admin_tools/menu/css.html -->
\ No newline at end of file diff --git a/lib/grappelli/templates/admin_tools/menu/delete_confirm.html b/lib/grappelli/templates/admin_tools/menu/delete_confirm.html new file mode 100644 index 0000000..e32a678 --- /dev/null +++ b/lib/grappelli/templates/admin_tools/menu/delete_confirm.html @@ -0,0 +1,13 @@ +{% extends "admin/base_site.html" %} + +{% block content %} + +<p>Are you sure you want to delete this bookmark?</p> + +<p>{{ bookmark.name }} - {{ bookmark.url }}</p> + +<form action="." method="POST"> + <p><input type="submit" value="Delete" /></p> +</form> + +{% endblock %} diff --git a/lib/grappelli/templates/admin_tools/menu/dummy.html b/lib/grappelli/templates/admin_tools/menu/dummy.html new file mode 100644 index 0000000..f04fcf5 --- /dev/null +++ b/lib/grappelli/templates/admin_tools/menu/dummy.html @@ -0,0 +1 @@ +{% extends template %} diff --git a/lib/grappelli/templates/admin_tools/menu/form.html b/lib/grappelli/templates/admin_tools/menu/form.html new file mode 100644 index 0000000..7da463a --- /dev/null +++ b/lib/grappelli/templates/admin_tools/menu/form.html @@ -0,0 +1,10 @@ +{% extends "admin/base_site.html" %} + +{% block content %} + +<form action="." method="POST"> + {{ form.as_p }} + <p><input type="submit" value="Save" /></p> +</form> + +{% endblock %} diff --git a/lib/grappelli/templates/admin_tools/menu/item.html b/lib/grappelli/templates/admin_tools/menu/item.html new file mode 100644 index 0000000..9bf8bbd --- /dev/null +++ b/lib/grappelli/templates/admin_tools/menu/item.html @@ -0,0 +1,15 @@ +{% load admin_tools_menu_tags %} +{% spaceless %} +{% if not item.is_empty %} + <li class="menu-item{% if item.children %} parent{% if index %} collapse closed{% else %} item-collapse item-closed{% endif %}{% endif %}{% if not item.enabled %} disabled{% endif %}{% if selected %} selected{% endif %}{% if forloop.last %} last{% endif %}{% if item.css_classes %} {{ item.css_classes|join:' ' }}{% endif %}"> + <a href="{% if item.url and item.enabled %}{{ item.url }}{% else %}#{% endif %}" class="{% if item.children %}parent{% if index %} collapse-handler{% else %} item-collapse-handler-container{% endif %}{% endif %}" {% if item.description %} title="{{ item.description }}"{% endif %}{% if item.accesskey %} accesskey="{{ item.accesskey }}"{% endif %}>{{ item.title }}</a>{% if item.children %}{% if not index %}<a href="javascript://" class="icon item-collapse-handler"></a>{% endif %}{% endif %} + {% if item.children %} + <ul> + {% for child_item in item.children %} + {% admin_tools_render_menu_item child_item %} + {% endfor %} + </ul> + {% endif %} + </li> +{% endif %} +{% endspaceless %} diff --git a/lib/grappelli/templates/admin_tools/menu/menu.html b/lib/grappelli/templates/admin_tools/menu/menu.html new file mode 100644 index 0000000..f43dc23 --- /dev/null +++ b/lib/grappelli/templates/admin_tools/menu/menu.html @@ -0,0 +1,64 @@ +{% load i18n admin_tools_menu_tags %} +{% if menu.children %} + <script type="text/javascript" src="{{ media_url }}/admin_tools/js/utils.js"></script> + <script type="text/javascript" charset="utf-8"> + // Load js files syncronously and conditionally + var js_files = [ + { + src : '{{ media_url }}/admin_tools/js/jquery/jquery.min.js', + test: function() { return typeof(jQuery) == 'undefined'; } + }, + { + src : '{{ media_url }}/admin_tools/js/json.min.js', + test: function() { return typeof(JSON.stringify) == 'undefined'; } + }, + { + src : '{{ media_url }}/admin_tools/js/menu.js', + test: function() { return true; } + }{% for js in menu.Media.js %}, + { + src : '{{ media_url }}/{{ js }}', + test: function() { return true; } + }{% endfor %} + ]; + loadScripts(js_files, function(){ + jQuery(function($) { + {% if has_bookmark_item %} + process_bookmarks( + "{{ request.get_full_path }}", + "{{ title }}", + "{% trans 'Please enter a name for the bookmark' %}" + ); + {% endif %} + }); + }); + </script> + {% comment %} + {% for item in menu.children %} + <ul class="navigation-menu"> + {% admin_tools_render_menu_item item forloop.counter %} + {% ifequal item.css_classes|join:' ' "bookmark" %} + <li class="actions"> + {% if bookmark %} + {% include "admin_tools/menu/remove_bookmark_form.html" %} + {% else %} + {% include "admin_tools/menu/add_bookmark_form.html" %} + {% endif %} + </li> + {% endifequal %} + </ul> + {% endfor %} + {% endcomment %} + {% for item in menu.children %} + <ul class="navigation-menu"> + {% admin_tools_render_menu_item item forloop.counter %} + </ul> + {% ifequal item.css_classes|join:' ' "bookmark" %} + {% if bookmark %} + {% include "admin_tools/menu/remove_bookmark_form.html" %} + {% else %} + {% include "admin_tools/menu/add_bookmark_form.html" %} + {% endif %} + {% endifequal %} + {% endfor %} +{% endif %} diff --git a/lib/grappelli/templates/admin_tools/menu/menu.txt b/lib/grappelli/templates/admin_tools/menu/menu.txt new file mode 100644 index 0000000..72d20da --- /dev/null +++ b/lib/grappelli/templates/admin_tools/menu/menu.txt @@ -0,0 +1,32 @@ +from django.core.urlresolvers import reverse +from django.utils.translation import ugettext_lazy as _ +from admin_tools.menu import items, Menu + +# to activate your custom menu add the following to your settings.py: +# +# ADMIN_TOOLS_MENU = '{{ project }}.{{ file }}.CustomMenu' + +class CustomMenu(Menu): + """ + Custom Menu for {{ project }} admin site. + """ + def __init__(self, **kwargs): + Menu.__init__(self, **kwargs) + self.children.append(items.MenuItem( + title=_('Dashboard'), + url=reverse('admin:index') + )) + self.children.append(items.AppList( + title=_('Applications'), + models=('add.your.app.models.here',) + )) + self.children.append(items.AppList( + title=_('Administration'), + models=('django.contrib',) + )) + + def init_with_context(self, context): + """ + Use this method if you need to access the request context. + """ + pass diff --git a/lib/grappelli/templates/admin_tools/menu/remove_bookmark_form.html b/lib/grappelli/templates/admin_tools/menu/remove_bookmark_form.html new file mode 100644 index 0000000..7d9567f --- /dev/null +++ b/lib/grappelli/templates/admin_tools/menu/remove_bookmark_form.html @@ -0,0 +1,7 @@ +{% url admin-tools-menu-remove-bookmark bookmark.id as form_url %} +{% if form_url %} +<form id="bookmark-form" action="{{ form_url }}" method="POST"> + <input type="hidden" name="next" value="{% firstof url request.get_full_path|urlencode %}" /> + <button id="bookmark-button" class="bookmarked" type="submit"></button> +</form> +{% endif %} |