Move templates and urls to apps.

Implement url hooks.
Many apps are now removable.
Default to assuming services have been migrated.
This commit is contained in:
Adarnof
2017-06-07 22:49:46 -04:00
parent 9cc9a36766
commit 97fe2ddfd0
62 changed files with 685 additions and 469 deletions

View File

@@ -1,5 +1,6 @@
from services.hooks import MenuItemHook
from services.hooks import MenuItemHook, UrlHook
from alliance_auth import hooks
from permissions_tool import urls
class PermissionsTool(MenuItemHook):
@@ -7,7 +8,9 @@ class PermissionsTool(MenuItemHook):
MenuItemHook.__init__(self,
'Permissions Audit',
'fa fa-key fa-id-card grayiconecolor',
'permissions_overview', 400)
'permissions_tool:overview',
order=400,
navactive=['permissions_tool:'])
def render(self, request):
if request.user.has_perm('permissions_tool.audit_permissions'):
@@ -15,6 +18,11 @@ class PermissionsTool(MenuItemHook):
return ''
@hooks.register('menu_util_hook')
@hooks.register('menu_item_hook')
def register_menu():
return PermissionsTool()
@hooks.register('url_hook')
def register_url():
return UrlHook(urls, 'permissions_tool', r'^permissions/')

View File

@@ -11,12 +11,12 @@
{% if request.GET.all != 'yes' %}
<span class="pull-right">
{% blocktrans %}Showing only applied permissions{% endblocktrans %}
<a href="{% url 'permissions_overview' %}?all=yes" class="btn btn-primary">{% trans "Show All" %}</a>
<a href="{% url 'permissions_tool:overview' %}?all=yes" class="btn btn-primary">{% trans "Show All" %}</a>
</span>
{% else %}
<span class="pull-right">
{% blocktrans %}Showing all permissions{% endblocktrans %}
<a href="{% url 'permissions_overview' %}?all=no" class="btn btn-primary">{% trans "Show Applied" %}</a>
<a href="{% url 'permissions_tool:overview' %}?all=no" class="btn btn-primary">{% trans "Show Applied" %}</a>
</span>
{% endif %}
<table class="table table-hover">
@@ -55,7 +55,7 @@
{{ perm.permission.content_type.model }}
</td>
<td>
<a href="{% url "permissions_audit" app_label=perm.permission.content_type.app_label model=perm.permission.content_type.model codename=perm.permission.codename %}">
<a href="{% url "permissions_tool:audit" app_label=perm.permission.content_type.app_label model=perm.permission.content_type.model codename=perm.permission.codename %}">
{{ perm.permission.codename }}
</a>
</td>

View File

@@ -4,7 +4,7 @@ from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^overview/$', views.permissions_overview, name='permissions_overview'),
url(r'^overview/$', views.permissions_overview, name='overview'),
url(r'^audit/(?P<app_label>[\w\-_]+)/(?P<model>[\w\-_]+)/(?P<codename>[\w\-_]+)/$', views.permissions_audit,
name='permissions_audit'),
name='audit'),
]