mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 12:30:15 +02:00
Added some more niceness. Updated eve api for pulling ticker from corp
This commit is contained in:
parent
b748c223c8
commit
7521d9fc4d
@ -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
|
@ -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'
|
||||
|
@ -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):
|
||||
|
@ -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)
|
||||
allianceuser_owner = models.ForeignKey(AllianceUser)
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -28,7 +28,10 @@
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="{% url 'auth_dashboard' %}">{{ ALLIANCE_NAME }}</a>
|
||||
<img src="https://image.eveonline.com/Alliance/{{ ALLIANCE_ID }}_64.png" alt="" class="navbar-brand">
|
||||
<a class="navbar-brand" href="{% url 'auth_dashboard' %}">
|
||||
{{ ALLIANCE_NAME }}
|
||||
</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
|
@ -8,12 +8,62 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
|
||||
<h3> Really dumb right now</h3>
|
||||
<p> Click button to add user to services</p>
|
||||
<a href="{% url 'auth_activate_forum' %}"><button type="button" class="btn btn-default">Activate Forum</button></a>
|
||||
<a href="{% url 'auth_activate_jabber' %}"><button type="button" class="btn btn-default">Activate Jabber</button></a>
|
||||
<a href="{% url 'auth_activate_mumble' %}"><button type="button" class="btn btn-default">Activate Jabber</button></a>
|
||||
|
||||
<h1 class="page-header text-center">Available Applications</h1>
|
||||
<table class="table table-bordered">
|
||||
<tr>
|
||||
<th class="text-center">Application</th>
|
||||
<th class="text-center">Username</th>
|
||||
<th class="text-center">Password</th>
|
||||
<th class="text-center">Action</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center">Forums</td>
|
||||
<td class="text-center">{{ user.forum_username }}</td>
|
||||
<td class="text-center">{{ user.forum_password }}</td>
|
||||
<td class="text-center">
|
||||
<a href="{% url 'auth_activate_forum' %}">
|
||||
<button type="button" class="btn btn-success"><span class="glyphicon glyphicon-ok"></span></button>
|
||||
</a>
|
||||
<a href="{% url 'auth_activate_forum' %}">
|
||||
<button type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span></button>
|
||||
</a>
|
||||
<a href="{% url 'auth_activate_forum' %}">
|
||||
<button type="button" class="btn btn-primary"><span class="glyphicon glyphicon-refresh"></span></button>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center">Jabber</td>
|
||||
<td class="text-center">{{ user.jabber_username }}</td>
|
||||
<td class="text-center">{{ user.jabber_password }}</td>
|
||||
<td class="text-center">
|
||||
<a href="{% url 'auth_activate_jabber' %}">
|
||||
<button type="button" class="btn btn-success"><span class="glyphicon glyphicon-ok"></span></button>
|
||||
</a>
|
||||
<a href="{% url 'auth_activate_jabber' %}">
|
||||
<button type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span></button>
|
||||
</a>
|
||||
<a href="{% url 'auth_activate_jabber' %}">
|
||||
<button type="button" class="btn btn-primary"><span class="glyphicon glyphicon-refresh"></span></button>
|
||||
</a>
|
||||
</td>
|
||||
<tr>
|
||||
<td class="text-center">Mumble</td>
|
||||
<td class="text-center">{{ user.mumble_username }}</td>
|
||||
<td class="text-center">{{ user.mumble_password }}</td>
|
||||
<td class="text-center">
|
||||
<a href="{% url 'auth_activate_mumble' %}">
|
||||
<button type="button" class="btn btn-success"><span class="glyphicon glyphicon-ok"></span></button>
|
||||
</a>
|
||||
<a href="{% url 'auth_activate_mumble' %}">
|
||||
<button type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span></button>
|
||||
</a>
|
||||
<a href="{% url 'auth_activate_mumble' %}">
|
||||
<button type="button" class="btn btn-primary"><span class="glyphicon glyphicon-refresh"></span></button>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{% endblock content %}
|
||||
|
@ -15,8 +15,9 @@
|
||||
<div class="col-sm-12">
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<h3>{{character.character_name}}</h3>
|
||||
<p><strong>Corporation: </strong>{{character.corporation_name}}</p>
|
||||
<p><strong>Alliance: </strong> {{character.alliance_name}} </p>
|
||||
<p><strong>Corporation: </strong>{{character.corporation_name}}</p>
|
||||
<p><strong>Corporation Ticker: </strong> {{character.corporation_ticker}} </p>
|
||||
</div>
|
||||
<div class="col-xs-8 col-sm-4 text-center">
|
||||
<figure>
|
||||
|
Loading…
x
Reference in New Issue
Block a user