-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add toolbar feature. override Index.html so as to better integrate wi…
…th DjangoCMS
- Loading branch information
1 parent
e24526f
commit e9cff5a
Showing
9 changed files
with
81 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from django.core.urlresolvers import reverse | ||
from django.conf import settings | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
from cms.api import get_page_draft | ||
from cms.toolbar_pool import toolbar_pool | ||
from cms.toolbar_base import CMSToolbar | ||
|
||
from pydoc import locate | ||
|
||
accessor_class = locate( | ||
getattr(settings, 'ACCESSOR_CLASS_PATH', 'django_version_viewer.mixins.Accessor')) | ||
accessor = accessor_class() | ||
|
||
|
||
@toolbar_pool.register | ||
class DjangoViewerToolbar(CMSToolbar): | ||
def populate(self): | ||
# always use draft if we have a page | ||
self.page = get_page_draft(self.request.current_page) | ||
|
||
if not self.page: | ||
return | ||
|
||
disabled = not accessor.allow_access(self.request) | ||
current_page_menu = self.toolbar.get_or_create_menu('page') | ||
|
||
current_page_menu.add_modal_item( | ||
_('View Pip Packages'), | ||
url=reverse('django_version_viewer_toolbar'), | ||
disabled=disabled | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{% extends "admin/index.html" %} | ||
|
||
{% load i18n admin_static pip_version_viewer_tags %} | ||
|
||
{% block content %} | ||
{% show_pip_package_versions %} | ||
{{ block.super }} | ||
{% endblock %} |