mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-07 07:36:20 +01:00
Name generator/formatter (#897)
* Squash services migrations * Add name to example service to allow it to be used in tests * Add name formatter to services * Add documentation
This commit is contained in:
@@ -18,6 +18,7 @@ class Phpbb3Service(ServicesHook):
|
||||
self.urlpatterns = urlpatterns
|
||||
self.service_url = settings.PHPBB3_URL
|
||||
self.access_perm = 'phpbb3.access_phpbb3'
|
||||
self.name_format = '{character_name}'
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
|
||||
@@ -5,6 +5,7 @@ from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
from allianceauth.celery import app
|
||||
from allianceauth.notifications import notify
|
||||
from allianceauth.services.hooks import NameFormatter
|
||||
from .manager import Phpbb3Manager
|
||||
from .models import Phpbb3User
|
||||
|
||||
@@ -64,3 +65,8 @@ class Phpbb3Tasks:
|
||||
@staticmethod
|
||||
def disable():
|
||||
Phpbb3User.objects.all().delete()
|
||||
|
||||
@staticmethod
|
||||
def get_username(user):
|
||||
from .auth_hooks import Phpbb3Service
|
||||
return NameFormatter(Phpbb3Service(), user).format_name()
|
||||
|
||||
@@ -21,7 +21,7 @@ def activate_forum(request):
|
||||
# Valid now we get the main characters
|
||||
character = request.user.profile.main_character
|
||||
logger.debug("Adding phpbb user for user %s with main character %s" % (request.user, character))
|
||||
result = Phpbb3Manager.add_user(character.character_name, request.user.email, ['REGISTERED'],
|
||||
result = Phpbb3Manager.add_user(Phpbb3Tasks.get_username(request.user), request.user.email, ['REGISTERED'],
|
||||
character.character_id)
|
||||
# if empty we failed
|
||||
if result[0] != "":
|
||||
|
||||
Reference in New Issue
Block a user