diff --git a/README.md b/README.md index bad3c8cc..78f9a05e 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,11 @@ Requirments: python-mysql-connector python-mysqld django-evolution + python-passlib + bcrypt Services Interaction: - Vanilla forums + Mysql Forums Mumble Prosody (jabber) diff --git a/allianceauth/settings.py b/allianceauth/settings.py index 2807bfe0..5a793f6f 100644 --- a/allianceauth/settings.py +++ b/allianceauth/settings.py @@ -83,6 +83,15 @@ DATABASES = { 'PASSWORD': 'allianceauth', 'HOST': '127.0.0.1', 'PORT': '3306', + }, + + 'phpbb3': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': 'alliance_forum', + 'USER': 'allianceauth', + 'PASSWORD': 'allianceauth', + 'HOST': '127.0.0.1', + 'PORT': '3306', } } diff --git a/allianceauth/urls.py b/allianceauth/urls.py index 20324af0..a2b28b9b 100644 --- a/allianceauth/urls.py +++ b/allianceauth/urls.py @@ -11,6 +11,8 @@ urlpatterns = patterns('', url(r'^characters/', 'portal.views.characters_view', name='characters'), url(r'^apikeymanagment/', 'portal.views.apikeymanagment_view', name='apimanagment'), url(r'^maincharacterchange/(\d+)/$', 'portal.views.main_character_change', name='main_character_change'), + url(r'^applications/', 'portal.views.applications_view', name = 'applications'), + url(r'^activateforum/$', 'portal.views.activate_forum', name = 'activateforum'), url(r'^loginuser/','authentication.views.login_user', name='loginuser'), url(r'^logoutuser/','authentication.views.logout_user', name='logoutuser'), url(r'^register/', 'registration.views.register', name='register'), diff --git a/authentication/models.py b/authentication/models.py index 3a3d2904..2f395499 100644 --- a/authentication/models.py +++ b/authentication/models.py @@ -59,6 +59,9 @@ class AllianceUserManager(BaseUserManager): user = AllianceUser.objects.get(id=user_id) user.main_char_id = character_id user.save(update_fields=['main_char_id']) + + def check_if_user_exist(self, user_id): + return AllianceUser.objects.filter(id=user_id).exists() # The icv user class AllianceUser(AbstractBaseUser): diff --git a/evespecific/managers.py b/evespecific/managers.py index 2e45930c..ace198a6 100644 --- a/evespecific/managers.py +++ b/evespecific/managers.py @@ -27,11 +27,15 @@ class EveCharacterManager(): def get_characters_by_owner_id(self, owner_id): return EveCharacter.objects.all().filter(allianceuser_owner=owner_id) + def get_character_by_id(self, char_id): + if EveCharacter.objects.filter(character_id = char_id).exists(): + return EveCharacter.objects.get(character_id=char_id) + + return None + def check_if_character_owned_by_user(self, char_id, user_id): character = EveCharacter.objects.get(character_id = char_id) - print char_id - print user_id - print character.allianceuser_owner + if character.allianceuser_owner.id == user_id: return True diff --git a/portal/views.py b/portal/views.py index f2a4802d..b9680ffd 100644 --- a/portal/views.py +++ b/portal/views.py @@ -6,6 +6,8 @@ from forms import UpdateKeyForm from evespecific.managers import EveCharacterManager from authentication.models import AllianceUserManager +from util.phpbb3_manager import Phpbb3Manager + # Create your views here. @login_required def index(request): @@ -39,3 +41,24 @@ def apikeymanagment_view(request): form = UpdateKeyForm(initial={'api_id':request.user.api_id,'api_key':request.user.api_key}) return render_to_response('public/apikeymanagment.html', {'form':form}, context_instance=RequestContext(request)) + +@login_required +def applications_view(request): + return render_to_response('public/applications.html', None, context_instance=RequestContext(request)) + +@login_required +def activate_forum(request): + userManager = AllianceUserManager() + forumManager = Phpbb3Manager() + + if userManager.check_if_user_exist(request.user.id): + # Valid now we get the main characters + characterManager = EveCharacterManager() + character = characterManager.get_character_by_id(request.user.main_char_id) + + if forumManager.check_user(character.character_name) == False: + forumManager.add_user(character.character_name, "test", request.user.email, ['REGISTERED']) + return HttpResponseRedirect("/applications/") + + return HttpResponseRedirect("/") + diff --git a/templates/public/applications.html b/templates/public/applications.html new file mode 100644 index 00000000..41330482 --- /dev/null +++ b/templates/public/applications.html @@ -0,0 +1,16 @@ +{% extends "public/base.html" %} +{% load staticfiles %} + +{% block title %}Alliance Auth{% endblock %} + +{% block page_title %}Something something here{% endblock page_title %} +{% block extra_css %}{% endblock extra_css %} + +{% block content %} +
+ +{% endblock content %} diff --git a/templates/public/base.html b/templates/public/base.html index a3404c3d..26363fa5 100644 --- a/templates/public/base.html +++ b/templates/public/base.html @@ -52,7 +52,7 @@