mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-14 06:50:15 +02:00
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:
parent
9cc9a36766
commit
97fe2ddfd0
@ -16,6 +16,7 @@ from django.contrib import messages
|
||||
from celery.schedules import crontab
|
||||
|
||||
INSTALLED_APPS = [
|
||||
# Core apps - required to function
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
@ -25,25 +26,27 @@ INSTALLED_APPS = [
|
||||
'django.contrib.humanize',
|
||||
'django_celery_beat',
|
||||
'bootstrapform',
|
||||
'geelweb.django.navhelper',
|
||||
'bootstrap_pagination',
|
||||
'sortedm2m',
|
||||
'authentication',
|
||||
'services',
|
||||
'eveonline',
|
||||
'groupmanagement',
|
||||
'notifications',
|
||||
'esi',
|
||||
|
||||
# Optional apps - remove if not desired
|
||||
'corputils',
|
||||
'hrapplications',
|
||||
'timerboard',
|
||||
'srp',
|
||||
'optimer',
|
||||
'corputils',
|
||||
'fleetactivitytracking',
|
||||
'fleetup',
|
||||
'notifications',
|
||||
'esi',
|
||||
'fleetactivitytracking',
|
||||
'permissions_tool',
|
||||
'geelweb.django.navhelper',
|
||||
'bootstrap_pagination',
|
||||
'sortedm2m',
|
||||
|
||||
# Services - comment out if not used
|
||||
# Services - remove if not used
|
||||
'services.modules.mumble',
|
||||
'services.modules.discord',
|
||||
'services.modules.discourse',
|
||||
@ -135,8 +138,6 @@ TEMPLATES = [
|
||||
'django.template.context_processors.tz',
|
||||
'services.context_processors.auth_settings',
|
||||
'notifications.context_processors.user_notification_count',
|
||||
'authentication.context_processors.states',
|
||||
'authentication.context_processors.membership_state',
|
||||
'groupmanagement.context_processors.can_manage_groups',
|
||||
],
|
||||
},
|
||||
@ -164,7 +165,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||
},
|
||||
]
|
||||
|
||||
AUTHENTICATION_BACKENDS = ['authentication.backends.StateBackend']
|
||||
AUTHENTICATION_BACKENDS = ['authentication.backends.StateBackend', 'django.contrib.auth.backends.ModelBackend']
|
||||
LOGIN_URL = 'auth_login_user'
|
||||
|
||||
# Internationalization
|
||||
|
@ -8,16 +8,8 @@ from authentication import hmac_urls
|
||||
import authentication.views
|
||||
import services.views
|
||||
import groupmanagement.views
|
||||
import optimer.views
|
||||
import timerboard.views
|
||||
import fleetactivitytracking.views
|
||||
import fleetup.urls
|
||||
import srp.views
|
||||
import notifications.views
|
||||
import hrapplications.views
|
||||
import corputils.urls
|
||||
import esi.urls
|
||||
import permissions_tool.urls
|
||||
from alliance_auth import NAME
|
||||
from alliance_auth.hooks import get_hooks
|
||||
from django.views.generic.base import TemplateView
|
||||
@ -42,23 +34,6 @@ urlpatterns = [
|
||||
url(r'^sso/', include(esi.urls, namespace='esi')),
|
||||
url(r'^sso/login$', authentication.views.sso_login, name='auth_sso_login'),
|
||||
|
||||
# SRP URLS
|
||||
url(r'^srp_fleet_remove/(\w+)$', srp.views.srp_fleet_remove, name='auth_srp_fleet_remove'),
|
||||
url(r'^srp_fleet_disable/(\w+)$', srp.views.srp_fleet_disable, name='auth_srp_fleet_disable'),
|
||||
url(r'^srp_fleet_enable/(\w+)$', srp.views.srp_fleet_enable, name='auth_srp_fleet_enable'),
|
||||
url(r'^srp_fleet_mark_completed/(\w+)', srp.views.srp_fleet_mark_completed,
|
||||
name='auth_srp_fleet_mark_completed'),
|
||||
url(r'^srp_fleet_mark_uncompleted/(\w+)', srp.views.srp_fleet_mark_uncompleted,
|
||||
name='auth_srp_fleet_mark_uncompleted'),
|
||||
url(r'^srp_request_remove/', srp.views.srp_request_remove,
|
||||
name="auth_srp_request_remove"),
|
||||
url(r'srp_request_approve/', srp.views.srp_request_approve,
|
||||
name='auth_srp_request_approve'),
|
||||
url(r'srp_request_reject/', srp.views.srp_request_reject,
|
||||
name='auth_srp_request_reject'),
|
||||
url(_(r'srp_request_amount_update/(\w+)'), srp.views.srp_request_update_amount,
|
||||
name="auth_srp_request_update_amount"),
|
||||
|
||||
# Notifications
|
||||
url(r'^remove_notifications/(\w+)/$', notifications.views.remove_notification, name='auth_remove_notification'),
|
||||
url(r'^notifications/mark_all_read/$', notifications.views.mark_all_read, name='auth_mark_all_notifications_read'),
|
||||
@ -68,13 +43,6 @@ urlpatterns = [
|
||||
|
||||
# User viewed/translated URLS
|
||||
urlpatterns += i18n_patterns(
|
||||
|
||||
# Fleetup
|
||||
url(r'^fleetup/', include(fleetup.urls.urlpatterns)),
|
||||
|
||||
# Corputils
|
||||
url(_(r'^corpstats/'), include(corputils.urls, namespace='corputils')),
|
||||
|
||||
# Group management
|
||||
url(_(r'^groups/'), groupmanagement.views.groups_view, name='auth_groups'),
|
||||
url(_(r'^group/management/'), groupmanagement.views.group_management,
|
||||
@ -99,54 +67,8 @@ urlpatterns += i18n_patterns(
|
||||
url(_(r'^group/leave_request/reject/(\w+)'), groupmanagement.views.group_leave_reject_request,
|
||||
name='auth_group_leave_reject_request'),
|
||||
|
||||
# HR Application Management
|
||||
url(_(r'^hr_application_management/'), hrapplications.views.hr_application_management_view,
|
||||
name="auth_hrapplications_view"),
|
||||
url(_(r'^hr_application_create/$'), hrapplications.views.hr_application_create_view,
|
||||
name="auth_hrapplication_create_view"),
|
||||
url(_(r'^hr_application_create/(\d+)'), hrapplications.views.hr_application_create_view,
|
||||
name="auth_hrapplication_create_view"),
|
||||
url(_(r'^hr_application_remove/(\w+)'), hrapplications.views.hr_application_remove,
|
||||
name="auth_hrapplication_remove"),
|
||||
url(_(r'hr_application_view/(\w+)'), hrapplications.views.hr_application_view,
|
||||
name="auth_hrapplication_view"),
|
||||
url(_(r'hr_application_personal_view/(\w+)'), hrapplications.views.hr_application_personal_view,
|
||||
name="auth_hrapplication_personal_view"),
|
||||
url(_(r'hr_application_personal_removal/(\w+)'),
|
||||
hrapplications.views.hr_application_personal_removal,
|
||||
name="auth_hrapplication_personal_removal"),
|
||||
url(_(r'hr_application_approve/(\w+)'), hrapplications.views.hr_application_approve,
|
||||
name="auth_hrapplication_approve"),
|
||||
url(_(r'hr_application_reject/(\w+)'), hrapplications.views.hr_application_reject,
|
||||
name="auth_hrapplication_reject"),
|
||||
url(_(r'hr_application_search/'), hrapplications.views.hr_application_search,
|
||||
name="auth_hrapplication_search"),
|
||||
url(_(r'hr_mark_in_progress/(\w+)'), hrapplications.views.hr_application_mark_in_progress,
|
||||
name="auth_hrapplication_mark_in_progress"),
|
||||
|
||||
# Fleet Operations Timers
|
||||
url(_(r'^optimer/$'), optimer.views.optimer_view, name='auth_optimer_view'),
|
||||
url(_(r'^add_optimer/$'), optimer.views.add_optimer_view, name='auth_add_optimer_view'),
|
||||
url(_(r'^remove_optimer/(\w+)'), optimer.views.remove_optimer, name='auth_remove_optimer'),
|
||||
url(_(r'^edit_optimer/(\w+)$'), optimer.views.edit_optimer, name='auth_edit_optimer'),
|
||||
|
||||
# Service Urls
|
||||
url(_(r'^services/$'), services.views.services_view, name='auth_services'),
|
||||
|
||||
# Timer URLS
|
||||
url(_(r'^timers/$'), timerboard.views.timer_view, name='auth_timer_view'),
|
||||
url(_(r'^add_timer/$'), timerboard.views.add_timer_view, name='auth_add_timer_view'),
|
||||
url(_(r'^remove_timer/(\w+)'), timerboard.views.remove_timer, name='auth_remove_timer'),
|
||||
url(_(r'^edit_timer/(\w+)$'), timerboard.views.edit_timer, name='auth_edit_timer'),
|
||||
|
||||
# SRP URLS
|
||||
url(_(r'^srp/$'), srp.views.srp_management, name='auth_srp_management_view'),
|
||||
url(_(r'^srp_all/$'), srp.views.srp_management_all, name='auth_srp_management_all_view'),
|
||||
url(_(r'^srp_fleet_view/(\w+)$'), srp.views.srp_fleet_view, name='auth_srp_fleet_view'),
|
||||
url(_(r'^srp_fleet_add_view/$'), srp.views.srp_fleet_add_view, name='auth_srp_fleet_add_view'),
|
||||
url(_(r'^srp_fleet_edit/(\w+)$'), srp.views.srp_fleet_edit_view, name='auth_srp_fleet_edit_view'),
|
||||
url(_(r'^srp_request/(\w+)'), srp.views.srp_request_view, name='auth_srp_request_view'),
|
||||
|
||||
# Tools
|
||||
url(_(r'^tool/fleet_formatter_tool/$'), services.views.fleet_formatter_view,
|
||||
name='auth_fleet_format_tool_view'),
|
||||
@ -155,33 +77,7 @@ urlpatterns += i18n_patterns(
|
||||
url(_(r'^notifications/$'), notifications.views.notification_list, name='auth_notification_list'),
|
||||
url(_(r'^notifications/(\w+)/$'), notifications.views.notification_view, name='auth_notification_view'),
|
||||
|
||||
# FleetActivityTracking (FAT)
|
||||
url(r'^fat/$', fleetactivitytracking.views.fatlink_view, name='auth_fatlink_view'),
|
||||
url(r'^fat/statistics/$', fleetactivitytracking.views.fatlink_statistics_view, name='auth_fatlink_view_statistics'),
|
||||
url(r'^fat/statistics/corp/(\w+)$', fleetactivitytracking.views.fatlink_statistics_corp_view, name='auth_fatlink_view_statistics_corp'),
|
||||
url(r'^fat/statistics/corp/(?P<corpid>\w+)/(?P<year>[0-9]+)/(?P<month>[0-9]+)/', fleetactivitytracking.views.fatlink_statistics_corp_view,
|
||||
name='auth_fatlink_view_statistics_corp_month'),
|
||||
url(r'^fat/statistics/(?P<year>[0-9]+)/(?P<month>[0-9]+)/$', fleetactivitytracking.views.fatlink_statistics_view,
|
||||
name='auth_fatlink_view_statistics_month'),
|
||||
url(r'^fat/user/statistics/$', fleetactivitytracking.views.fatlink_personal_statistics_view,
|
||||
name='auth_fatlink_view_personal_statistics'),
|
||||
url(r'^fat/user/statistics/(?P<year>[0-9]+)/$', fleetactivitytracking.views.fatlink_personal_statistics_view,
|
||||
name='auth_fatlink_view_personal_statistics_year'),
|
||||
url(r'^fat/user/statistics/(?P<year>[0-9]+)/(?P<month>[0-9]+)/$',
|
||||
fleetactivitytracking.views.fatlink_monthly_personal_statistics_view,
|
||||
name='auth_fatlink_view_personal_statistics_month'),
|
||||
url(r'^fat/user/(?P<char_id>[0-9]+)/statistics/(?P<year>[0-9]+)/(?P<month>[0-9]+)/$',
|
||||
fleetactivitytracking.views.fatlink_monthly_personal_statistics_view,
|
||||
name='auth_fatlink_view_user_statistics_month'),
|
||||
url(r'^fat/create/$', fleetactivitytracking.views.create_fatlink_view, name='auth_create_fatlink_view'),
|
||||
url(r'^fat/modify/$', fleetactivitytracking.views.modify_fatlink_view, name='auth_modify_fatlink_view'),
|
||||
url(r'^fat/modify/(?P<hash>[a-zA-Z0-9_-]+)/([a-z0-9_-]+)$',
|
||||
fleetactivitytracking.views.modify_fatlink_view),
|
||||
url(r'^fat/link/$', fleetactivitytracking.views.fatlink_view, name='auth_click_fatlink_view'),
|
||||
url(r'^fat/link/(?P<hash>[a-zA-Z0-9]+)/(?P<fatname>[a-z0-9_-]+)/$',
|
||||
fleetactivitytracking.views.click_fatlink_view),
|
||||
|
||||
url(r'^permissions/', include(permissions_tool.urls))
|
||||
)
|
||||
|
||||
# Append hooked service urls
|
||||
@ -189,3 +85,7 @@ services = get_hooks('services_hook')
|
||||
for svc in services:
|
||||
urlpatterns += svc().urlpatterns
|
||||
|
||||
# Append app urls
|
||||
app_urls = get_hooks('url_hook')
|
||||
for app in app_urls:
|
||||
urlpatterns += [app().include_pattern]
|
||||
|
@ -23,7 +23,7 @@ def optional_dependencies():
|
||||
dependencies = []
|
||||
|
||||
# Skip adding module dependencies if the settings specifies that services have been migrated
|
||||
if hasattr(settings, 'SERVICES_MIGRATED') and settings.SERVICES_MIGRATED:
|
||||
if not hasattr(settings, 'SERVICES_MIGRATED') or settings.SERVICES_MIGRATED:
|
||||
return dependencies
|
||||
|
||||
if 'services.modules.xenforo' in installed_apps:
|
||||
|
@ -29,59 +29,61 @@
|
||||
|
||||
<nav class="navbar navbar-inverse navbar-static-top auth-navbar-top" role="navigation">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand">
|
||||
<a class="navbar-brand">
|
||||
{{ SITE_NAME }}
|
||||
</a>
|
||||
<!-- /.navbar-header -->
|
||||
</a>
|
||||
<!-- /.navbar-header -->
|
||||
|
||||
<ul class="nav navbar-top-links navbar-right">
|
||||
<li class="nav-link">
|
||||
<form id="f_lang_select" action="{% url 'set_language' %}" method="post">
|
||||
{% csrf_token %}
|
||||
<input name="next" type="hidden" value="{{ request.get_full_path|slice:'3:' }}" />
|
||||
<select onchange="this.form.submit()" class="form-control" id="lang_select" name="language">
|
||||
{% get_language_info_list for LANGUAGES as languages %}
|
||||
{% for language in languages %}
|
||||
<option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected="selected"{% endif %}>
|
||||
{{ language.name_local }} ({{ language.code }})
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</form>
|
||||
</li>
|
||||
{% if notifications %}
|
||||
<li class="nav-link active">
|
||||
<a href="{% url 'auth_notification_list' %}">
|
||||
<ul class="nav navbar-top-links navbar-right">
|
||||
<li class="nav-link">
|
||||
<form id="f_lang_select" action="{% url 'set_language' %}" method="post">
|
||||
{% csrf_token %}
|
||||
<input name="next" type="hidden" value="{{ request.get_full_path|slice:'3:' }}"/>
|
||||
<select onchange="this.form.submit()" class="form-control" id="lang_select" name="language">
|
||||
{% get_language_info_list for LANGUAGES as languages %}
|
||||
{% for language in languages %}
|
||||
<option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %}
|
||||
selected="selected"{% endif %}>
|
||||
{{ language.name_local }} ({{ language.code }})
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</form>
|
||||
</li>
|
||||
{% if notifications %}
|
||||
<li class="nav-link active">
|
||||
<a href="{% url 'auth_notification_list' %}">
|
||||
<span class="fa-stack">
|
||||
<i class="fa fa-bell fa-stack-2x"></i>
|
||||
<i class="fa fa-inverse fa-stack-1x">{{ notifications }}</i>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="nav-link"><a href="{% url 'auth_notification_list' %}">
|
||||
<i class="fa fa-bell-o"></i></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if user.is_authenticated %}
|
||||
{% if user.is_staff %}
|
||||
<li><a href="{% url 'admin:index' %}">{% trans "Admin" %}</a></li>
|
||||
</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="nav-link"><a href="{% url 'auth_notification_list' %}">
|
||||
<i class="fa fa-bell-o"></i></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if user.is_authenticated %}
|
||||
{% if user.is_staff %}
|
||||
<li><a href="{% url 'admin:index' %}">{% trans "Admin" %}</a></li>
|
||||
{% endif %}
|
||||
<li><a href="{% url 'auth_logout' %}">{% trans "Logout" %}</a></li>
|
||||
{% else %}
|
||||
<li><a href="{% url 'authentication:login' %}">{% trans "Login" %}</a></li>
|
||||
{% endif %}
|
||||
<li><a href="{% url 'auth_logout' %}">{% trans "Logout" %}</a></li>
|
||||
{% else %}
|
||||
<li><a href="{% url 'authentication:login' %}">{% trans "Login" %}</a></li>
|
||||
{% endif %}
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- /.navbar-top-links -->
|
||||
|
||||
<div class="navbar-default sidebar auth-sidebar" role="navigation">
|
||||
<div class="sidebar-nav navbar-collapse">
|
||||
<ul class="nav" id="side-menu">
|
||||
<li>
|
||||
<a class="{% navactive request 'authentication:dashboard' %}" href="{% url 'authentication:dashboard' %}">
|
||||
<a class="{% navactive request 'authentication:dashboard' %}"
|
||||
href="{% url 'authentication:dashboard' %}">
|
||||
<i class="fa fa-dashboard fa-fw grayiconecolor"></i>{% trans " Dashboard" %}
|
||||
</a>
|
||||
</li>
|
||||
@ -90,91 +92,24 @@
|
||||
<i class="fa fa-cogs fa-fw fa-sitemap grayiconecolor"></i>{% trans " Groups" %}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="{% navactive request 'authentication:help' %}" href="{% url 'authentication:help' %}">
|
||||
<i class="fa fa-question fa-fw grayiconecolor"></i>{% trans " Help" %}
|
||||
</a>
|
||||
</li>
|
||||
{% menu_main %}
|
||||
|
||||
|
||||
<li>
|
||||
<a class="{% navactive request 'auth_services' %}" href="{% url 'auth_services' %}">
|
||||
<i class="fa fa-cogs fa-fw grayiconecolor"></i>{% trans " Services" %}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a class="{% navactive request 'auth_hrapplications_view auth_hrapplication_create_view auth_hrapplication_personal_view auth_hrapplication_search auth_hrapplication_view' %}"
|
||||
href="{% url 'auth_hrapplications_view' %}">
|
||||
<i class="fa fa-file-o fa-fw grayiconecolor"></i>{% trans " Applications" %}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{% if perms.corputils.view_corp_corpstats or perms.corputils.view_alliance_corpstats or perms.corputils.view_blue_corpstats %}
|
||||
<li>
|
||||
<a class="{% navactive request 'corputils:' %}" href="{% url 'corputils:view' %}">
|
||||
<i class="fa fa-share-alt fa-fw grayiconecolor"></i>{% trans " Corporation Stats" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if can_manage_groups %}
|
||||
<li>
|
||||
<a class="{% navactive request 'auth_group_management auth_group_membership auth_group_membership_list' %}" href="{% url 'auth_group_management' %}">
|
||||
<a class="{% navactive request 'auth_group_management auth_group_membership auth_group_membership_list' %}"
|
||||
href="{% url 'auth_group_management' %}">
|
||||
<i class="fa fa-lock fa-sitemap fa-fw grayiconecolor"></i>{% trans " Group Management" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if perms.auth.view_fleetup %}
|
||||
<li>
|
||||
<a class="{% navactive request 'auth_fleetup_view auth_fleetup_fittings auth_fleetup_fitting auth_fleetup_doctrines auth_fleetup_doctrine auth_fleetup_characters' %}" href="{% url 'auth_fleetup_view' %}">
|
||||
<i class="fa fa-clock-o fa-fw grayiconecolor"></i> Fleet-Up
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if perms.auth.optimer_view %}
|
||||
<li>
|
||||
<a class="{% navactive request 'auth_optimer_view auth_add_optimer_view auth_edit_optimer' %}" href="{% url 'auth_optimer_view' %}">
|
||||
<i class="fa fa-exclamation fa-fw grayiconecolor"></i>{% trans " Fleet Operations" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if perms.auth.timer_view %}
|
||||
<li>
|
||||
<a class="{% navactive request 'auth_timer_view auth_add_timer_view auth_edit_timer' %}" href="{% url 'auth_timer_view' %}">
|
||||
<i class="fa fa-clock-o fa-fw grayiconecolor"></i>{% trans " Structure Timers" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% menu_items %}
|
||||
|
||||
<li>
|
||||
<a class="{% navactive request 'auth_fatlink_view auth_fatlink_view_statistics auth_fatlink_view_statistics_month auth_fatlink_view_personal_statistics auth_fatlink_view_personal_statistics_year auth_fatlink_view_personal_statistics_month auth_fatlink_view_user_statistics_month auth_create_fatlink_view auth_modify_fatlink_view auth_click_fatlink_view' %}" href="{% url 'auth_fatlink_view' %}">
|
||||
<i class="fa fa-users fa-lightbulb-o fa-fw grayiconecolor"></i>{% trans " Fleet Activity Tracking" %}
|
||||
<a class="{% navactive request 'authentication:help' %}"
|
||||
href="{% url 'authentication:help' %}">
|
||||
<i class="fa fa-question fa-fw grayiconecolor"></i>{% trans " Help" %}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{% if perms.srp.access_srp %}
|
||||
<li>
|
||||
<a class="{% navactive request 'auth_srp_management_view auth_srp_management_all_view auth_srp_fleet_view auth_srp_fleet_add_view auth_srp_fleet_edit_view auth_srp_request_view auth_srp_request_update_amount_view' %}" href="{% url 'auth_srp_management_view' %}">
|
||||
<i class="fa fa-money fa-fw grayiconecolor"></i>{% trans " Ship Replacement" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% menu_aux %}
|
||||
|
||||
{% if perms.auth.jabber_broadcast or perms.auth.jabber_broadcast_all or user.is_superuser %}
|
||||
<li>
|
||||
<a class="{% navactive request 'auth_fleet_format_tool_view' %}" href="{% url 'auth_fleet_format_tool_view' %}">
|
||||
<i class="fa fa-space-shuttle fa-fw grayiconecolor"></i>{% trans " Fleet Broadcast Formatter" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% menu_util %}
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
@ -188,11 +123,11 @@
|
||||
{% if messages %}
|
||||
<br>
|
||||
{% for message in messages %}
|
||||
<div class="alert alert-{{ message.level_tag}}">{{ message }}</div>
|
||||
<div class="alert alert-{{ message.level_tag }}">{{ message }}</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% block content %}
|
||||
{% endblock content %}
|
||||
{% block content %}
|
||||
{% endblock content %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
32
corputils/auth_hooks.py
Normal file
32
corputils/auth_hooks.py
Normal file
@ -0,0 +1,32 @@
|
||||
from services.hooks import MenuItemHook, UrlHook
|
||||
from alliance_auth import hooks
|
||||
from corputils import urls
|
||||
|
||||
|
||||
class CorpStats(MenuItemHook):
|
||||
def __init__(self):
|
||||
MenuItemHook.__init__(self,
|
||||
'Corporation Stats',
|
||||
'fa fa-share-alt fa-fw grayiconecolor',
|
||||
'corputils:view',
|
||||
navactive=['corputils:'])
|
||||
|
||||
def render(self, request):
|
||||
if request.user.has_perm('corputils.view_corp_corpstats') or request.user.has_perm('corputils.view_alliance_corpstats') or request.user.has_perm('corputils.add_corpstats'):
|
||||
return MenuItemHook.render(self, request)
|
||||
return ''
|
||||
|
||||
|
||||
@hooks.register('menu_item_hook')
|
||||
def register_menu():
|
||||
return CorpStats()
|
||||
|
||||
|
||||
class CorpStatsUrl(UrlHook):
|
||||
def __init__(self):
|
||||
UrlHook.__init__(self, urls, 'corputils', r'^corpstats/')
|
||||
|
||||
|
||||
@hooks.register('url_hook')
|
||||
def register_url():
|
||||
return CorpStatsUrl()
|
@ -2,7 +2,6 @@
|
||||
{% load i18n %}
|
||||
{% load humanize %}
|
||||
{% load bootstrap_pagination %}
|
||||
{% load eveonline_extras %}
|
||||
{% block member_data %}
|
||||
{% if corpstats %}
|
||||
<div class="row">
|
||||
|
@ -7,17 +7,9 @@
|
||||
|
||||
The menu hooks allow you to dynamically specify menu items from your plugin app or service. To achieve this you should subclass or instantiate the `services.hooks.MenuItemHook` class and then register the menu item with one of the hooks.
|
||||
|
||||
There are three levels of Menu Item Hooks
|
||||
|
||||
- `menu_main_hook`
|
||||
- `menu_aux_hook`
|
||||
- `menu_util_hook`
|
||||
|
||||
These represent the 3 levels of menu displayed on the site.
|
||||
|
||||
To register a MenuItemHook class you would do the following:
|
||||
|
||||
@hooks.register('menu_util_hook')
|
||||
@hooks.register('menu_item_hook')
|
||||
def register_menu():
|
||||
return MenuItemHook('Example Item', 'glyphicon glyphicon-heart', 'example_url_name', 150)
|
||||
|
||||
@ -34,5 +26,7 @@ The classes that should be applied to the bootstrap menu item icon
|
||||
The name of the Django URL to use
|
||||
#### order
|
||||
An integer which specifies the order of the menu item, lowest to highest
|
||||
#### navactive
|
||||
A list of views or namespaces the link should be highlighted on. See [django-navhelper](https://github.com/geelweb/django-navhelper#navactive) for usage. Defaults to the supplied `url_name`.
|
||||
|
||||
If you cannot get the menu item to look the way you wish, you are free to subclass and override the default render function and the template used.
|
||||
|
54
docs/development/url-hooks.md
Normal file
54
docs/development/url-hooks.md
Normal file
@ -0,0 +1,54 @@
|
||||
# URL Hooks
|
||||
|
||||
```eval_rst
|
||||
.. note::
|
||||
Currently most URL patterns are statically defined in the project's core urls.py file. Ideally this behaviour will change over time with each module of Alliance Auth providing all of its menu items via the hook. New modules should aim to use the hook over statically adding URL patterns to the project's patterns.
|
||||
```
|
||||
|
||||
The URL hooks allow you to dynamically specify URL patterns from your plugin app or service. To achieve this you should subclass or instantiate the `services.hooks.UrlHook` class and then register the URL patterns with the hook.
|
||||
|
||||
To register a UrlHook class you would do the following:
|
||||
|
||||
@hooks.register('url_hook')
|
||||
def register_urls():
|
||||
return UrlHook(app_name.urls, 'app_name', r^'app_name/')
|
||||
|
||||
|
||||
The `UrlHook` class specifies some parameters/instance variables required for URL pattern inclusion.
|
||||
|
||||
`UrlHook(urls, app_name, base_url)`
|
||||
|
||||
#### urls
|
||||
The urls module to include. See [the Django docs](https://docs.djangoproject.com/en/dev/topics/http/urls/#example) for designing urlpatterns.
|
||||
#### namespace
|
||||
The URL namespace to apply. This is usually just the app name.
|
||||
#### base_url
|
||||
The URL prefix to match against in regex form. Example `r'^app_name/'`. This prefix will be applied in front of all URL patterns included. It is possible to use the same prefix as existing apps (or no prefix at all) but [standard URL resolution](https://docs.djangoproject.com/en/dev/topics/http/urls/#how-django-processes-a-request) ordering applies (hook URLs are the last ones registered).
|
||||
|
||||
### Example
|
||||
|
||||
An app called `plugin` provides a single view:
|
||||
|
||||
def index(request):
|
||||
return render(request, 'plugin/index.html')
|
||||
|
||||
The app's `urls.py` would look like so:
|
||||
|
||||
from django.conf.urls import url
|
||||
import plugin.views
|
||||
|
||||
urlpatterns = [
|
||||
url(r^'index$', plugins.views.index, name='index'),
|
||||
]
|
||||
|
||||
Subsequently it would implement the UrlHook in a dedicated `auth_hooks.py` file like so:
|
||||
|
||||
from alliance_auth import hooks
|
||||
from services.hooks import UrlHook
|
||||
import plugin.urls
|
||||
|
||||
@hooks.register('url_hook')
|
||||
def register_urls():
|
||||
return UrlHook(plugin.urls, 'plugin', r^'plugin/')
|
||||
|
||||
When this app is included in the project's `settings.INSTALLED_APPS` users would access the index view by navigating to `https://example.com/plugin/index`.
|
14
fleetactivitytracking/auth_hooks.py
Normal file
14
fleetactivitytracking/auth_hooks.py
Normal file
@ -0,0 +1,14 @@
|
||||
from services.hooks import MenuItemHook, UrlHook
|
||||
from alliance_auth import hooks
|
||||
from fleetactivitytracking import urls
|
||||
|
||||
|
||||
@hooks.register('menu_item_hook')
|
||||
def register_menu():
|
||||
return MenuItemHook('Fleet Activity Tracking', 'fa fa-users fa-lightbulb-o fa-fw grayiconecolor', 'fatlink:view',
|
||||
navactive=['fatlink:'])
|
||||
|
||||
|
||||
@hooks.register('url_hook')
|
||||
def register_url():
|
||||
return UrlHook(urls, 'fatlink', r'^fat/')
|
@ -11,8 +11,8 @@
|
||||
<h1 class="page-header text-center">{% blocktrans %}Participation data statistics for {{ month }}, {{ year }}{% endblocktrans %}
|
||||
{% if char_id %}
|
||||
<div class="text-right">
|
||||
<a href="{% url 'auth_fatlink_view_user_statistics_month' char_id previous_month|date:"Y" previous_month|date:"m" %}" class="btn btn-info">{% trans "Previous month" %}</a>
|
||||
<a href="{% url 'auth_fatlink_view_user_statistics_month' char_id next_month|date:"Y" next_month|date:"m" %}" class="btn btn-info">{% trans "Next month" %}</a>
|
||||
<a href="{% url 'fatlink:user_statistics_month' char_id previous_month|date:"Y" previous_month|date:"m" %}" class="btn btn-info">{% trans "Previous month" %}</a>
|
||||
<a href="{% url 'fatlink:user_statistics_month' char_id next_month|date:"Y" next_month|date:"m" %}" class="btn btn-info">{% trans "Next month" %}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</h1>
|
||||
|
@ -10,9 +10,9 @@
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header text-center">{% blocktrans %}Participation data statistics for {{ year }}{% endblocktrans %}
|
||||
<div class="text-right">
|
||||
<a href="{% url 'auth_fatlink_view_personal_statistics_year' previous_year %}" class="btn btn-info">{% trans "Previous year" %}</a>
|
||||
<a href="{% url 'fatlink:personal_statistics_year' previous_year %}" class="btn btn-info">{% trans "Previous year" %}</a>
|
||||
{% if next_year %}
|
||||
<a href="{% url 'auth_fatlink_view_personal_statistics_year' next_year %}" class="btn btn-info">{% trans "Next year" %}</a>
|
||||
<a href="{% url 'fatlink:personal_statistics_year' next_year %}" class="btn btn-info">{% trans "Next year" %}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</h1>
|
||||
@ -25,7 +25,7 @@
|
||||
{% for monthnr, month, n_fats in monthlystats %}
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<a href="{% url 'auth_fatlink_view_personal_statistics_month' year monthnr %}">
|
||||
<a href="{% url 'fatlink:personal_statistics_month' year monthnr %}">
|
||||
{{ month }}
|
||||
</a>
|
||||
</td>
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "public/base.html" %}
|
||||
{% extends "registered/base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load staticfiles %}
|
||||
{% load i18n %}
|
||||
@ -10,9 +10,9 @@
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header text-center">{% blocktrans %}Participation data statistics for {{ month }}, {{ year }}{% endblocktrans %}
|
||||
<div class="text-right">
|
||||
<a href="{% url 'auth_fatlink_view_statistics_corp_month' corpid previous_month|date:"Y" previous_month|date:"m" %}" class="btn btn-info">{% trans "Previous month" %}</a>
|
||||
<a href="{% url 'fatlink:statistics_corp_month' corpid previous_month|date:"Y" previous_month|date:"m" %}" class="btn btn-info">{% trans "Previous month" %}</a>
|
||||
{% if next_month %}
|
||||
<a href="{% url 'auth_fatlink_view_statistics_corp_month' corpid next_month|date:"Y" next_month|date:"m" %}" class="btn btn-info">{% trans "Next month" %}</a>
|
||||
<a href="{% url 'fatlink:statistics_corp_month' corpid next_month|date:"Y" next_month|date:"m" %}" class="btn btn-info">{% trans "Next month" %}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</h1>
|
||||
|
@ -10,9 +10,9 @@
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header text-center">{% blocktrans %}Participation data statistics for {{ month }}, {{ year }}{% endblocktrans %}
|
||||
<div class="text-right">
|
||||
<a href="{% url 'auth_fatlink_view_statistics_month' previous_month|date:"Y" previous_month|date:"m" %}" class="btn btn-info">{% trans "Previous month" %}</a>
|
||||
<a href="{% url 'fatlink:statistics_month' previous_month|date:"Y" previous_month|date:"m" %}" class="btn btn-info">{% trans "Previous month" %}</a>
|
||||
{% if next_month %}
|
||||
<a href="{% url 'auth_fatlink_view_statistics_month' next_month|date:"Y" next_month|date:"m" %}" class="btn btn-info">{% trans "Next month" %}</a>
|
||||
<a href="{% url 'fatlink:statistics_month' next_month|date:"Y" next_month|date:"m" %}" class="btn btn-info">{% trans "Next month" %}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</h1>
|
||||
@ -33,7 +33,7 @@
|
||||
<td>
|
||||
<img src="https://image.eveonline.com/Corporation/{{ corpStat.corp.corporation_id }}_32.png" class="ra-avatar img-responsive">
|
||||
</td>
|
||||
<td class="text-center"><a href="{% url 'auth_fatlink_view_statistics_corp' corpStat.corp.corporation_id %}">[{{ corpStat.corp.corporation_ticker }}]</td>
|
||||
<td class="text-center"><a href="{% url 'fatlink:statistics_corp' corpStat.corp.corporation_id %}">[{{ corpStat.corp.corporation_ticker }}]</td>
|
||||
<td class="text-center">{{ corpStat.corp.corporation_name }}</td>
|
||||
<td class="text-center">{{ corpStat.corp.member_count }}</td>
|
||||
<td class="text-center">{{ corpStat.n_fats }}</td>
|
||||
|
@ -16,7 +16,7 @@
|
||||
</h4>
|
||||
</th>
|
||||
<th class="col-md-1">
|
||||
<a href="{% url 'auth_fatlink_view_personal_statistics' %}" class="btn btn-info">
|
||||
<a href="{% url 'fatlink:personal_statistics' %}" class="btn btn-info">
|
||||
{% trans "Personal statistics" %}
|
||||
</a>
|
||||
</th>
|
||||
@ -57,12 +57,12 @@
|
||||
</h4>
|
||||
</th>
|
||||
<th class="col-md-1">
|
||||
<a href="{% url 'auth_fatlink_view_statistics' %}" class="btn btn-info">
|
||||
<a href="{% url 'fatlink:statistics' %}" class="btn btn-info">
|
||||
{% trans "View statistics" %}
|
||||
</a>
|
||||
</th>
|
||||
<th class="col-md-1">
|
||||
<a href="{% url 'auth_create_fatlink_view' %}" class="btn btn-success">
|
||||
<a href="{% url 'fatlink:create' %}" class="btn btn-success">
|
||||
{% trans "Create fatlink" %}
|
||||
</a>
|
||||
</th>
|
||||
@ -80,13 +80,13 @@
|
||||
</tr>
|
||||
{% for link in fatlinks %}
|
||||
<tr>
|
||||
<td class="text-center"><a href="{% url 'auth_click_fatlink_view' %}{{ link.hash }}/{{ link.name }}">{{ link.name }}</a></td>
|
||||
<td class="text-center"><a href="{% url 'fatlink:click_fatlink' %}{{ link.hash }}/{{ link.name }}">{{ link.name }}</a></td>
|
||||
<td class="text-center">{{ link.creator.username }}</td>
|
||||
<td class="text-center">{{ link.fleet }}</td>
|
||||
<td class="text-center">{{ link.fatdatetime }}</td>
|
||||
<td class="text-center">{{ link.duration }}</td>
|
||||
<td class="text-center">
|
||||
<a href="{% url 'auth_modify_fatlink_view' %}{{ link.hash }}/{{ link.name }}" class="btn btn-info">
|
||||
<a href="{% url 'fatlink:modify' %}{{ link.hash }}/{{ link.name }}" class="btn btn-info">
|
||||
<span class="glyphicon glyphicon-edit"></span>
|
||||
</a>
|
||||
</td>
|
||||
|
32
fleetactivitytracking/urls.py
Normal file
32
fleetactivitytracking/urls.py
Normal file
@ -0,0 +1,32 @@
|
||||
from django.conf.urls import url
|
||||
import fleetactivitytracking.views
|
||||
|
||||
urlpatterns = [
|
||||
# FleetActivityTracking (FAT)
|
||||
url(r'^$', fleetactivitytracking.views.fatlink_view, name='view'),
|
||||
url(r'^statistics/$', fleetactivitytracking.views.fatlink_statistics_view, name='statistics'),
|
||||
url(r'^statistics/corp/(\w+)$', fleetactivitytracking.views.fatlink_statistics_corp_view,
|
||||
name='statistics_corp'),
|
||||
url(r'^statistics/corp/(?P<corpid>\w+)/(?P<year>[0-9]+)/(?P<month>[0-9]+)/',
|
||||
fleetactivitytracking.views.fatlink_statistics_corp_view,
|
||||
name='statistics_corp_month'),
|
||||
url(r'^statistics/(?P<year>[0-9]+)/(?P<month>[0-9]+)/$', fleetactivitytracking.views.fatlink_statistics_view,
|
||||
name='statistics_month'),
|
||||
url(r'^user/statistics/$', fleetactivitytracking.views.fatlink_personal_statistics_view,
|
||||
name='personal_statistics'),
|
||||
url(r'^user/statistics/(?P<year>[0-9]+)/$', fleetactivitytracking.views.fatlink_personal_statistics_view,
|
||||
name='personal_statistics_year'),
|
||||
url(r'^user/statistics/(?P<year>[0-9]+)/(?P<month>[0-9]+)/$',
|
||||
fleetactivitytracking.views.fatlink_monthly_personal_statistics_view,
|
||||
name='personal_statistics_month'),
|
||||
url(r'^user/(?P<char_id>[0-9]+)/statistics/(?P<year>[0-9]+)/(?P<month>[0-9]+)/$',
|
||||
fleetactivitytracking.views.fatlink_monthly_personal_statistics_view,
|
||||
name='user_statistics_month'),
|
||||
url(r'^create/$', fleetactivitytracking.views.create_fatlink_view, name='create'),
|
||||
url(r'^modify/$', fleetactivitytracking.views.modify_fatlink_view, name='modify'),
|
||||
url(r'^modify/(?P<hash>[a-zA-Z0-9_-]+)/([a-z0-9_-]+)$',
|
||||
fleetactivitytracking.views.modify_fatlink_view),
|
||||
url(r'^link/$', fleetactivitytracking.views.fatlink_view, name='click_fatlink'),
|
||||
url(r'^link/(?P<hash>[a-zA-Z0-9]+)/(?P<fatname>[a-z0-9_-]+)/$',
|
||||
fleetactivitytracking.views.click_fatlink_view),
|
||||
]
|
@ -10,10 +10,12 @@ from django.contrib import messages
|
||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
from eveonline.models import EveCharacter
|
||||
from eveonline.models import EveCorporationInfo
|
||||
from eveonline.models import EveAllianceInfo
|
||||
from eveonline.managers import EveManager
|
||||
from fleetactivitytracking.forms import FatlinkForm
|
||||
from fleetactivitytracking.models import Fatlink, Fat
|
||||
|
||||
from authentication.models import CharacterOwnership
|
||||
from django.contrib.auth.models import User
|
||||
from esi.decorators import token_required
|
||||
|
||||
from slugify import slugify
|
||||
@ -61,10 +63,10 @@ class MemberStat(object):
|
||||
self.mainchid = member.profile.main_character.character_id if member.profile.main_character else None
|
||||
self.mainchar = EveCharacter.objects.get(character_id=self.mainchid)
|
||||
nchars = 0
|
||||
for alliance_id in settings.STR_ALLIANCE_IDS:
|
||||
nchars += EveCharacter.objects.filter(user_id=member['user_id']).filter(alliance_id=alliance_id).count()
|
||||
for alliance in EveAllianceInfo.objects.all():
|
||||
nchars += EveCharacter.objects.filter(character_ownership__user=member).filter(alliance_id=alliance.alliance_id).count()
|
||||
self.n_chars = nchars
|
||||
self.n_fats = Fat.objects.filter(user_id=member['user_id']).filter(
|
||||
self.n_fats = Fat.objects.filter(user_id=member.pk).filter(
|
||||
fatlink__fatdatetime__gte=start_of_month).filter(fatlink__fatdatetime__lte=start_of_next_month).count()
|
||||
|
||||
def avg_fat(self):
|
||||
@ -118,11 +120,12 @@ def fatlink_statistics_corp_view(request, corpid, year=None, month=None):
|
||||
start_of_next_month = first_day_of_next_month(year, month)
|
||||
start_of_previous_month = first_day_of_previous_month(year, month)
|
||||
fat_stats = {}
|
||||
corp_members = EveCharacter.objects.filter(corporation_id=corpid).values('user_id').distinct()
|
||||
corp_members = CharacterOwnership.objects.filter(character__corporation_id=corpid).values('user_id').distinct()
|
||||
|
||||
for member in corp_members:
|
||||
print(member)
|
||||
try:
|
||||
fat_stats[member['user_id']] = MemberStat(member, start_of_month, start_of_next_month)
|
||||
fat_stats[member['user_id']] = MemberStat(User.objects.get(pk=member['user_id']), start_of_month, start_of_next_month)
|
||||
except ObjectDoesNotExist:
|
||||
continue
|
||||
|
||||
@ -255,12 +258,10 @@ def click_fatlink_view(request, token, hash, fatname):
|
||||
location['solar_system_name'] = \
|
||||
c.Universe.get_universe_systems_system_id(system_id=location['solar_system_id']).result()[
|
||||
'name']
|
||||
print(location)
|
||||
if location['station_id']:
|
||||
location['station_name'] = \
|
||||
c.Universe.get_universe_stations_station_id(station_id=location['station_id']).result()['name']
|
||||
elif location['structure_id']:
|
||||
print('HERE')
|
||||
c = token.get_esi_client(Universe='v1')
|
||||
location['station_name'] = \
|
||||
c.Universe.get_universe_structures_structure_id(structure_id=location['structure_id']).result()[
|
||||
@ -291,7 +292,7 @@ def click_fatlink_view(request, token, hash, fatname):
|
||||
return render(request, 'fleetactivitytracking/characternotexisting.html', context=context)
|
||||
else:
|
||||
messages.error(request, _('FAT link has expired.'))
|
||||
return redirect(fatlink_view)
|
||||
return redirect('fatlink:view')
|
||||
|
||||
|
||||
@login_required
|
||||
@ -324,8 +325,8 @@ def create_fatlink_view(request):
|
||||
else:
|
||||
form = FatlinkForm()
|
||||
context = {'form': form, 'badrequest': True}
|
||||
return render(request, 'registered/fatlinkformatter.html', context=context)
|
||||
return redirect('auth_fatlink_view')
|
||||
return render(request, 'fleetactivitytracking/fatlinkformatter.html', context=context)
|
||||
return redirect('fatlink:view')
|
||||
|
||||
else:
|
||||
form = FatlinkForm()
|
||||
@ -341,7 +342,7 @@ def create_fatlink_view(request):
|
||||
def modify_fatlink_view(request, hash=""):
|
||||
logger.debug("modify_fatlink_view called by user %s" % request.user)
|
||||
if not hash:
|
||||
return redirect('auth_fatlink_view')
|
||||
return redirect('fatlink:view')
|
||||
|
||||
fatlink = Fatlink.objects.filter(hash=hash)[0]
|
||||
|
||||
@ -355,7 +356,7 @@ def modify_fatlink_view(request, hash=""):
|
||||
if request.GET.get('deletefat', None):
|
||||
logger.debug("Removing fleetactivitytracking %s" % fatlink.name)
|
||||
fatlink.delete()
|
||||
return redirect('auth_fatlink_view')
|
||||
return redirect('fatlink:view')
|
||||
|
||||
registered_fats = Fat.objects.filter(fatlink=fatlink).order_by('character__character_name')
|
||||
|
||||
|
26
fleetup/auth_hooks.py
Normal file
26
fleetup/auth_hooks.py
Normal file
@ -0,0 +1,26 @@
|
||||
from services.hooks import MenuItemHook, UrlHook
|
||||
from alliance_auth import hooks
|
||||
from fleetup import urls
|
||||
|
||||
|
||||
class FleetUpMenu(MenuItemHook):
|
||||
def __init__(self):
|
||||
MenuItemHook.__init__(self, 'Fleet-Up',
|
||||
'fa fa-arrow-up fa-fw grayiconecolor',
|
||||
'fleetup:view',
|
||||
navactive=['fleetup:'])
|
||||
|
||||
def render(self, request):
|
||||
if request.user.has_perm('auth.view_fleetup'):
|
||||
return MenuItemHook.render(self, request)
|
||||
return ''
|
||||
|
||||
|
||||
@hooks.register('menu_item_hook')
|
||||
def register_menu():
|
||||
return FleetUpMenu()
|
||||
|
||||
|
||||
@hooks.register('url_hook')
|
||||
def register_url():
|
||||
return UrlHook(urls, 'fleetup', r'^fleetup/')
|
@ -33,7 +33,7 @@
|
||||
{% for item in Role.list %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url 'auth_fleetup_fitting' item.FittingId %}"><img src="https://image.eveonline.com/InventoryType/{{ item.EveTypeId }}_32.png"></a>
|
||||
<a href="{% url 'fleetup:fitting' item.FittingId %}"><img src="https://image.eveonline.com/InventoryType/{{ item.EveTypeId }}_32.png"></a>
|
||||
</td>
|
||||
<td>
|
||||
{{ item.Name }}
|
||||
|
@ -33,13 +33,13 @@
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url 'auth_fleetup_doctrine' item.DoctrineId %}"><img src="https://image.eveonline.com/InventoryType/{{ item.IconId }}_32.png"></a>
|
||||
<a href="{% url 'fleetup:doctrine' item.DoctrineId %}"><img src="https://image.eveonline.com/InventoryType/{{ item.IconId }}_32.png"></a>
|
||||
</td>
|
||||
<td>
|
||||
{{ item.Name }}
|
||||
</td>
|
||||
<td>
|
||||
<a href="{% url 'auth_fleetup_doctrine' item.DoctrineId %}" class="btn btn-info btn-sm">{{ item.FolderName }}</a>
|
||||
<a href="{% url 'fleetup:doctrine' item.DoctrineId %}" class="btn btn-info btn-sm">{{ item.FolderName }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ item.LastUpdatedString }}
|
||||
|
@ -34,7 +34,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<a class="btn btn-primary" href="{% url 'auth_fleetup_doctrine' doctrin.DoctrineId %}">{% trans "See doctrine" %}</a>
|
||||
<a class="btn btn-primary" href="{% url 'fleetup:doctrine' doctrin.DoctrineId %}">{% trans "See doctrine" %}</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
@ -59,7 +59,7 @@
|
||||
{% for arbit, orbit in doctrines_list.items %}
|
||||
|
||||
{% for fitting in orbit.Data %}
|
||||
<a href="{% url 'auth_fleetup_fitting' fitting.FittingId %}" class="list-group-item">
|
||||
<a href="{% url 'fleetup:fitting' fitting.FittingId %}" class="list-group-item">
|
||||
|
||||
<h4 class="list-group-item-heading">{{ fitting.Name }}<span class="pull-right"><img src="https://image.eveonline.com/InventoryType/{{ fitting.EveTypeId }}_32.png" class="img-circle"></span></h4>
|
||||
<p class="list-group-item-heading">{{ fitting.Role }} - {{ fitting.ShipType }}</p>
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url 'auth_fleetup_fitting' fittings.fitting_id %}"><img src="https://image.eveonline.com/InventoryType/{{ fittings.icon_id }}_32.png"></a>
|
||||
<a href="{% url 'fleetup:fitting' fittings.fitting_id %}"><img src="https://image.eveonline.com/InventoryType/{{ fittings.icon_id }}_32.png"></a>
|
||||
</td>
|
||||
<td>
|
||||
{{ fittings.name }}
|
||||
|
@ -62,7 +62,7 @@
|
||||
{% if start.doctrine %}
|
||||
{% for doctrine in start.doctrine %}
|
||||
|
||||
<a href="{% url 'auth_fleetup_doctrine' doctrine.Id %}" class="label label-success">{{ doctrine.Name }}</a>
|
||||
<a href="{% url 'fleetup:doctrine' doctrine.Id %}" class="label label-success">{{ doctrine.Name }}</a>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
|
@ -14,11 +14,11 @@
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="{% navactive request 'auth_fleetup_view' %}"><a href="{% url 'auth_fleetup_view' %}">{% trans "Ops and Timers" %}</a></li>
|
||||
<li class="{% navactive request 'auth_fleetup_doctrines auth_fleetup_doctrine' %}"><a href="{% url 'auth_fleetup_doctrines' %}">{% trans "Doctrines" %}</a></li>
|
||||
<li class="{% navactive request 'auth_fleetup_fittings auth_fleetup_fitting' %}"><a href="{% url 'auth_fleetup_fittings' %}">{% trans "Fittings" %}</a></li>
|
||||
<li class="{% navactive request 'fleetup:view' %}"><a href="{% url 'fleetup:view' %}">{% trans "Ops and Timers" %}</a></li>
|
||||
<li class="{% navactive request 'fleetup:doctrines fleetup:doctrine' %}"><a href="{% url 'fleetup:doctrines' %}">{% trans "Doctrines" %}</a></li>
|
||||
<li class="{% navactive request 'fleetup:fittings fleetup:fitting' %}"><a href="{% url 'fleetup:fittings' %}">{% trans "Fittings" %}</a></li>
|
||||
{% if perms.auth.corp_stats %}
|
||||
<li class="{% navactive request 'auth_fleetup_characters' %}"><a href="{% url 'auth_fleetup_characters' %}">{% trans "Characters" %}</a></li>
|
||||
<li class="{% navactive request 'fleetup:characters' %}"><a href="{% url 'fleetup:characters' %}">{% trans "Characters" %}</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -3,11 +3,13 @@ from django.conf.urls import url
|
||||
|
||||
from . import views
|
||||
|
||||
app_name = 'fleetup'
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.fleetup_view, name='auth_fleetup_view'),
|
||||
url(r'^fittings/$', views.fleetup_fittings, name='auth_fleetup_fittings'),
|
||||
url(r'^fittings/(?P<fittingnumber>[0-9]+)/$', views.fleetup_fitting, name='auth_fleetup_fitting'),
|
||||
url(r'^doctrines/$', views.fleetup_doctrines, name='auth_fleetup_doctrines'),
|
||||
url(r'^characters/$', views.fleetup_characters, name='auth_fleetup_characters'),
|
||||
url(r'^doctrines/(?P<doctrinenumber>[0-9]+)/$', views.fleetup_doctrine, name='auth_fleetup_doctrine'),
|
||||
url(r'^$', views.fleetup_view, name='view'),
|
||||
url(r'^fittings/$', views.fleetup_fittings, name='fittings'),
|
||||
url(r'^fittings/(?P<fittingnumber>[0-9]+)/$', views.fleetup_fitting, name='fitting'),
|
||||
url(r'^doctrines/$', views.fleetup_doctrines, name='doctrines'),
|
||||
url(r'^characters/$', views.fleetup_characters, name='characters'),
|
||||
url(r'^doctrines/(?P<doctrinenumber>[0-9]+)/$', views.fleetup_doctrine, name='doctrine'),
|
||||
]
|
||||
|
27
hrapplications/auth_hooks.py
Normal file
27
hrapplications/auth_hooks.py
Normal file
@ -0,0 +1,27 @@
|
||||
from services.hooks import MenuItemHook, UrlHook
|
||||
from alliance_auth import hooks
|
||||
from hrapplications import urls
|
||||
|
||||
|
||||
class ApplicationsMenu(MenuItemHook):
|
||||
def __init__(self):
|
||||
MenuItemHook.__init__(self,
|
||||
'Applications',
|
||||
'fa fa-file-o fa-fw grayiconecolor',
|
||||
'hrapplications:index',
|
||||
navactive=['hrapplications:'])
|
||||
|
||||
|
||||
@hooks.register('menu_item_hook')
|
||||
def register_menu():
|
||||
return ApplicationsMenu()
|
||||
|
||||
|
||||
class ApplicationsUrls(UrlHook):
|
||||
def __init__(self):
|
||||
UrlHook.__init__(self, urls, 'hrapplications', r'^hr/')
|
||||
|
||||
|
||||
@hooks.register('url_hook')
|
||||
def register_url():
|
||||
return ApplicationsUrls()
|
@ -14,7 +14,7 @@
|
||||
{% for choice in choices %}
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<a href="{% url 'auth_hrapplication_create_view' choice.0 %}" class="btn btn-primary" title="Apply">{{ choice.1 }}</a>
|
||||
<a href="{% url 'hrapplications:create_view' choice.0 %}" class="btn btn-primary" title="Apply">{{ choice.1 }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
12
stock/templates/registered/hrapplicationmanagement.html → hrapplications/templates/hrapplications/management.html
Executable file → Normal file
12
stock/templates/registered/hrapplicationmanagement.html → hrapplications/templates/hrapplications/management.html
Executable file → Normal file
@ -13,7 +13,7 @@
|
||||
<h1 class="page-header text-center">{% trans "Personal Applications" %}
|
||||
<div class="text-right">
|
||||
{% if create %}
|
||||
<a href="{% url 'auth_hrapplication_create_view' %}">
|
||||
<a href="{% url 'hrapplications:create_view' %}">
|
||||
<button type="button" class="btn btn-success">{% trans "Create Application" %}</button>
|
||||
</a>
|
||||
{% else %}
|
||||
@ -44,13 +44,13 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href="{% url 'auth_hrapplication_personal_view' personal_app.id %}"
|
||||
<a href="{% url 'hrapplications:personal_view' personal_app.id %}"
|
||||
class="btn btn-primary">
|
||||
<span class="glyphicon glyphicon-eye-open"></span>
|
||||
</a>
|
||||
|
||||
{% if personal_app.approved == None %}
|
||||
<a href="{% url 'auth_hrapplication_personal_removal' personal_app.id %}"
|
||||
<a href="{% url 'hrapplications:personal_removal' personal_app.id %}"
|
||||
class="btn btn-danger">
|
||||
<span class="glyphicon glyphicon-remove"></span>
|
||||
</a>
|
||||
@ -107,7 +107,7 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href="{% url 'auth_hrapplication_view' app.id %}"
|
||||
<a href="{% url 'hrapplications:view' app.id %}"
|
||||
class="btn btn-primary">
|
||||
<span class="glyphicon glyphicon-eye-open"></span>
|
||||
</a>
|
||||
@ -152,7 +152,7 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href="{% url 'auth_hrapplication_view' app.id %}"
|
||||
<a href="{% url 'hrapplications:view' app.id %}"
|
||||
class="btn btn-primary">
|
||||
<span class="glyphicon glyphicon-eye-open"></span>
|
||||
</a>
|
||||
@ -182,7 +182,7 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-signin" role="form"
|
||||
action={% url 'auth_hrapplication_search' %} method="POST">
|
||||
action={% url 'hrapplications:search' %} method="POST">
|
||||
{% csrf_token %}
|
||||
{{ search_form|bootstrap }}
|
||||
<br/>
|
4
stock/templates/registered/hrapplicationsearchview.html → hrapplications/templates/hrapplications/searchview.html
Executable file → Normal file
4
stock/templates/registered/hrapplicationsearchview.html → hrapplications/templates/hrapplications/searchview.html
Executable file → Normal file
@ -45,7 +45,7 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href="{% url 'auth_hrapplication_view' app.id %}" class="btn btn-primary">
|
||||
<a href="{% url 'hrapplications:view' app.id %}" class="btn btn-primary">
|
||||
<span class="glyphicon glyphicon-eye-open"></span>
|
||||
</a>
|
||||
</td>
|
||||
@ -69,7 +69,7 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-signin" role="form"
|
||||
action={% url 'auth_hrapplication_search' %} method="POST">
|
||||
action={% url 'hrapplications:search' %} method="POST">
|
||||
{% csrf_token %}
|
||||
{{ search_form|bootstrap }}
|
||||
<br/>
|
@ -79,19 +79,19 @@
|
||||
{% if app.approved == None %}
|
||||
{% if app.reviewer == user %}
|
||||
{% if perms.hrapplications.approve_application %}
|
||||
<a href="{% url 'auth_hrapplication_approve' app.id %}"
|
||||
<a href="{% url 'hrapplications:approve' app.id %}"
|
||||
class="btn btn-success">{% trans "Approve" %}</a>
|
||||
{% endif %}
|
||||
{% if perms.hrapplications.reject_application %}
|
||||
<a href="{% url 'auth_hrapplication_reject' app.id %}"
|
||||
<a href="{% url 'hrapplications:reject' app.id %}"
|
||||
class="btn btn-danger">{% trans "Reject" %}</a>
|
||||
{% endif %}
|
||||
{% if perms.hrapplications.delete_application %}
|
||||
<a href="{% url 'auth_hrapplication_remove' app.id %}"
|
||||
<a href="{% url 'hrapplications:remove' app.id %}"
|
||||
class="btn btn-danger">{% trans "Delete" %}</a>
|
||||
{% endif %}
|
||||
{% elif not app.reviewer %}
|
||||
<a href="{% url 'auth_hrapplication_mark_in_progress' app.id %}"
|
||||
<a href="{% url 'hrapplications:mark_in_progress' app.id %}"
|
||||
class="btn btn-warning">{% trans "Mark in Progress" %}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
30
hrapplications/urls.py
Normal file
30
hrapplications/urls.py
Normal file
@ -0,0 +1,30 @@
|
||||
from django.conf.urls import url
|
||||
import hrapplications.views
|
||||
|
||||
app_name = 'hrapplications'
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', hrapplications.views.hr_application_management_view,
|
||||
name="index"),
|
||||
url(r'^create/$', hrapplications.views.hr_application_create_view,
|
||||
name="create_view"),
|
||||
url(r'^create/(\d+)', hrapplications.views.hr_application_create_view,
|
||||
name="create_view"),
|
||||
url(r'^remove/(\w+)', hrapplications.views.hr_application_remove,
|
||||
name="remove"),
|
||||
url(r'view/(\w+)', hrapplications.views.hr_application_view,
|
||||
name="view"),
|
||||
url(r'personal/view/(\w+)', hrapplications.views.hr_application_personal_view,
|
||||
name="personal_view"),
|
||||
url(r'personal/removal/(\w+)',
|
||||
hrapplications.views.hr_application_personal_removal,
|
||||
name="personal_removal"),
|
||||
url(r'approve/(\w+)', hrapplications.views.hr_application_approve,
|
||||
name="approve"),
|
||||
url(r'reject/(\w+)', hrapplications.views.hr_application_reject,
|
||||
name="reject"),
|
||||
url(r'search/', hrapplications.views.hr_application_search,
|
||||
name="search"),
|
||||
url(r'mark_in_progress/(\w+)', hrapplications.views.hr_application_mark_in_progress,
|
||||
name="mark_in_progress"),
|
||||
]
|
@ -10,7 +10,6 @@ from hrapplications.models import ApplicationResponse
|
||||
from hrapplications.models import ApplicationComment
|
||||
from hrapplications.forms import HRApplicationCommentForm
|
||||
from hrapplications.forms import HRApplicationSearchForm
|
||||
from eveonline.models import EveCharacter
|
||||
|
||||
import logging
|
||||
|
||||
@ -44,7 +43,7 @@ def hr_application_management_view(request):
|
||||
'search_form': HRApplicationSearchForm(),
|
||||
'create': create_application_test(request.user)
|
||||
}
|
||||
return render(request, 'registered/hrapplicationmanagement.html', context=context)
|
||||
return render(request, 'hrapplications/management.html', context=context)
|
||||
|
||||
|
||||
@login_required
|
||||
@ -67,14 +66,14 @@ def hr_application_create_view(request, form_id=None):
|
||||
return redirect('auth_hrapplications_view')
|
||||
else:
|
||||
questions = app_form.questions.all()
|
||||
return render(request, 'registered/hrapplicationcreate.html',
|
||||
return render(request, 'hrapplications/create.html',
|
||||
context={'questions': questions, 'corp': app_form.corp})
|
||||
else:
|
||||
choices = []
|
||||
for app_form in ApplicationForm.objects.all():
|
||||
if not Application.objects.filter(user=request.user).filter(form=app_form).exists():
|
||||
choices.append((app_form.id, app_form.corp.corporation_name))
|
||||
return render(request, 'registered/hrapplicationcorpchoice.html', context={'choices': choices})
|
||||
return render(request, 'hrapplications/corpchoice.html', context={'choices': choices})
|
||||
|
||||
|
||||
@login_required
|
||||
@ -89,7 +88,7 @@ def hr_application_personal_view(request, app_id):
|
||||
'comments': ApplicationComment.objects.filter(application=app),
|
||||
'comment_form': HRApplicationCommentForm(),
|
||||
}
|
||||
return render(request, 'registered/hrapplicationview.html', context=context)
|
||||
return render(request, 'hrapplications/view.html', context=context)
|
||||
else:
|
||||
logger.warn("User %s not authorized to view %s" % (request.user, app))
|
||||
return redirect('auth_hrapplications_view')
|
||||
@ -140,7 +139,7 @@ def hr_application_view(request, app_id):
|
||||
'comments': ApplicationComment.objects.filter(application=app),
|
||||
'comment_form': form,
|
||||
}
|
||||
return render(request, 'registered/hrapplicationview.html', context=context)
|
||||
return render(request, 'hrapplications/view.html', context=context)
|
||||
|
||||
|
||||
@login_required
|
||||
@ -232,11 +231,11 @@ def hr_application_search(request):
|
||||
|
||||
context = {'applications': applications, 'search_form': HRApplicationSearchForm()}
|
||||
|
||||
return render(request, 'registered/hrapplicationsearchview.html', context=context)
|
||||
return render(request, 'hrapplications/searchview.html', context=context)
|
||||
else:
|
||||
logger.debug("Form invalid - returning for user %s to retry." % request.user)
|
||||
context = {'applications': None, 'search_form': form}
|
||||
return render(request, 'registered/hrapplicationsearchview.html', context=context)
|
||||
return render(request, 'hrapplications/searchview.html', context=context)
|
||||
|
||||
else:
|
||||
logger.debug("Returning empty search form for user %s" % request.user)
|
||||
@ -258,4 +257,4 @@ def hr_application_mark_in_progress(request, app_id):
|
||||
else:
|
||||
logger.warn(
|
||||
"User %s unable to mark %s in progress: already being reviewed by %s" % (request.user, app, app.reviewer))
|
||||
return redirect("auth_hrapplication_view", app_id)
|
||||
return redirect("hrapplications:view", app_id)
|
||||
|
26
optimer/auth_hooks.py
Normal file
26
optimer/auth_hooks.py
Normal file
@ -0,0 +1,26 @@
|
||||
from services.hooks import MenuItemHook, UrlHook
|
||||
from alliance_auth import hooks
|
||||
from optimer import urls
|
||||
|
||||
|
||||
class OpTimerboardMenu(MenuItemHook):
|
||||
def __init__(self):
|
||||
MenuItemHook.__init__(self, 'Fleet Operations',
|
||||
'fa fa-exclamation fa-fw grayiconecolor',
|
||||
'optimer:view',
|
||||
navactive=['optimer:'])
|
||||
|
||||
def render(self, request):
|
||||
if request.user.has_perm('auth.optimer_view'):
|
||||
return MenuItemHook.render(self, request)
|
||||
return ''
|
||||
|
||||
|
||||
@hooks.register('menu_item_hook')
|
||||
def register_menu():
|
||||
return OpTimerboardMenu()
|
||||
|
||||
|
||||
@hooks.register('url_hook')
|
||||
def register_url():
|
||||
return UrlHook(urls, 'optimer', r'^optimer/')
|
@ -1,46 +1,46 @@
|
||||
{% extends "registered/base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load staticfiles %}
|
||||
{% load i18n %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
|
||||
{% block title %}{% trans "Alliance Auth - Fleet Operation Create" %}{% endblock %}
|
||||
|
||||
{% block page_title %}{% trans "Create Operation" %}{% endblock page_title %}
|
||||
{% block extra_css %}
|
||||
{% include 'bundles/jquery-datetimepicker-css.html' %}
|
||||
{% endblock extra_css %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header text-center">{% trans "Create Fleet Operation" %}</h1>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="col-md-4 col-md-offset-4">
|
||||
<div class="row">
|
||||
<form class="form-signin" role="form" action="" method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form|bootstrap }}
|
||||
<br/>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">{% trans "Create Fleet Operation" %}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock content %}
|
||||
|
||||
{% block extra_javascript %}
|
||||
{% include 'bundles/jquery-datetimepicker-js.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
|
||||
$('#id_start').datetimepicker({
|
||||
lang: '{{ LANGUAGE_CODE }}',
|
||||
maskInput: true,
|
||||
format: 'Y-m-d H:i',minDate:0
|
||||
});
|
||||
|
||||
{% endblock extra_script %}
|
||||
{% extends "registered/base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load staticfiles %}
|
||||
{% load i18n %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
|
||||
{% block title %}{% trans "Alliance Auth - Fleet Operation Create" %}{% endblock %}
|
||||
|
||||
{% block page_title %}{% trans "Create Operation" %}{% endblock page_title %}
|
||||
{% block extra_css %}
|
||||
{% include 'bundles/jquery-datetimepicker-css.html' %}
|
||||
{% endblock extra_css %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header text-center">{% trans "Create Fleet Operation" %}</h1>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="col-md-4 col-md-offset-4">
|
||||
<div class="row">
|
||||
<form class="form-signin" role="form" action="" method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form|bootstrap }}
|
||||
<br/>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">{% trans "Create Fleet Operation" %}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock content %}
|
||||
|
||||
{% block extra_javascript %}
|
||||
{% include 'bundles/jquery-datetimepicker-js.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
|
||||
$('#id_start').datetimepicker({
|
||||
lang: '{{ LANGUAGE_CODE }}',
|
||||
maskInput: true,
|
||||
format: 'Y-m-d H:i',minDate:0
|
||||
});
|
||||
|
||||
{% endblock extra_script %}
|
@ -32,9 +32,9 @@
|
||||
{% if perms.auth.optimer_management %}
|
||||
<td class="text-center">{{ ops.eve_character }}</td>
|
||||
<td class="text-center">
|
||||
<a href="{% url 'auth_remove_optimer' ops.id %}" class="btn btn-danger">
|
||||
<a href="{% url 'optimer:remove' ops.id %}" class="btn btn-danger">
|
||||
<span class="glyphicon glyphicon-remove"></span>
|
||||
</a><a href="{% url 'auth_edit_optimer' ops.id %}" class="btn btn-info"><span class="glyphicon glyphicon-pencil"></span></a>
|
||||
</a><a href="{% url 'optimer:edit' ops.id %}" class="btn btn-info"><span class="glyphicon glyphicon-pencil"></span></a>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
@ -13,7 +13,7 @@
|
||||
<h1 class="page-header text-center">{% trans "Fleet Operation Timers" %}
|
||||
<div class="text-right">
|
||||
{% if perms.auth.optimer_management %}
|
||||
<a href="{% url 'auth_add_optimer_view' %}" class="btn btn-success">{% trans "Create Operation" %}</a>
|
||||
<a href="{% url 'optimer:add' %}" class="btn btn-success">{% trans "Create Operation" %}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</h1>
|
||||
@ -27,14 +27,14 @@
|
||||
|
||||
<h4><b>{% trans "Next Timers" %}</b></h4>
|
||||
{% if future_timers %}
|
||||
{% include "registered/fleetoptable.html" with timers=future_timers %}
|
||||
{% include "optimer/fleetoptable.html" with timers=future_timers %}
|
||||
{% else %}
|
||||
<div class="alert alert-warning text-center">{% trans "No upcoming timers." %}</div>
|
||||
{% endif %}
|
||||
|
||||
<h4><b>{% trans "Past Timers" %}</b></h4>
|
||||
{% if past_timers %}
|
||||
{% include "registered/fleetoptable.html" with timers=past_timers %}
|
||||
{% include "optimer/fleetoptable.html" with timers=past_timers %}
|
||||
{% else %}
|
||||
<div class="alert alert-warning text-center">{% trans "No past timers." %}</div>
|
||||
{% endif %}
|
0
stock/templates/registered/optimerupdate.html → optimer/templates/optimer/update.html
Executable file → Normal file
0
stock/templates/registered/optimerupdate.html → optimer/templates/optimer/update.html
Executable file → Normal file
11
optimer/urls.py
Normal file
11
optimer/urls.py
Normal file
@ -0,0 +1,11 @@
|
||||
from django.conf.urls import url
|
||||
import optimer.views
|
||||
|
||||
app_name = 'optimer'
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', optimer.views.optimer_view, name='view'),
|
||||
url(r'^add$', optimer.views.add_optimer_view, name='add'),
|
||||
url(r'^(\w+)/remove$', optimer.views.remove_optimer, name='remove'),
|
||||
url(r'^(\w+)/edit$', optimer.views.edit_optimer, name='edit'),
|
||||
]
|
@ -24,7 +24,7 @@ def optimer_view(request):
|
||||
'past_timers': OpTimer.objects.all().filter(
|
||||
start__lt=timezone.now()).order_by('-start')}
|
||||
|
||||
return render(request, 'registered/operationmanagement.html', context=render_items)
|
||||
return render(request, 'optimer/management.html', context=render_items)
|
||||
|
||||
|
||||
@login_required
|
||||
@ -52,14 +52,14 @@ def add_optimer_view(request):
|
||||
op.save()
|
||||
logger.info("User %s created op timer with name %s" % (request.user, op.operation_name))
|
||||
messages.success(request, _('Created operation timer for %(opname)s.') % {"opname": op.operation_name})
|
||||
return redirect("/optimer/")
|
||||
return redirect("optimer:view")
|
||||
else:
|
||||
logger.debug("Returning new opForm")
|
||||
form = OpForm()
|
||||
|
||||
render_items = {'form': form}
|
||||
|
||||
return render(request, 'registered/addoperation.html', context=render_items)
|
||||
return render(request, 'optimer/add.html', context=render_items)
|
||||
|
||||
|
||||
@login_required
|
||||
@ -70,7 +70,7 @@ def remove_optimer(request, optimer_id):
|
||||
op.delete()
|
||||
logger.info("Deleting optimer id %s by user %s" % (optimer_id, request.user))
|
||||
messages.success(request, _('Removed operation timer for %(opname)s.') % {"opname": op.operation_name})
|
||||
return redirect("auth_optimer_view")
|
||||
return redirect("optimer:view")
|
||||
|
||||
|
||||
@login_required
|
||||
@ -93,7 +93,7 @@ def edit_optimer(request, optimer_id):
|
||||
logger.info("User %s updating optimer id %s " % (request.user, optimer_id))
|
||||
op.save()
|
||||
messages.success(request, _('Saved changes to operation timer for %(opname)s.') % {"opname": op.operation_name})
|
||||
return redirect("auth_optimer_view")
|
||||
return redirect("optimer:view")
|
||||
else:
|
||||
data = {
|
||||
'doctrine': op.doctrine,
|
||||
@ -104,4 +104,4 @@ def edit_optimer(request, optimer_id):
|
||||
'fc': op.fc,
|
||||
}
|
||||
form = OpForm(initial=data)
|
||||
return render(request, 'registered/optimerupdate.html', context={'form': form})
|
||||
return render(request, 'optimer/update.html', context={'form': form})
|
||||
|
@ -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/')
|
||||
|
@ -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>
|
||||
|
@ -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'),
|
||||
]
|
||||
|
22
services/auth_hooks.py
Normal file
22
services/auth_hooks.py
Normal file
@ -0,0 +1,22 @@
|
||||
from services.hooks import MenuItemHook
|
||||
from alliance_auth import hooks
|
||||
from services.hooks import ServicesHook
|
||||
|
||||
|
||||
class Services(MenuItemHook):
|
||||
def __init__(self):
|
||||
MenuItemHook.__init__(self,
|
||||
'Services',
|
||||
'fa fa-cogs fa-fw grayiconecolor',
|
||||
'auth_services', 100)
|
||||
|
||||
def render(self, request):
|
||||
for svc in ServicesHook.get_services():
|
||||
if svc.service_active_for_user(request.user):
|
||||
return MenuItemHook.render(self, request)
|
||||
return ''
|
||||
|
||||
|
||||
@hooks.register('menu_item_hook')
|
||||
def register_menu():
|
||||
return Services()
|
@ -1,7 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
from django.conf.urls import include, url
|
||||
from alliance_auth.hooks import get_hooks
|
||||
|
||||
|
||||
@ -104,14 +104,22 @@ class ServicesHook:
|
||||
|
||||
|
||||
class MenuItemHook:
|
||||
def __init__(self, text, classes, url_name, order=None):
|
||||
def __init__(self, text, classes, url_name, order=None, navactive=list([])):
|
||||
self.text = text
|
||||
self.classes = classes
|
||||
self.url_name = url_name
|
||||
self.template = 'public/menuitem.html'
|
||||
self.order = order if order is not None else 9999
|
||||
navactive = navactive or []
|
||||
navactive.append(url_name)
|
||||
self.navactive = navactive
|
||||
|
||||
def render(self, request):
|
||||
return render_to_string(self.template,
|
||||
{'item': self},
|
||||
request=request)
|
||||
|
||||
|
||||
class UrlHook:
|
||||
def __init__(self, urls, namespace, base_url):
|
||||
self.include_pattern = url(base_url, include(urls, namespace=namespace))
|
||||
|
@ -81,11 +81,29 @@ class JabberBroadcast(MenuItemHook):
|
||||
'auth_jabber_broadcast_view')
|
||||
|
||||
def render(self, request):
|
||||
if request.user.has_perm('auth.jabber_broadcast'):
|
||||
if request.user.has_perm('auth.jabber_broadcast') or request.user.has_perm('auth.jabber_broadcast_all'):
|
||||
return MenuItemHook.render(self, request)
|
||||
return ''
|
||||
|
||||
|
||||
@hooks.register('menu_util_hook')
|
||||
class FleetBroadcastFormatter(MenuItemHook):
|
||||
def __init__(self):
|
||||
MenuItemHook.__init__(self,
|
||||
'Fleet Broadcast Formatter',
|
||||
'fa fa-lock fa-fw fa-space-shuttle grayiconecolor',
|
||||
'auth_fleet_format_tool_view')
|
||||
|
||||
def render(self, request):
|
||||
if request.user.has_perm('auth.jabber_broadcast') or request.user.has_perm('auth.jabber_broadcast_all'):
|
||||
return MenuItemHook.render(self, request)
|
||||
return ''
|
||||
|
||||
|
||||
@hooks.register('menu_item_hook')
|
||||
def register_formatter():
|
||||
return FleetBroadcastFormatter()
|
||||
|
||||
|
||||
@hooks.register('menu_item_hook')
|
||||
def register_menu():
|
||||
return JabberBroadcast()
|
||||
|
@ -2,7 +2,7 @@
|
||||
{% load navactive %}
|
||||
|
||||
<li>
|
||||
<a class="{% navactive request item.url_name %}" href="{% url item.url_name %}">
|
||||
<a class="{% navactive request item.navactive|join:" " %}" href="{% url item.url_name %}">
|
||||
<i class="{{ item.classes }}"></i> {% trans item.text %}
|
||||
</a>
|
||||
</li>
|
||||
|
@ -17,27 +17,9 @@ def process_menu_items(hooks, request):
|
||||
|
||||
|
||||
@register.inclusion_tag('public/menublock.html', takes_context=True)
|
||||
def menu_main(context):
|
||||
def menu_items(context):
|
||||
request = context['request']
|
||||
|
||||
return {
|
||||
'menu_items': process_menu_items(get_hooks('menu_main_hook'), request),
|
||||
}
|
||||
|
||||
|
||||
@register.inclusion_tag('public/menublock.html', takes_context=True)
|
||||
def menu_aux(context):
|
||||
request = context['request']
|
||||
|
||||
return {
|
||||
'menu_items': process_menu_items(get_hooks('menu_aux_hook'), request),
|
||||
}
|
||||
|
||||
|
||||
@register.inclusion_tag('public/menublock.html', takes_context=True)
|
||||
def menu_util(context):
|
||||
request = context['request']
|
||||
|
||||
return {
|
||||
'menu_items': process_menu_items(get_hooks('menu_util_hook'), request),
|
||||
'menu_items': process_menu_items(get_hooks('menu_item_hook'), request),
|
||||
}
|
||||
|
26
srp/auth_hooks.py
Normal file
26
srp/auth_hooks.py
Normal file
@ -0,0 +1,26 @@
|
||||
from services.hooks import MenuItemHook, UrlHook
|
||||
from alliance_auth import hooks
|
||||
from srp import urls
|
||||
|
||||
|
||||
class SrpMenu(MenuItemHook):
|
||||
def __init__(self):
|
||||
MenuItemHook.__init__(self, 'Ship Replacement',
|
||||
'fa fa-money fa-fw grayiconecolor',
|
||||
'srp:management',
|
||||
navactive=['srp:'])
|
||||
|
||||
def render(self, request):
|
||||
if request.user.has_perm('srp.access_srp'):
|
||||
return MenuItemHook.render(self, request)
|
||||
return ''
|
||||
|
||||
|
||||
@hooks.register('menu_item_hook')
|
||||
def register_menu():
|
||||
return SrpMenu()
|
||||
|
||||
|
||||
@hooks.register('url_hook')
|
||||
def register_url():
|
||||
return UrlHook(urls, 'srp', r'^srp/')
|
4
stock/templates/registered/srpfleetadd.html → srp/templates/srp/add.html
Executable file → Normal file
4
stock/templates/registered/srpfleetadd.html → srp/templates/srp/add.html
Executable file → Normal file
@ -28,9 +28,9 @@
|
||||
{% else %}
|
||||
<div class="alert alert-info" role="alert">{% blocktrans %}Give this link to the line members{% endblocktrans %}.</div>
|
||||
<div class="alert alert-info" role="alert">
|
||||
http://{{ request.get_host }}{% url 'auth_srp_request_view' completed_srp_code %}</div>
|
||||
http://{{ request.get_host }}{% url 'srp:request' completed_srp_code %}</div>
|
||||
<div class="text-center">
|
||||
<a href="{% url 'auth_srp_management_view' %}" class="btn btn-primary btn-lg">{% trans "Continue" %}</a>
|
||||
<a href="{% url 'srp:management' %}" class="btn btn-primary btn-lg">{% trans "Continue" %}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
18
stock/templates/registered/srpfleetdata.html → srp/templates/srp/data.html
Executable file → Normal file
18
stock/templates/registered/srpfleetdata.html → srp/templates/srp/data.html
Executable file → Normal file
@ -51,11 +51,11 @@
|
||||
<div class="text-right">
|
||||
{% if perms.auth.srp_management %}
|
||||
{% if fleet_status == "Completed" %}
|
||||
<a href="{% url 'auth_srp_fleet_mark_uncompleted' fleet_id %}" class="btn btn-warning">
|
||||
<a href="{% url 'srp:mark_uncompleted' fleet_id %}" class="btn btn-warning">
|
||||
{% trans "Mark Incomplete" %}
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{% url 'auth_srp_fleet_mark_completed' fleet_id %}" class="btn btn-success">
|
||||
<a href="{% url 'srp:mark_completed' fleet_id %}" class="btn btn-success">
|
||||
{% trans "Mark Completed" %}
|
||||
</a>
|
||||
{% endif %}
|
||||
@ -71,13 +71,13 @@
|
||||
<b><span style="padding-right:2.5em">{% trans "Total Losses:" %} {{ srpfleetrequests.count }}</span></b>
|
||||
<b><span style="padding-right:2.5em">{% trans "Total ISK Cost:" %} {{ totalcost | intcomma }}</span></b>
|
||||
{% if perms.auth.srp_management %}
|
||||
<button type="submit" title="Approve" class="btn btn-success" formaction="{% url 'auth_srp_request_approve' %}">
|
||||
<button type="submit" title="Approve" class="btn btn-success" formaction="{% url 'srp:request_approve' %}">
|
||||
<span class="glyphicon glyphicon-ok"></span>
|
||||
</button>
|
||||
<button type="submit" title="Reject" class="btn btn-warning" formaction="{% url 'auth_srp_request_reject' %}">
|
||||
<button type="submit" title="Reject" class="btn btn-warning" formaction="{% url 'srp:request_reject' %}">
|
||||
<span class="glyphicon glyphicon-remove"></span>
|
||||
</button>
|
||||
<button type="submit" title="Remove" onclick="return confirm('{% trans "Are you sure you want to delete SRP requests?" %}')" class="btn btn-danger" formaction="{% url 'auth_srp_request_remove' %}">
|
||||
<button type="submit" title="Remove" onclick="return confirm('{% trans "Are you sure you want to delete SRP requests?" %}')" class="btn btn-danger" formaction="{% url 'srp:request_remove' %}">
|
||||
<span class="glyphicon glyphicon-trash"></span>
|
||||
</button>
|
||||
{% endif %}
|
||||
@ -112,7 +112,7 @@ ESC to cancel"
|
||||
<td class="text-center">{{ srpfleetrequest.additional_info }}</td>
|
||||
<td class="text-center">{{ srpfleetrequest.srp_ship_name }}</td>
|
||||
<td class="text-center">{{ srpfleetrequest.kb_total_loss | intcomma }} ISK</td>
|
||||
<td class="srp" data-name="srp_total_amount" data-type="number" data-pk="{{srpfleetrequest.id}}" data-url="{% url 'auth_srp_request_update_amount' srpfleetrequest.id %}" data-params="{csrfmiddlewaretoken:'{{csrf_token}}'}" class="text-center">{{ srpfleetrequest.srp_total_amount | intcomma }} ISK</td>
|
||||
<td class="srp" data-name="srp_total_amount" data-type="number" data-pk="{{srpfleetrequest.id}}" data-url="{% url 'srp:request_update_amount' srpfleetrequest.id %}" data-params="{csrfmiddlewaretoken:'{{csrf_token}}'}" class="text-center">{{ srpfleetrequest.srp_total_amount | intcomma }} ISK</td>
|
||||
<td class="text-center">{{ srpfleetrequest.post_time | date:"Y-m-d H:i" }}</td>
|
||||
<td class="text-center">
|
||||
{% if srpfleetrequest.srp_status == "Approved" %}
|
||||
@ -147,13 +147,13 @@ ESC to cancel"
|
||||
<b><span style="padding-right:2.5em">{% trans "Total Losses:" %} {{ srpfleetrequests.count }}</span></b>
|
||||
<b><span style="padding-right:2.5em">{% trans "Total ISK Cost:" %} {{ totalcost | intcomma }}</span></b>
|
||||
{% if perms.auth.srp_management %}
|
||||
<button type="submit" title="Approve" class="btn btn-success" formaction="{% url 'auth_srp_request_approve' %}">
|
||||
<button type="submit" title="Approve" class="btn btn-success" formaction="{% url 'srp:request_approve' %}">
|
||||
<span class="glyphicon glyphicon-ok"></span>
|
||||
</button>
|
||||
<button type="submit" title="Reject" class="btn btn-warning" formaction="{% url 'auth_srp_request_reject' %}">
|
||||
<button type="submit" title="Reject" class="btn btn-warning" formaction="{% url 'srp:request_reject' %}">
|
||||
<span class="glyphicon glyphicon-remove"></span>
|
||||
</button>
|
||||
<button type="submit" title="Remove" onclick="return confirm('{% trans "Are you sure you want to delete SRP requests?" %}')" class="btn btn-danger" formaction="{% url 'auth_srp_request_remove' %}">
|
||||
<button type="submit" title="Remove" onclick="return confirm('{% trans "Are you sure you want to delete SRP requests?" %}')" class="btn btn-danger" formaction="{% url 'srp:request_remove' %}">
|
||||
<span class="glyphicon glyphicon-trash"></span>
|
||||
</button>
|
||||
{% endif %}
|
16
stock/templates/registered/srpmanagement.html → srp/templates/srp/management.html
Executable file → Normal file
16
stock/templates/registered/srpmanagement.html → srp/templates/srp/management.html
Executable file → Normal file
@ -15,10 +15,10 @@
|
||||
<h1 class="page-header text-center">{% trans "SRP Management" %}
|
||||
<div class="text-right">
|
||||
{% if perms.auth.srp_management %}
|
||||
<a href="{% url 'auth_srp_management_all_view' %}" class="btn btn-primary">
|
||||
<a href="{% url 'srp:all' %}" class="btn btn-primary">
|
||||
{% trans "View All" %}
|
||||
</a>
|
||||
<a href="{% url 'auth_srp_fleet_add_view' %}" class="btn btn-success">
|
||||
<a href="{% url 'srp:add' %}" class="btn btn-success">
|
||||
{% trans "Add SRP Fleet" %}
|
||||
</a>
|
||||
{% endif %}
|
||||
@ -64,7 +64,7 @@
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{% if srpfleet.fleet_srp_code %}
|
||||
<a class="label label-warning" href="{% url 'auth_srp_request_view' srpfleet.fleet_srp_code %}">{{ srpfleet.fleet_srp_code }}</a>
|
||||
<a class="label label-warning" href="{% url 'srp:request' srpfleet.fleet_srp_code %}">{{ srpfleet.fleet_srp_code }}</a>
|
||||
{% else %}
|
||||
<div class="label label-danger">
|
||||
{% trans "Disabled" %}
|
||||
@ -89,24 +89,24 @@
|
||||
</td>
|
||||
<td class="text-center">
|
||||
|
||||
<a href="{% url 'auth_srp_fleet_view' srpfleet.id %}" class="btn btn-primary" title="View">
|
||||
<a href="{% url 'srp:fleet' srpfleet.id %}" class="btn btn-primary" title="View">
|
||||
<span class="glyphicon glyphicon-eye-open"></span>
|
||||
</a>
|
||||
|
||||
{% if perms.auth.srp_management %}
|
||||
<a href="{% url 'auth_srp_fleet_edit_view' srpfleet.id %}" class="btn btn-info" title="Edit">
|
||||
<a href="{% url 'srp:edit' srpfleet.id %}" class="btn btn-info" title="Edit">
|
||||
<span class="glyphicon glyphicon-pencil"></span>
|
||||
</a>
|
||||
|
||||
<a href="{% url 'auth_srp_fleet_remove' srpfleet.id %}" onclick="return confirm('{% trans "Are you sure you want to delete this SRP code and its contents?" %}')" class="btn btn-danger" title="Remove">
|
||||
<a href="{% url 'srp:remove' srpfleet.id %}" onclick="return confirm('{% trans "Are you sure you want to delete this SRP code and its contents?" %}')" class="btn btn-danger" title="Remove">
|
||||
<span class="glyphicon glyphicon-trash"></span>
|
||||
</a>
|
||||
{% if srpfleet.fleet_srp_code %}
|
||||
<a href="{% url 'auth_srp_fleet_disable' srpfleet.id %}" class="btn btn-warning" title="Disable">
|
||||
<a href="{% url 'srp:disable' srpfleet.id %}" class="btn btn-warning" title="Disable">
|
||||
<span class="glyphicon glyphicon-remove-sign"></span>
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{% url 'auth_srp_fleet_enable' srpfleet.id %}" class="btn btn-success" title="Enable">
|
||||
<a href="{% url 'srp:enable' srpfleet.id %}" class="btn btn-success" title="Enable">
|
||||
<span class="glyphicon glyphicon-ok-sign"></span>
|
||||
</a>
|
||||
{% endif %}
|
0
stock/templates/registered/srpfleetrequest.html → srp/templates/srp/request.html
Executable file → Normal file
0
stock/templates/registered/srpfleetrequest.html → srp/templates/srp/request.html
Executable file → Normal file
0
stock/templates/registered/srpfleetupdate.html → srp/templates/srp/update.html
Executable file → Normal file
0
stock/templates/registered/srpfleetupdate.html → srp/templates/srp/update.html
Executable file → Normal file
31
srp/urls.py
Normal file
31
srp/urls.py
Normal file
@ -0,0 +1,31 @@
|
||||
from django.conf.urls import url
|
||||
import srp.views
|
||||
|
||||
app_name = 'srp'
|
||||
|
||||
urlpatterns = [
|
||||
# SRP URLS
|
||||
url(r'^$', srp.views.srp_management, name='management'),
|
||||
url(r'^all/$', srp.views.srp_management_all, name='all'),
|
||||
url(r'^(\w+)/view$', srp.views.srp_fleet_view, name='fleet'),
|
||||
url(r'^add/$', srp.views.srp_fleet_add_view, name='add'),
|
||||
url(r'^(\w+)/edit$', srp.views.srp_fleet_edit_view, name='edit'),
|
||||
url(r'^(\w+)/request', srp.views.srp_request_view, name='request'),
|
||||
|
||||
# SRP URLS
|
||||
url(r'^(\w+)/remove$', srp.views.srp_fleet_remove, name='remove'),
|
||||
url(r'^(\w+)/disable$', srp.views.srp_fleet_disable, name='disable'),
|
||||
url(r'^(\w+)/enable$', srp.views.srp_fleet_enable, name='enable'),
|
||||
url(r'^(\w+)/complete$', srp.views.srp_fleet_mark_completed,
|
||||
name='mark_completed'),
|
||||
url(r'^(\w+)/incomplete$', srp.views.srp_fleet_mark_uncompleted,
|
||||
name='mark_uncompleted'),
|
||||
url(r'^request/remove/', srp.views.srp_request_remove,
|
||||
name="request_remove"),
|
||||
url(r'request/approve/', srp.views.srp_request_approve,
|
||||
name='request_approve'),
|
||||
url(r'request/reject/', srp.views.srp_request_reject,
|
||||
name='request_reject'),
|
||||
url(r'^request/(\w+)/update', srp.views.srp_request_update_amount,
|
||||
name="request_update_amount"),
|
||||
]
|
91
srp/views.py
91
srp/views.py
@ -37,7 +37,7 @@ def srp_management(request):
|
||||
fleets = SrpFleetMain.objects.filter(fleet_srp_status="")
|
||||
totalcost = sum([int(fleet.total_cost) for fleet in fleets])
|
||||
context = {"srpfleets": fleets, "totalcost": totalcost}
|
||||
return render(request, 'registered/srpmanagement.html', context=context)
|
||||
return render(request, 'srp/management.html', context=context)
|
||||
|
||||
|
||||
@login_required
|
||||
@ -47,7 +47,7 @@ def srp_management_all(request):
|
||||
fleets = SrpFleetMain.objects.all()
|
||||
totalcost = sum([int(fleet.total_cost) for fleet in fleets])
|
||||
context = {"srpfleets": SrpFleetMain.objects.all(), "totalcost": totalcost}
|
||||
return render(request, 'registered/srpmanagement.html', context=context)
|
||||
return render(request, 'srp/management.html', context=context)
|
||||
|
||||
|
||||
@login_required
|
||||
@ -59,7 +59,7 @@ def srp_fleet_view(request, fleet_id):
|
||||
"srpfleetrequests": fleet_main.srpuserrequest_set.order_by('srp_ship_name'),
|
||||
"totalcost": fleet_main.total_cost}
|
||||
|
||||
return render(request, 'registered/srpfleetdata.html', context=context)
|
||||
return render(request, 'srp/data.html', context=context)
|
||||
|
||||
|
||||
@login_required
|
||||
@ -93,7 +93,7 @@ def srp_fleet_add_view(request):
|
||||
|
||||
render_items = {'form': form, "completed": completed, "completed_srp_code": completed_srp_code}
|
||||
|
||||
return render(request, 'registered/srpfleetadd.html', context=render_items)
|
||||
return render(request, 'srp/add.html', context=render_items)
|
||||
|
||||
|
||||
@login_required
|
||||
@ -104,7 +104,7 @@ def srp_fleet_remove(request, fleet_id):
|
||||
srpfleetmain.delete()
|
||||
logger.info("SRP Fleet %s deleted by user %s" % (srpfleetmain.fleet_name, request.user))
|
||||
messages.success(request, _('Removed SRP fleet %(fleetname)s.') % {"fleetname": srpfleetmain.fleet_name})
|
||||
return redirect("auth_srp_management_view")
|
||||
return redirect("srp:management")
|
||||
|
||||
|
||||
@login_required
|
||||
@ -116,7 +116,7 @@ def srp_fleet_disable(request, fleet_id):
|
||||
srpfleetmain.save()
|
||||
logger.info("SRP Fleet %s disabled by user %s" % (srpfleetmain.fleet_name, request.user))
|
||||
messages.success(request, _('Disabled SRP fleet %(fleetname)s.') % {"fleetname": srpfleetmain.fleet_name})
|
||||
return redirect("auth_srp_management_view")
|
||||
return redirect("srp:management")
|
||||
|
||||
|
||||
@login_required
|
||||
@ -128,7 +128,7 @@ def srp_fleet_enable(request, fleet_id):
|
||||
srpfleetmain.save()
|
||||
logger.info("SRP Fleet %s enable by user %s" % (srpfleetmain.fleet_name, request.user))
|
||||
messages.success(request, _('Enabled SRP fleet %(fleetname)s.') % {"fleetname": srpfleetmain.fleet_name})
|
||||
return redirect("auth_srp_management_view")
|
||||
return redirect("srp:management")
|
||||
|
||||
|
||||
@login_required
|
||||
@ -141,7 +141,7 @@ def srp_fleet_mark_completed(request, fleet_id):
|
||||
logger.info("Marked SRP Fleet %s as completed by user %s" % (srpfleetmain.fleet_name, request.user))
|
||||
messages.success(request,
|
||||
_('Marked SRP fleet %(fleetname)s as completed.') % {"fleetname": srpfleetmain.fleet_name})
|
||||
return redirect("auth_srp_fleet_view", fleet_id)
|
||||
return redirect("srp:fleet", fleet_id)
|
||||
|
||||
|
||||
@login_required
|
||||
@ -154,7 +154,7 @@ def srp_fleet_mark_uncompleted(request, fleet_id):
|
||||
logger.info("Marked SRP Fleet %s as incomplete for user %s" % (fleet_id, request.user))
|
||||
messages.success(request,
|
||||
_('Marked SRP fleet %(fleetname)s as incomplete.') % {"fleetname": srpfleetmain.fleet_name})
|
||||
return redirect("auth_srp_fleet_view", fleet_id)
|
||||
return redirect("srp:fleet", fleet_id)
|
||||
|
||||
|
||||
@login_required
|
||||
@ -166,7 +166,7 @@ def srp_request_view(request, fleet_srp):
|
||||
logger.error("Unable to locate SRP Fleet using code %s for user %s" % (fleet_srp, request.user))
|
||||
messages.error(request,
|
||||
_('Unable to locate SRP code with ID %(srpfleetid)s') % {"srpfleetid": fleet_srp})
|
||||
return redirect("auth_srp_management_view")
|
||||
return redirect("srp:management")
|
||||
|
||||
if request.method == 'POST':
|
||||
form = SrpFleetUserRequestForm(request.POST)
|
||||
@ -176,7 +176,7 @@ def srp_request_view(request, fleet_srp):
|
||||
if SrpUserRequest.objects.filter(killboard_link=form.cleaned_data['killboard_link']).exists():
|
||||
messages.error(request,
|
||||
_("This Killboard link has already been posted."))
|
||||
return redirect("auth_srp_management_view")
|
||||
return redirect("srp:management")
|
||||
|
||||
character = request.user.profile.main_character
|
||||
srp_fleet_main = SrpFleetMain.objects.get(fleet_srp_code=fleet_srp)
|
||||
@ -198,41 +198,43 @@ def srp_request_view(request, fleet_srp):
|
||||
messages.error(request,
|
||||
_(
|
||||
"Your SRP request Killmail link is invalid. Please make sure you are using zKillboard."))
|
||||
return redirect("auth_srp_management_view")
|
||||
return redirect("srp:management")
|
||||
|
||||
if request.user.characterownership_set.filter(character__character_name=victim_name).exists():
|
||||
if request.user.character_ownerships.filter(character__character_name=victim_name).exists():
|
||||
srp_request.srp_ship_name = EveManager.get_itemtype(ship_type_id).name
|
||||
srp_request.kb_total_loss = ship_value
|
||||
srp_request.post_time = post_time
|
||||
srp_request.save()
|
||||
logger.info("Created SRP Request on behalf of user %s for fleet name %s" % (
|
||||
request.user, srp_fleet_main.fleet_name))
|
||||
messages.success(request, _('Submitted SRP request for your %(ship)s.') % {"ship": srp_request.srp_ship_name})
|
||||
return redirect("auth_srp_management_view")
|
||||
messages.success(request,
|
||||
_('Submitted SRP request for your %(ship)s.') % {"ship": srp_request.srp_ship_name})
|
||||
return redirect("srp:management")
|
||||
else:
|
||||
messages.error(request,
|
||||
_("%(charname)s does not belong to your Auth account. Please add the API key for this character and try again")
|
||||
_(
|
||||
"%(charname)s does not belong to your Auth account. Please add the API key for this character and try again")
|
||||
% {"charname": victim_name})
|
||||
return redirect("auth_srp_management_view")
|
||||
return redirect("srp:management")
|
||||
else:
|
||||
logger.debug("Returning blank SrpFleetUserRequestForm")
|
||||
form = SrpFleetUserRequestForm()
|
||||
|
||||
render_items = {'form': form}
|
||||
|
||||
return render(request, 'registered/srpfleetrequest.html', context=render_items)
|
||||
return render(request, 'srp/request.html', context=render_items)
|
||||
|
||||
|
||||
@login_required
|
||||
@permission_required('auth.srp_management')
|
||||
def srp_request_remove(request):
|
||||
numrequests = len(request.POST)-1
|
||||
numrequests = len(request.POST) - 1
|
||||
logger.debug("srp_request_remove called by user %s for %s srp request id's" % (request.user, numrequests))
|
||||
stored_fleet_view = None
|
||||
for srp_request_id in request.POST:
|
||||
if numrequests == 0:
|
||||
messages.warning(request, _("No SRP requests selected"))
|
||||
return redirect("auth_srp_management_view")
|
||||
return redirect("srp:management")
|
||||
if srp_request_id == "csrfmiddlewaretoken":
|
||||
continue
|
||||
if SrpUserRequest.objects.filter(id=srp_request_id).exists():
|
||||
@ -241,25 +243,24 @@ def srp_request_remove(request):
|
||||
srpuserrequest.delete()
|
||||
logger.info("Deleted SRP request id %s for user %s" % (srp_request_id, request.user))
|
||||
if stored_fleet_view is None:
|
||||
logger.error("Unable to delete srp request id %s for user %s - request matching id not found." % (
|
||||
srp_request_id, request.user))
|
||||
messages.error(request, _('Unable to locate SRP request with ID %(requestid)s') % {"requestid": srp_request_id})
|
||||
return redirect("auth_srp_management_view")
|
||||
logger.error("Unable to delete srp requests for user %s - request matching id not found." % (request.user))
|
||||
messages.error(request, _('Unable to locate selected SRP request.'))
|
||||
return redirect("srp:management")
|
||||
else:
|
||||
messages.success(request, _('Deleted %(numrequests)s SRP requests') % {"numrequests": numrequests})
|
||||
return redirect("auth_srp_fleet_view", stored_fleet_view)
|
||||
return redirect("srp:fleet", stored_fleet_view)
|
||||
|
||||
|
||||
@login_required
|
||||
@permission_required('auth.srp_management')
|
||||
def srp_request_approve(request):
|
||||
numrequests = len(request.POST)-1
|
||||
numrequests = len(request.POST) - 1
|
||||
logger.debug("srp_request_approve called by user %s for %s srp request id's" % (request.user, numrequests))
|
||||
stored_fleet_view = None
|
||||
for srp_request_id in request.POST:
|
||||
if numrequests == 0:
|
||||
messages.warning(request, _("No SRP requests selected"))
|
||||
return redirect("auth_srp_management_view")
|
||||
return redirect("srp:management")
|
||||
if srp_request_id == "csrfmiddlewaretoken":
|
||||
continue
|
||||
if SrpUserRequest.objects.filter(id=srp_request_id).exists():
|
||||
@ -276,28 +277,28 @@ def srp_request_approve(request):
|
||||
'SRP Request Approved',
|
||||
level='success',
|
||||
message='Your SRP request for a %s lost during %s has been approved for %s ISK.' % (
|
||||
srpuserrequest.srp_ship_name, srpuserrequest.srp_fleet_main.fleet_name, intcomma(srpuserrequest.srp_total_amount))
|
||||
srpuserrequest.srp_ship_name, srpuserrequest.srp_fleet_main.fleet_name,
|
||||
intcomma(srpuserrequest.srp_total_amount))
|
||||
)
|
||||
if stored_fleet_view is None:
|
||||
logger.error("Unable to approve srp request id %s on behalf of user %s - request matching id not found." % (
|
||||
srp_request_id, request.user))
|
||||
messages.error(request, _('Unable to locate SRP request with ID %(requestid)s') % {"requestid": srp_request_id})
|
||||
return redirect("auth_srp_management_view")
|
||||
logger.error("Unable to approve srp request on behalf of user %s - request matching id not found." % (request.user))
|
||||
messages.error(request, _('Unable to locate selected SRP request.'))
|
||||
return redirect("srp:management")
|
||||
else:
|
||||
messages.success(request, _('Approved %(numrequests)s SRP requests') % {"numrequests": numrequests})
|
||||
return redirect("auth_srp_fleet_view", stored_fleet_view)
|
||||
return redirect("srp:fleet", stored_fleet_view)
|
||||
|
||||
|
||||
@login_required
|
||||
@permission_required('auth.srp_management')
|
||||
def srp_request_reject(request):
|
||||
numrequests = len(request.POST)-1
|
||||
numrequests = len(request.POST) - 1
|
||||
logger.debug("srp_request_reject called by user %s for %s srp request id's" % (request.user, numrequests))
|
||||
stored_fleet_view = None
|
||||
for srp_request_id in request.POST:
|
||||
if numrequests == 0:
|
||||
messages.warning(request, _("No SRP requests selected"))
|
||||
return redirect("auth_srp_management_view")
|
||||
return redirect("srp:management")
|
||||
if srp_request_id == "csrfmiddlewaretoken":
|
||||
continue
|
||||
if SrpUserRequest.objects.filter(id=srp_request_id).exists():
|
||||
@ -315,13 +316,12 @@ def srp_request_reject(request):
|
||||
srpuserrequest.srp_ship_name, srpuserrequest.srp_fleet_main.fleet_name)
|
||||
)
|
||||
if stored_fleet_view is None:
|
||||
logger.error("Unable to reject SRP request id %s on behalf of user %s - request matching id not found." % (
|
||||
srp_request_id, request.user))
|
||||
messages.error(request, _('Unable to locate SRP request with ID %(requestid)s') % {"requestid": srp_request_id})
|
||||
return redirect("auth_srp_management_view")
|
||||
logger.error("Unable to reject SRP request on behalf of user %s - request matching id not found." % (request.user))
|
||||
messages.error(request, _('Unable to locate selected SRP request'))
|
||||
return redirect("srp:management")
|
||||
else:
|
||||
messages.success(request, _('Rejected %(numrequests)s SRP requests.') % {"numrequests": numrequests})
|
||||
return redirect("auth_srp_fleet_view", stored_fleet_view)
|
||||
return redirect("srp:fleet", stored_fleet_view)
|
||||
|
||||
|
||||
@login_required
|
||||
@ -332,15 +332,16 @@ def srp_request_update_amount(request, fleet_srp_request_id):
|
||||
|
||||
if SrpUserRequest.objects.filter(id=fleet_srp_request_id).exists() is False:
|
||||
logger.error("Unable to locate SRP request id %s for user %s" % (fleet_srp_request_id, request.user))
|
||||
messages.error(request, _('Unable to locate SRP request with ID %(requestid)s') % {"requestid": fleet_srp_request_id})
|
||||
return redirect("auth_srp_management_view")
|
||||
messages.error(request,
|
||||
_('Unable to locate SRP request with ID %(requestid)s') % {"requestid": fleet_srp_request_id})
|
||||
return redirect("srp:management")
|
||||
|
||||
srp_request = SrpUserRequest.objects.get(id=fleet_srp_request_id)
|
||||
srp_request.srp_total_amount = request.POST['value']
|
||||
srp_request.save()
|
||||
logger.info("Updated srp request id %s total to %s by user %s" % (
|
||||
fleet_srp_request_id, request.POST['value'], request.user))
|
||||
return JsonResponse({"success":True,"pk":fleet_srp_request_id,"newValue":request.POST['value']})
|
||||
return JsonResponse({"success": True, "pk": fleet_srp_request_id, "newValue": request.POST['value']})
|
||||
|
||||
|
||||
@login_required
|
||||
@ -357,8 +358,8 @@ def srp_fleet_edit_view(request, fleet_id):
|
||||
logger.info("User %s edited SRP Fleet %s" % (request.user, srpfleetmain.fleet_name))
|
||||
messages.success(request,
|
||||
_('Saved changes to SRP fleet %(fleetname)s') % {"fleetname": srpfleetmain.fleet_name})
|
||||
return redirect("auth_srp_management_view")
|
||||
return redirect("srp:management")
|
||||
else:
|
||||
logger.debug("Returning blank SrpFleetMainUpdateForm")
|
||||
form = SrpFleetMainUpdateForm()
|
||||
return render(request, 'registered/srpfleetupdate.html', context={'form': form})
|
||||
return render(request, 'srp/update.html', context={'form': form})
|
||||
|
26
timerboard/auth_hooks.py
Normal file
26
timerboard/auth_hooks.py
Normal file
@ -0,0 +1,26 @@
|
||||
from services.hooks import MenuItemHook, UrlHook
|
||||
from alliance_auth import hooks
|
||||
from timerboard import urls
|
||||
|
||||
|
||||
class TimerboardMenu(MenuItemHook):
|
||||
def __init__(self):
|
||||
MenuItemHook.__init__(self, 'Structure Timers',
|
||||
'fa fa-clock-o fa-fw grayiconecolor',
|
||||
'timerboard:view',
|
||||
navactive=['timerboard:'])
|
||||
|
||||
def render(self, request):
|
||||
if request.user.has_perm('auth.timer_view'):
|
||||
return MenuItemHook.render(self, request)
|
||||
return ''
|
||||
|
||||
|
||||
@hooks.register('menu_item_hook')
|
||||
def register_menu():
|
||||
return TimerboardMenu()
|
||||
|
||||
|
||||
@hooks.register('url_hook')
|
||||
def register_url():
|
||||
return UrlHook(urls, 'timerboard', r'^timers/')
|
0
stock/templates/registered/addtimer.html → timerboard/templates/timerboard/add.html
Executable file → Normal file
0
stock/templates/registered/addtimer.html → timerboard/templates/timerboard/add.html
Executable file → Normal file
7
stock/templates/registered/timermanagement.html → timerboard/templates/timerboard/management.html
Executable file → Normal file
7
stock/templates/registered/timermanagement.html → timerboard/templates/timerboard/management.html
Executable file → Normal file
@ -13,7 +13,7 @@
|
||||
<h1 class="page-header text-center">{% trans "Structure Timers" %}
|
||||
<div class="text-right">
|
||||
{% if perms.auth.timer_management %}
|
||||
<a href="{% url 'auth_add_timer_view' %}" class="btn btn-success">{% trans "Create Structure Timer" %}</a>
|
||||
<a href="{% url 'timerboard:add' %}" class="btn btn-success">{% trans "Create Structure Timer" %}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</h1>
|
||||
@ -279,11 +279,12 @@
|
||||
<td class="text-center">{{ timer.eve_character.character_name }}</td>
|
||||
{% if perms.auth.timer_management %}
|
||||
<td class="text-center">
|
||||
<a href="{% url 'auth_remove_timer' timer.id %}" class="btn btn-danger">
|
||||
<a href="{% url 'timerboard:remove' timer.id %}" class="btn btn-danger">
|
||||
<span class="glyphicon glyphicon-remove"></span>
|
||||
</a>
|
||||
<a href="{% url 'auth_edit_timer' timer.id %}" class="btn btn-info">
|
||||
<a href="{% url 'timerboard:edit' timer.id %}" class="btn btn-info">
|
||||
<span class="glyphicon glyphicon-pencil"></span>
|
||||
</a>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
11
timerboard/urls.py
Normal file
11
timerboard/urls.py
Normal file
@ -0,0 +1,11 @@
|
||||
from django.conf.urls import url
|
||||
import timerboard.views
|
||||
|
||||
app_name = 'timerboard'
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', timerboard.views.timer_view, name='view'),
|
||||
url(r'^add/$', timerboard.views.add_timer_view, name='add'),
|
||||
url(r'^remove/(\w+)$', timerboard.views.remove_timer, name='remove'),
|
||||
url(r'^edit/(\w+)$', timerboard.views.edit_timer, name='edit'),
|
||||
]
|
@ -30,7 +30,6 @@ def timer_view(request):
|
||||
corp_timers = Timer.objects.all().filter(corp_timer=True).filter(eve_corp=corp)
|
||||
else:
|
||||
corp_timers = []
|
||||
timer_list = Timer.objects.filter(corp_timer=False)
|
||||
render_items = {'timers': Timer.objects.all().filter(corp_timer=False),
|
||||
'corp_timers': corp_timers,
|
||||
'future_timers': Timer.objects.all().filter(corp_timer=False).filter(
|
||||
@ -38,7 +37,7 @@ def timer_view(request):
|
||||
'past_timers': Timer.objects.all().filter(corp_timer=False).filter(
|
||||
eve_time__lt=datetime.datetime.now())}
|
||||
|
||||
return render(request, 'registered/timermanagement.html', context=render_items)
|
||||
return render(request, 'timerboard/management.html', context=render_items)
|
||||
|
||||
|
||||
@login_required
|
||||
@ -84,7 +83,7 @@ def add_timer_view(request):
|
||||
|
||||
render_items = {'form': form}
|
||||
|
||||
return render(request, 'registered/addtimer.html', context=render_items)
|
||||
return render(request, 'timerboard/add.html', context=render_items)
|
||||
|
||||
|
||||
@login_required
|
||||
@ -150,4 +149,4 @@ def edit_timer(request, timer_id):
|
||||
'minutes_left': tdminutes,
|
||||
}
|
||||
form = TimerForm(initial=data)
|
||||
return render(request, 'registered/timerupdate.html', context={'form': form})
|
||||
return render(request, 'timerboard/update.html', context={'form': form})
|
||||
|
Loading…
x
Reference in New Issue
Block a user