diff --git a/allianceauth/settings.py b/allianceauth/settings.py index 82d31b92..c5e03771 100644 --- a/allianceauth/settings.py +++ b/allianceauth/settings.py @@ -151,11 +151,11 @@ STATIC_URL = '/static/' # ALLIANCE INFO ALLIANCE_ID = 0 -ALLIANCE_NAME = 'AllianceName' +ALLIANCE_NAME = '' # Jabber Prosody Info OPENFIRE_ADDRESS = "http://someaddress.com:9090/" -OPENFIRE_SECRET_KEY = "somekey" +OPENFIRE_SECRET_KEY = "somesecretkey" # Mumble settings MUMBLE_SERVER_ID = 1 \ No newline at end of file diff --git a/authentication/models.py b/authentication/models.py index 777e95e7..aa03741d 100644 --- a/authentication/models.py +++ b/authentication/models.py @@ -1,7 +1,7 @@ from django.db import models from django.contrib.auth.models import BaseUserManager from django.contrib.auth.models import AbstractBaseUser -# Todo Add a check to make sure the email / username has not been used before + class AllianceUserManager(BaseUserManager): @@ -66,18 +66,47 @@ class AllianceUserManager(BaseUserManager): def check_if_user_exist_by_name(self, user_name): return AllianceUser.objects.filter(username=user_name).exists() + def update_user_form_info(self, username, password, user_id): + if AllianceUser.objects.filter(id=user_id).exists(): + user = AllianceUser.objects.get(id=user_id) + user.forum_username = username + user.forum_password = password + user.save(update_fields=['forum_username', 'forum_password']) + + def update_user_jabber_info(self, username, password, user_id): + if AllianceUser.objects.filter(id=user_id).exists(): + user = AllianceUser.objects.get(id=user_id) + user.jabber_username = username + user.jabber_password = password + user.save(update_fields=['jabber_username', 'jabber_password']) + + def update_user_mumble_info(self, username, password, user_id): + if AllianceUser.objects.filter(id=user_id).exists(): + user = AllianceUser.objects.get(id=user_id) + user.mumble_username = username + user.mumble_password = password + user.save(update_fields=['mumble_username', 'mumble_password']) + class AllianceUser(AbstractBaseUser): - username = models.CharField(max_length = 40,unique=True) - email = models.EmailField(max_length=255,unique=True) + username = models.CharField(max_length=40, unique=True) + email = models.EmailField(max_length=255, unique=True) is_active = models.BooleanField(default=True) is_admin = models.BooleanField(default=False) - is_moderator = models.BooleanField(default = False) - is_banned = models.BooleanField(default = False) - api_id = models.CharField(max_length = 254) - api_key = models.CharField(max_length = 254) - main_char_id = models.IntegerField(default = 0) - + is_moderator = models.BooleanField(default=False) + is_banned = models.BooleanField(default=False) + api_id = models.CharField(max_length=254) + api_key = models.CharField(max_length=254) + main_char_id = models.IntegerField(default=0) + + # Login information stuff + forum_username = models.CharField(max_length=64) + forum_password = models.CharField(max_length=64) + jabber_username = models.CharField(max_length=64) + jabber_password = models.CharField(max_length=64) + mumble_username = models.CharField(max_length=64) + mumble_password = models.CharField(max_length=64) + objects = AllianceUserManager() USERNAME_FIELD = 'username' diff --git a/evespecific/managers.py b/evespecific/managers.py index 462ad405..6688b168 100644 --- a/evespecific/managers.py +++ b/evespecific/managers.py @@ -1,4 +1,5 @@ from models import EveCharacter +from services.eveapi_manager import EveApiManager class EveCharacterManager(): @@ -7,7 +8,7 @@ class EveCharacterManager(): pass def create_character(self, character_id, character_name, corporation_id, - corporation_name, alliance_id, + corporation_name, corporation_ticker, alliance_id, alliance_name, allianceuser_owner): eve_char = EveCharacter(); @@ -15,6 +16,7 @@ class EveCharacterManager(): eve_char.character_name = character_name eve_char.corporation_id = corporation_id eve_char.corporation_name = corporation_name + eve_char.corporation_ticker = corporation_ticker eve_char.alliance_id = alliance_id eve_char.alliance_name = alliance_name eve_char.allianceuser_owner = allianceuser_owner @@ -22,12 +24,17 @@ class EveCharacterManager(): eve_char.save() def create_characters_from_list(self, chars, owner): + evemanager = EveApiManager() + for char in chars.result: if not self.check_if_character_exist(chars.result[char]['name']): self.create_character(chars.result[char]['id'], chars.result[char]['name'], - chars.result[char]['corp']['id'], chars.result[char]['corp']['name'], - chars.result[char]['alliance']['id'], chars.result[char]['alliance']['name'], + chars.result[char]['corp']['id'], + chars.result[char]['corp']['name'], + evemanager.get_corporation_ticker_from_id(chars.result[char]['corp']['id']), + chars.result[char]['alliance']['id'], + chars.result[char]['alliance']['name'], owner) def check_if_character_exist(self, char_name): diff --git a/evespecific/models.py b/evespecific/models.py index a044477d..d6de1604 100644 --- a/evespecific/models.py +++ b/evespecific/models.py @@ -8,6 +8,7 @@ class EveCharacter(models.Model): character_name = models.CharField(max_length=254) corporation_id = models.CharField(max_length=254) corporation_name = models.CharField(max_length=254) + corporation_ticker = models.CharField(max_length=254) alliance_id = models.CharField(max_length=254) alliance_name = models.CharField(max_length=254) - allianceuser_owner = models.ForeignKey(AllianceUser) \ No newline at end of file + allianceuser_owner = models.ForeignKey(AllianceUser) diff --git a/services/eveapi_manager.py b/services/eveapi_manager.py index fb9f69fc..9d4f95df 100644 --- a/services/eveapi_manager.py +++ b/services/eveapi_manager.py @@ -1,3 +1,4 @@ +import sys import evelink.api import evelink.char import evelink.eve @@ -8,12 +9,30 @@ class EveApiManager(): def __init__(self): pass - def get_characters_from_api(self, api_id, api_key): - api = evelink.api.API(api_key=(api_id, api_key)) - # Should get characters - account = evelink.account.Account(api=api) - chars = account.characters() + chars = [] + try: + api = evelink.api.API(api_key=(api_id, api_key)) + # Should get characters + account = evelink.account.Account(api=api) + chars = account.characters() + except evelink.api.APIError as error: + print error return chars + def get_corporation_ticker_from_id(self, corp_id): + ticker = "" + try: + print corp_id + api = evelink.api.API() + corp = evelink.corp.Corp(api) + response = corp.corporation_sheet(corp_id) + print response + ticker = response[0]['ticker'] + except evelink.api.APIError as error: + print error + + return ticker + + diff --git a/templates/public/base.html b/templates/public/base.html index c771b489..89d47861 100644 --- a/templates/public/base.html +++ b/templates/public/base.html @@ -28,7 +28,10 @@ - {{ ALLIANCE_NAME }} + + + {{ ALLIANCE_NAME }} +