Files
allianceauth/allianceauth/services/modules/ips4/auth_hooks.py
Basraah 786859294d Restructure Alliance Auth package (#867)
* Refactor allianceauth into its own package

* Add setup

* Add missing default_app_config declarations

* Fix timerboard namespacing

* Remove obsolete future imports

* Remove py2 mock support

* Remove six

* Add experimental 3.7 support and multiple Dj versions

* Remove python_2_unicode_compatible

* Add navhelper as local package

* Update requirements
2017-09-19 09:46:40 +10:00

49 lines
1.5 KiB
Python

from django.conf import settings
from django.template.loader import render_to_string
from allianceauth import hooks
from allianceauth.services.hooks import ServicesHook
from .tasks import Ips4Tasks
from .urls import urlpatterns
class Ips4Service(ServicesHook):
def __init__(self):
ServicesHook.__init__(self)
self.name = 'ips4'
self.urlpatterns = urlpatterns
self.service_url = settings.IPS4_URL
self.access_perm = 'ips4.access_ips4'
@property
def title(self):
return 'IPS4'
def service_active_for_user(self, user):
return user.has_perm(self.access_perm)
def render_services_ctrl(self, request):
"""
Example for rendering the service control panel row
You can override the default template and create a
custom one if you wish.
:param request:
:return:
"""
urls = self.Urls()
urls.auth_activate = 'auth_activate_ips4'
urls.auth_deactivate = 'auth_deactivate_ips4'
urls.auth_reset_password = 'auth_reset_ips4_password'
urls.auth_set_password = 'auth_set_ips4_password'
return render_to_string(self.service_ctrl_template, {
'service_name': self.title,
'urls': urls,
'service_url': self.service_url,
'username': request.user.ips4.username if Ips4Tasks.has_account(request.user) else ''
}, request=request)
@hooks.register('services_hook')
def register_service():
return Ips4Service()