Compare commits

..

17 Commits

Author SHA1 Message Date
Ariel Rin
321af5ec87 Version Bump v2.6.4 2020-04-17 06:56:40 +00:00
Ariel Rin
9ccf340b3d Merge branch 'error-redirects' into 'master'
Add 500 and 400, 403, 404 error redirects back to dashboard with basic message

See merge request allianceauth/allianceauth!1152
2020-04-17 06:45:01 +00:00
Aaron Kable
d7dcacb899 Add 500 and 400, 403, 404 error redirects back to dashboard with basic message 2020-04-17 06:45:01 +00:00
Ariel Rin
8addd483c2 Merge branch 'issue_1221' into 'master'
Remove support for Python 3.5

Closes #1224 and #1221

See merge request allianceauth/allianceauth!1182
2020-04-15 11:25:44 +00:00
Ariel Rin
4d27e5ac9b Merge branch 'improve_help_icon' into 'master'
Improve style of help icon

See merge request allianceauth/allianceauth!1192
2020-04-15 11:24:55 +00:00
ErikKalkoken
31290f6e80 Improve style of help icon 2020-04-11 20:23:41 +02:00
Ariel Rin
c31cc4dbee Merge branch 'mumble_displaynames' into 'master'
Mumble Display Names

See merge request allianceauth/allianceauth!1185
2020-04-06 02:19:53 +00:00
Aaron Kable
cc1f94cf61 Mumble Display Names 2020-04-06 02:19:53 +00:00
Ariel Rin
a9132b8d50 Merge branch 'fix_dev_docs' into 'master'
Add config file for readthedocs

See merge request allianceauth/allianceauth!1191
2020-04-03 13:33:30 +00:00
ErikKalkoken
7b4a9891aa Add config file for readthedocs 2020-04-03 15:18:45 +02:00
Ariel Rin
dcaaf38ecc Merge branch 'esi_update' into 'master'
Update swagger files and remove swagger file dependency from srp package

See merge request allianceauth/allianceauth!1187
2020-04-03 12:39:34 +00:00
Ariel Rin
653a8aa850 Merge branch 'improve_docu_link' into 'master'
Move docu link to top menu and open in new window

See merge request allianceauth/allianceauth!1189
2020-04-03 12:04:06 +00:00
Ariel Rin
274af11385 Merge branch 'docu_devs_update' into 'master'
Extend developer docs

See merge request allianceauth/allianceauth!1188
2020-04-03 12:03:34 +00:00
Erik Kalkoken
170b246901 Extend developer docs 2020-04-03 12:03:34 +00:00
ErikKalkoken
9ea79ea389 Move docu link to top menu and open in new window 2020-03-26 00:10:30 +01:00
ErikKalkoken
b6fdf840ef Update swagger files and remove swagger fle dependency from srp package 2020-03-25 18:00:23 +01:00
ErikKalkoken
42948386ec Remove support for Python 3.5 2020-03-21 13:16:42 +01:00
47 changed files with 2183 additions and 105 deletions

3
.gitignore vendored
View File

@@ -72,3 +72,6 @@ celerybeat-schedule
#transifex
.tx/
#other
.flake8

View File

@@ -6,11 +6,6 @@ before_script:
- python -V
- pip install wheel tox
test-3.5-core:
image: python:3.5-buster
script:
- tox -e py35-core
test-3.6-core:
image: python:3.6-buster
script:
@@ -26,11 +21,6 @@ test-3.8-core:
script:
- tox -e py38-core
test-3.5-all:
image: python:3.5-buster
script:
- tox -e py35-all
test-3.6-all:
image: python:3.6-buster
script:

27
.readthedocs.yml Normal file
View File

@@ -0,0 +1,27 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml
# Optionally build your docs in additional formats such as PDF and ePub
formats: all
# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- method: pip
path: .
extra_requirements:
- testing
system_packages: true

View File

@@ -1,6 +1,6 @@
# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
__version__ = '2.6.3'
__version__ = '2.6.4'
NAME = 'Alliance Auth v%s' % __version__
default_app_config = 'allianceauth.apps.AllianceAuthConfig'

View File

@@ -22,13 +22,6 @@ urlpatterns = [
r'^account/characters/add/$',
views.add_character,
name='add_character'
),
url(
r'^help/$',
login_required(
TemplateView.as_view(template_name='allianceauth/help.html')
),
name='help'
),
),
url(r'^dashboard/$', views.dashboard, name='dashboard'),
]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -4,3 +4,8 @@ from allianceauth import urls
urlpatterns = [
url(r'', include(urls)),
]
handler500 = 'allianceauth.views.Generic500Redirect'
handler404 = 'allianceauth.views.Generic404Redirect'
handler403 = 'allianceauth.views.Generic403Redirect'
handler400 = 'allianceauth.views.Generic400Redirect'

View File

@@ -36,7 +36,7 @@ class DiscordService(ServicesHook):
def sync_nickname(self, user):
logger.debug('Syncing %s nickname for user %s' % (self.name, user))
DiscordTasks.update_nickname.delay(user.pk)
DiscordTasks.update_nickname.apply_async(args=[user.pk], countdown=5)
def update_all_groups(self):
logger.debug('Update all %s groups called' % self.name)

View File

@@ -27,7 +27,12 @@ class DiscordViewsTestCase(WebTest):
self.login()
manager.generate_oauth_redirect_url.return_value = '/example.com/oauth/'
response = self.app.get('/discord/activate/', auto_follow=False)
self.assertRedirects(response, expected_url='/example.com/oauth/', target_status_code=404)
self.assertRedirects(
response,
expected_url="/example.com/oauth/",
target_status_code=404,
fetch_redirect_response=False,
)
@mock.patch(MODULE_PATH + '.tasks.DiscordOAuthManager')
def test_callback(self, manager):

View File

@@ -40,6 +40,11 @@ class MumbleService(ServicesHook):
if MumbleTasks.has_account(user):
MumbleTasks.update_groups.delay(user.pk)
def sync_nickname(self, user):
logger.debug("Updating %s nickname for %s" % (self.name, user))
if MumbleTasks.has_account(user):
MumbleTasks.update_display_name.apply_async(args=[user.pk], countdown=5) # cooldown on this task to ensure DB clean when syncing
def validate_user(self, user):
if MumbleTasks.has_account(user) and not self.service_active_for_user(user):
self.delete_user(user, notify_user=True)

View File

@@ -0,0 +1,17 @@
# Generated by Django 2.2.9 on 2020-03-16 07:49
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('mumble', '0007_not_null_user'),
]
operations = [
migrations.AddField(
model_name='mumbleuser',
name='display_name',
field=models.CharField(max_length=254, null=True),
)
]

View File

@@ -0,0 +1,37 @@
from django.db import migrations, models
from ..auth_hooks import MumbleService
from allianceauth.services.hooks import NameFormatter
def fwd_func(apps, schema_editor):
MumbleUser = apps.get_model("mumble", "MumbleUser")
db_alias = schema_editor.connection.alias
all_users = MumbleUser.objects.using(db_alias).all()
for user in all_users:
display_name = NameFormatter(MumbleService(), user.user).format_name()
user.display_name = display_name
user.save()
def rev_func(apps, schema_editor):
MumbleUser = apps.get_model("mumble", "MumbleUser")
db_alias = schema_editor.connection.alias
all_users = MumbleUser.objects.using(db_alias).all()
for user in all_users:
user.display_name = None
user.save()
class Migration(migrations.Migration):
dependencies = [
('mumble', '0008_mumbleuser_display_name'),
]
operations = [
migrations.RunPython(fwd_func, rev_func),
migrations.AlterField(
model_name='mumbleuser',
name='display_name',
field=models.CharField(max_length=254, unique=True),
preserve_default=False,
),
]

View File

@@ -15,10 +15,14 @@ class MumbleManager(models.Manager):
HASH_FN = 'bcrypt-sha256'
@staticmethod
def get_username(user):
def get_display_name(user):
from .auth_hooks import MumbleService
return NameFormatter(MumbleService(), user).format_name()
@staticmethod
def get_username(user):
return user.profile.main_character.character_name # main character as the user.username may be incorect
@staticmethod
def sanitise_username(username):
return username.replace(" ", "_")
@@ -32,20 +36,26 @@ class MumbleManager(models.Manager):
return bcrypt_sha256.encrypt(password.encode('utf-8'))
def create(self, user):
username = self.get_username(user)
logger.debug("Creating mumble user with username {}".format(username))
username_clean = self.sanitise_username(username)
password = self.generate_random_pass()
pwhash = self.gen_pwhash(password)
logger.debug("Proceeding with mumble user creation: clean username {}, pwhash starts with {}".format(
username_clean, pwhash[0:5]))
logger.info("Creating mumble user {}".format(username_clean))
try:
username = self.get_username(user)
logger.debug("Creating mumble user with username {}".format(username))
username_clean = self.sanitise_username(username)
display_name = self.get_display_name(user)
password = self.generate_random_pass()
pwhash = self.gen_pwhash(password)
logger.debug("Proceeding with mumble user creation: clean username {}, pwhash starts with {}".format(
username_clean, pwhash[0:5]))
logger.info("Creating mumble user {}".format(username_clean))
result = super(MumbleManager, self).create(user=user, username=username_clean,
pwhash=pwhash, hashfn=self.HASH_FN)
result.update_groups()
result.credentials.update({'username': result.username, 'password': password})
return result
result = super(MumbleManager, self).create(user=user, username=username_clean,
pwhash=pwhash, hashfn=self.HASH_FN,
display_name=display_name)
result.update_groups()
result.credentials.update({'username': result.username, 'password': password})
return result
except AttributeError: # No Main or similar errors
return False
return False
def user_exists(self, username):
return self.filter(username=username).exists()
@@ -59,6 +69,8 @@ class MumbleUser(AbstractServiceModel):
objects = MumbleManager()
display_name = models.CharField(max_length=254, unique=True)
def __str__(self):
return self.username
@@ -91,6 +103,12 @@ class MumbleUser(AbstractServiceModel):
self.save()
return True
def update_display_name(self):
logger.info("Updating mumble user {} display name".format(self.user))
self.display_name = MumbleManager.get_display_name(self.user)
self.save()
return True
class Meta:
permissions = (
("access_mumble", u"Can access the Mumble service"),

View File

@@ -45,9 +45,37 @@ class MumbleTasks:
logger.debug("User %s does not have a mumble account, skipping" % user)
return False
@staticmethod
@shared_task(bind=True, name="mumble.update_display_name", base=QueueOnce)
def update_display_name(self, pk):
user = User.objects.get(pk=pk)
logger.debug("Updating mumble groups for user %s" % user)
if MumbleTasks.has_account(user):
try:
if not user.mumble.update_display_name():
raise Exception("Display Name Sync failed")
logger.debug("Updated user %s mumble display name." % user)
return True
except MumbleUser.DoesNotExist:
logger.info("Mumble display name sync failed for {}, user does not have a mumble account".format(user))
except:
logger.exception("Mumble display name sync failed for %s, retrying in 10 mins" % user)
raise self.retry(countdown=60 * 10)
else:
logger.debug("User %s does not have a mumble account, skipping" % user)
return False
@staticmethod
@shared_task(name="mumble.update_all_groups")
def update_all_groups():
logger.debug("Updating ALL mumble groups")
for mumble_user in MumbleUser.objects.exclude(username__exact=''):
MumbleTasks.update_groups.delay(mumble_user.user.pk)
@staticmethod
@shared_task(name="mumble.update_all_display_names")
def update_all_display_names():
logger.debug("Updating ALL mumble display names")
for mumble_user in MumbleUser.objects.exclude(username__exact=''):
MumbleTasks.update_display_name.delay(mumble_user.user.pk)

View File

@@ -25,6 +25,9 @@ class MumbleHooksTestCase(TestCase):
def setUp(self):
self.member = 'member_user'
member = AuthUtils.create_member(self.member)
AuthUtils.add_main_character(member, 'auth_member', '12345', corp_id='111', corp_name='Test Corporation',
corp_ticker='TESTR')
member = User.objects.get(pk=member.pk)
MumbleUser.objects.create(user=member)
self.none_user = 'none_user'
none_user = AuthUtils.create_user(self.none_user)
@@ -122,23 +125,45 @@ class MumbleViewsTestCase(TestCase):
self.member.save()
AuthUtils.add_main_character(self.member, 'auth_member', '12345', corp_id='111', corp_name='Test Corporation',
corp_ticker='TESTR')
self.member = User.objects.get(pk=self.member.pk)
add_permissions()
def login(self):
self.client.force_login(self.member)
def test_activate(self):
def test_activate_update(self):
self.login()
expected_username = '[TESTR]auth_member'
expected_username = 'auth_member'
expected_displayname = '[TESTR]auth_member'
response = self.client.get(urls.reverse('mumble:activate'), follow=False)
self.assertEqual(response.status_code, 200)
self.assertContains(response, expected_username)
# create
mumble_user = MumbleUser.objects.get(user=self.member)
self.assertEqual(mumble_user.username, expected_username)
self.assertTrue(MumbleUser.objects.user_exists(expected_username))
self.assertEqual(str(mumble_user), expected_username)
self.assertEqual(mumble_user.display_name, expected_displayname)
self.assertTrue(mumble_user.pwhash)
self.assertIn('Guest', mumble_user.groups)
self.assertIn('Member', mumble_user.groups)
self.assertIn(',', mumble_user.groups)
# test update
self.member.profile.main_character.character_name = "auth_member_updated"
self.member.profile.main_character.corporation_ticker = "TESTU"
self.member.profile.main_character.save()
mumble_user.update_display_name()
mumble_user = MumbleUser.objects.get(user=self.member)
expected_displayname = '[TESTU]auth_member_updated'
self.assertEqual(mumble_user.username, expected_username)
self.assertTrue(MumbleUser.objects.user_exists(expected_username))
self.assertEqual(str(mumble_user), expected_username)
self.assertEqual(mumble_user.display_name, expected_displayname)
self.assertTrue(mumble_user.pwhash)
self.assertIn('Guest', mumble_user.groups)
self.assertIn('Member', mumble_user.groups)
self.assertIn(',', mumble_user.groups)
def test_deactivate_post(self):
self.login()
@@ -171,7 +196,6 @@ class MumbleViewsTestCase(TestCase):
self.assertTemplateUsed(response, 'services/service_credentials.html')
self.assertContains(response, 'auth_member')
class MumbleManagerTestCase(TestCase):
def setUp(self):
from .models import MumbleManager

View File

@@ -1,6 +1,7 @@
import logging
from django.contrib.auth.models import User, Group, Permission
from django.core.exceptions import ObjectDoesNotExist
from django.db import transaction
from django.db.models.signals import m2m_changed
from django.db.models.signals import pre_delete
@@ -11,6 +12,7 @@ from .tasks import disable_user
from allianceauth.authentication.models import State, UserProfile
from allianceauth.authentication.signals import state_changed
from allianceauth.eveonline.models import EveCharacter
logger = logging.getLogger(__name__)
@@ -157,14 +159,45 @@ def disable_services_on_inactive(sender, instance, *args, **kwargs):
@receiver(pre_save, sender=UserProfile)
def disable_services_on_no_main(sender, instance, *args, **kwargs):
if not instance.pk:
def process_main_character_change(sender, instance, *args, **kwargs):
if not instance.pk: # ignore
# new model being created
return
try:
old_instance = UserProfile.objects.get(pk=instance.pk)
if old_instance.main_character and not instance.main_character:
if old_instance.main_character and not instance.main_character: # lost main char disable services
logger.info("Disabling services due to loss of main character for user {0}".format(instance.user))
disable_user(instance.user)
elif old_instance.main_character is not instance.main_character: # swapping/changing main character
logger.info("Updating Names due to change of main character for user {0}".format(instance.user))
for svc in ServicesHook.get_services():
try:
svc.validate_user(instance.user)
svc.sync_nickname(instance.user)
except:
logger.exception('Exception running sync_nickname for services module %s on user %s' % (svc, instance))
except UserProfile.DoesNotExist:
pass
@receiver(pre_save, sender=EveCharacter)
def process_main_character_update(sender, instance, *args, **kwargs):
try:
if instance.userprofile:
old_instance = EveCharacter.objects.get(pk=instance.pk)
if not instance.character_name == old_instance.character_name or \
not instance.corporation_name == old_instance.corporation_name or \
not instance.alliance_name == old_instance.alliance_name:
logger.info("syncing service nickname for user {0}".format(instance.userprofile.user))
for svc in ServicesHook.get_services():
try:
svc.validate_user(instance.userprofile.user)
svc.sync_nickname(instance.userprofile.user)
except:
logger.exception('Exception running sync_nickname for services module %s on user %s' % (svc, instance))
except ObjectDoesNotExist: # not a main char ignore
pass

View File

@@ -1,21 +1,17 @@
from allianceauth import NAME
from esi.clients import esi_client_factory
import requests
import logging
import os
import requests
from allianceauth import NAME
from allianceauth.eveonline.providers import provider
logger = logging.getLogger(__name__)
SWAGGER_SPEC_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'swagger.json')
"""
Swagger Operations:
get_killmails_killmail_id_killmail_hash
"""
class SRPManager:
def __init__(self):
pass
@staticmethod
def get_kill_id(killboard_link):
num_set = '0123456789'
@@ -34,18 +30,23 @@ class SRPManager:
if result:
killmail_id = result['killmail_id']
killmail_hash = result['zkb']['hash']
c = esi_client_factory(spec_file=SWAGGER_SPEC_PATH)
km = c.Killmails.get_killmails_killmail_id_killmail_hash(killmail_id=killmail_id,
killmail_hash=killmail_hash).result()
c = provider.client
km = c.Killmails.get_killmails_killmail_id_killmail_hash(
killmail_id=killmail_id,
killmail_hash=killmail_hash
).result()
else:
raise ValueError("Invalid Kill ID")
if km:
ship_type = km['victim']['ship_type_id']
logger.debug("Ship type for kill ID %s is %s" % (kill_id, ship_type))
logger.debug(
"Ship type for kill ID %s is %s" % (kill_id, ship_type)
)
ship_value = result['zkb']['totalValue']
logger.debug("Total loss value for kill id %s is %s" % (kill_id, ship_value))
logger.debug(
"Total loss value for kill id %s is %s" % (kill_id, ship_value)
)
victim_id = km['victim']['character_id']
return ship_type, ship_value, victim_id
else:
raise ValueError("Invalid Kill ID or Hash.")

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
# Create your tests here.

View File

View File

@@ -0,0 +1,72 @@
import inspect
import json
import os
from unittest.mock import patch, Mock
from django.test import TestCase
from ..managers import SRPManager
MODULE_PATH = 'allianceauth.srp.managers'
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(
inspect.currentframe()
)))
def load_data(filename):
"""loads given JSON file from `testdata` sub folder and returns content"""
with open(
currentdir + '/testdata/%s.json' % filename, 'r', encoding='utf-8'
) as f:
data = json.load(f)
return data
class TestSrpManager(TestCase):
def test_can_extract_kill_id(self):
link = 'https://zkillboard.com/kill/81973979/'
expected = 81973979
self.assertEqual(int(SRPManager.get_kill_id(link)), expected)
@patch(MODULE_PATH + '.provider')
@patch(MODULE_PATH + '.requests.get')
def test_can_get_kill_data(self, mock_get, mock_provider):
mock_get.return_value.json.return_value = load_data(
'zkillboard_killmail_api_81973979'
)
mock_provider.client.Killmails.\
get_killmails_killmail_id_killmail_hash.return_value.\
result.return_value = load_data(
'get_killmails_killmail_id_killmail_hash_81973979'
)
ship_type, ship_value, victim_id = SRPManager.get_kill_data(81973979)
self.assertEqual(ship_type, 19720)
self.assertEqual(ship_value, 3177859026.86)
self.assertEqual(victim_id, 93330670)
@patch(MODULE_PATH + '.requests.get')
def test_invalid_id_for_zkb_raises_exception(self, mock_get):
mock_get.return_value.json.return_value = ['']
with self.assertRaises(ValueError):
ship_type, ship_value, victim_id = SRPManager.get_kill_data(81973979)
@patch(MODULE_PATH + '.provider')
@patch(MODULE_PATH + '.requests.get')
def test_invalid_id_for_esi_raises_exception(
self, mock_get, mock_provider
):
mock_get.return_value.json.return_value = load_data(
'zkillboard_killmail_api_81973979'
)
mock_provider.client.Killmails.\
get_killmails_killmail_id_killmail_hash.return_value.\
result.return_value = None
with self.assertRaises(ValueError):
ship_type, ship_value, victim_id = SRPManager.get_kill_data(81973979)

View File

@@ -0,0 +1,953 @@
{
"attackers": [
{
"alliance_id": 99009221,
"character_id": 92606407,
"corporation_id": 98343297,
"damage_done": 65236,
"final_blow": false,
"security_status": -6.4,
"ship_type_id": 47271,
"weapon_type_id": 47271
},
{
"alliance_id": 99006941,
"character_id": 95104060,
"corporation_id": 98416134,
"damage_done": 56425,
"final_blow": true,
"security_status": -1.1,
"ship_type_id": 17738,
"weapon_type_id": 2929
},
{
"alliance_id": 1220922756,
"character_id": 92793488,
"corporation_id": 679468421,
"damage_done": 55225,
"final_blow": false,
"security_status": -3.4,
"ship_type_id": 47271,
"weapon_type_id": 47271
},
{
"alliance_id": 99006941,
"character_id": 90376343,
"corporation_id": 98416134,
"damage_done": 51941,
"final_blow": false,
"security_status": 0.6,
"ship_type_id": 17738,
"weapon_type_id": 28215
},
{
"alliance_id": 99006941,
"character_id": 676848606,
"corporation_id": 98416134,
"damage_done": 45906,
"final_blow": false,
"security_status": -1.6,
"ship_type_id": 17738,
"weapon_type_id": 31894
},
{
"alliance_id": 99006941,
"character_id": 96692394,
"corporation_id": 98416134,
"damage_done": 44900,
"final_blow": false,
"security_status": -1.9,
"ship_type_id": 17738,
"weapon_type_id": 31894
},
{
"alliance_id": 99006941,
"character_id": 96624133,
"corporation_id": 98416134,
"damage_done": 44146,
"final_blow": false,
"security_status": -9.1,
"ship_type_id": 17738,
"weapon_type_id": 2929
},
{
"character_id": 95050100,
"corporation_id": 98497860,
"damage_done": 41517,
"final_blow": false,
"security_status": -3,
"ship_type_id": 17738,
"weapon_type_id": 17738
},
{
"alliance_id": 99006941,
"character_id": 458944878,
"corporation_id": 98416134,
"damage_done": 39888,
"final_blow": false,
"security_status": -6.5,
"ship_type_id": 17738,
"weapon_type_id": 28215
},
{
"alliance_id": 99006941,
"character_id": 96029663,
"corporation_id": 98433294,
"damage_done": 39406,
"final_blow": false,
"security_status": -6.7,
"ship_type_id": 17738,
"weapon_type_id": 28215
},
{
"alliance_id": 99006941,
"character_id": 90626300,
"corporation_id": 98416134,
"damage_done": 37808,
"final_blow": false,
"security_status": -0.6,
"ship_type_id": 17738,
"weapon_type_id": 31894
},
{
"alliance_id": 99006941,
"character_id": 90740848,
"corporation_id": 98416134,
"damage_done": 36342,
"final_blow": false,
"security_status": -1.8,
"ship_type_id": 17738,
"weapon_type_id": 2929
},
{
"alliance_id": 99006941,
"character_id": 1105550086,
"corporation_id": 98416134,
"damage_done": 35971,
"final_blow": false,
"security_status": -2.6,
"ship_type_id": 17738,
"weapon_type_id": 28215
},
{
"alliance_id": 99003581,
"character_id": 94727582,
"corporation_id": 98514029,
"damage_done": 33501,
"final_blow": false,
"security_status": 3.2,
"ship_type_id": 17738,
"weapon_type_id": 31894
},
{
"alliance_id": 99006941,
"character_id": 90368224,
"corporation_id": 98416134,
"damage_done": 32116,
"final_blow": false,
"security_status": -2.4,
"ship_type_id": 17738,
"weapon_type_id": 2929
},
{
"alliance_id": 99006941,
"character_id": 90001595,
"corporation_id": 98416134,
"damage_done": 31387,
"final_blow": false,
"security_status": -0.8,
"ship_type_id": 17738,
"weapon_type_id": 2456
},
{
"alliance_id": 99006941,
"character_id": 95278082,
"corporation_id": 98418839,
"damage_done": 31250,
"final_blow": false,
"security_status": 1.8,
"ship_type_id": 17738,
"weapon_type_id": 28215
},
{
"alliance_id": 99006941,
"character_id": 91971344,
"corporation_id": 98217414,
"damage_done": 31247,
"final_blow": false,
"security_status": -1,
"ship_type_id": 29986,
"weapon_type_id": 29986
},
{
"alliance_id": 99006941,
"character_id": 2113448089,
"corporation_id": 98418839,
"damage_done": 30174,
"final_blow": false,
"security_status": -0.4,
"ship_type_id": 17738,
"weapon_type_id": 17738
},
{
"alliance_id": 99006941,
"character_id": 2115912819,
"corporation_id": 98416134,
"damage_done": 29242,
"final_blow": false,
"security_status": -2.1,
"ship_type_id": 17738,
"weapon_type_id": 17738
},
{
"alliance_id": 99006941,
"character_id": 2115885290,
"corporation_id": 98416134,
"damage_done": 28009,
"final_blow": false,
"security_status": -2,
"ship_type_id": 17738,
"weapon_type_id": 17738
},
{
"alliance_id": 99006941,
"character_id": 95746094,
"corporation_id": 98416134,
"damage_done": 27565,
"final_blow": false,
"security_status": -7.8,
"ship_type_id": 17738,
"weapon_type_id": 17738
},
{
"alliance_id": 99003581,
"character_id": 90345487,
"corporation_id": 98514029,
"damage_done": 26016,
"final_blow": false,
"security_status": 0.5,
"ship_type_id": 17738,
"weapon_type_id": 17738
},
{
"alliance_id": 99006941,
"character_id": 2115874625,
"corporation_id": 98416134,
"damage_done": 25679,
"final_blow": false,
"security_status": -1.9,
"ship_type_id": 17738,
"weapon_type_id": 17738
},
{
"alliance_id": 99006941,
"character_id": 2115880975,
"corporation_id": 98416134,
"damage_done": 23320,
"final_blow": false,
"security_status": -3.5,
"ship_type_id": 17738,
"weapon_type_id": 17738
},
{
"alliance_id": 99006941,
"character_id": 96667534,
"corporation_id": 98416134,
"damage_done": 21699,
"final_blow": false,
"security_status": -0.6,
"ship_type_id": 17738,
"weapon_type_id": 17738
},
{
"alliance_id": 99006941,
"character_id": 2115866658,
"corporation_id": 98416134,
"damage_done": 20506,
"final_blow": false,
"security_status": -1.3,
"ship_type_id": 17738,
"weapon_type_id": 17738
},
{
"alliance_id": 99006941,
"character_id": 97105982,
"corporation_id": 98217414,
"damage_done": 19400,
"final_blow": false,
"security_status": 0,
"ship_type_id": 17738,
"weapon_type_id": 17738
},
{
"alliance_id": 99008704,
"character_id": 96110151,
"corporation_id": 98614116,
"damage_done": 17547,
"final_blow": false,
"security_status": -5.5,
"ship_type_id": 17740,
"weapon_type_id": 17740
},
{
"alliance_id": 99009221,
"character_id": 90526637,
"corporation_id": 98343297,
"damage_done": 16791,
"final_blow": false,
"security_status": -1.9,
"ship_type_id": 33157,
"weapon_type_id": 21640
},
{
"alliance_id": 99006941,
"character_id": 2112972140,
"corporation_id": 98416134,
"damage_done": 16749,
"final_blow": false,
"security_status": -1.2,
"ship_type_id": 17738,
"weapon_type_id": 17738
},
{
"alliance_id": 99006941,
"character_id": 2115879470,
"corporation_id": 98416134,
"damage_done": 14402,
"final_blow": false,
"security_status": -3.9,
"ship_type_id": 17738,
"weapon_type_id": 17738
},
{
"alliance_id": 99006941,
"character_id": 95698217,
"corporation_id": 98416134,
"damage_done": 11546,
"final_blow": false,
"security_status": -5.2,
"ship_type_id": 17738,
"weapon_type_id": 17738
},
{
"alliance_id": 99006941,
"character_id": 353190170,
"corporation_id": 98416134,
"damage_done": 10896,
"final_blow": false,
"security_status": -4.7,
"ship_type_id": 17738,
"weapon_type_id": 28215
},
{
"alliance_id": 99006941,
"character_id": 91546798,
"corporation_id": 98217414,
"damage_done": 9872,
"final_blow": false,
"security_status": -0.7,
"ship_type_id": 17738,
"weapon_type_id": 17738
},
{
"alliance_id": 99009221,
"character_id": 91578428,
"corporation_id": 302750157,
"damage_done": 7699,
"final_blow": false,
"security_status": -8.7,
"ship_type_id": 17920,
"weapon_type_id": 2185
},
{
"alliance_id": 99006941,
"character_id": 94105463,
"corporation_id": 98418839,
"damage_done": 5265,
"final_blow": false,
"security_status": -3.3,
"ship_type_id": 49713,
"weapon_type_id": 2488
},
{
"alliance_id": 99006941,
"character_id": 95526304,
"corporation_id": 98418839,
"damage_done": 3967,
"final_blow": false,
"security_status": -8.7,
"ship_type_id": 22474,
"weapon_type_id": 2488
},
{
"alliance_id": 99006941,
"character_id": 90331727,
"corporation_id": 98416134,
"damage_done": 2940,
"final_blow": false,
"security_status": -1.2,
"ship_type_id": 49713,
"weapon_type_id": 2185
},
{
"alliance_id": 99006941,
"character_id": 2115880459,
"corporation_id": 98416134,
"damage_done": 2301,
"final_blow": false,
"security_status": 4.1,
"ship_type_id": 17738,
"weapon_type_id": 17738
},
{
"alliance_id": 99009547,
"character_id": 1832436128,
"corporation_id": 98618666,
"damage_done": 937,
"final_blow": false,
"security_status": -8.1,
"ship_type_id": 17740,
"weapon_type_id": 3186
},
{
"alliance_id": 99009547,
"character_id": 96632877,
"corporation_id": 98618666,
"damage_done": 430,
"final_blow": false,
"security_status": -5.4,
"ship_type_id": 17740,
"weapon_type_id": 3186
},
{
"alliance_id": 99006941,
"character_id": 96146444,
"corporation_id": 98416134,
"damage_done": 126,
"final_blow": false,
"security_status": -1.2,
"ship_type_id": 49713,
"weapon_type_id": 49713
},
{
"character_id": 2116393370,
"corporation_id": 98593091,
"damage_done": 111,
"final_blow": false,
"security_status": 0,
"ship_type_id": 602,
"weapon_type_id": 27321
},
{
"alliance_id": 99006941,
"character_id": 93745147,
"corporation_id": 98418839,
"damage_done": 6,
"final_blow": false,
"security_status": -1.6,
"ship_type_id": 12021,
"weapon_type_id": 2873
},
{
"alliance_id": 99006941,
"character_id": 95610468,
"corporation_id": 98416134,
"damage_done": 4,
"final_blow": false,
"security_status": -2.2,
"ship_type_id": 12017,
"weapon_type_id": 484
},
{
"alliance_id": 99009221,
"character_id": 92304254,
"corporation_id": 98343297,
"damage_done": 1,
"final_blow": false,
"security_status": -9.3,
"ship_type_id": 22474,
"weapon_type_id": 22474
},
{
"alliance_id": 99006941,
"character_id": 96624034,
"corporation_id": 98493618,
"damage_done": 0,
"final_blow": false,
"security_status": -2.1,
"ship_type_id": 12017,
"weapon_type_id": 37611
},
{
"alliance_id": 99006941,
"character_id": 95388762,
"corporation_id": 98416134,
"damage_done": 0,
"final_blow": false,
"security_status": 0.4,
"ship_type_id": 12017,
"weapon_type_id": 3001
},
{
"alliance_id": 99006941,
"character_id": 1290463210,
"corporation_id": 98416134,
"damage_done": 0,
"final_blow": false,
"security_status": -1.9,
"ship_type_id": 49713,
"weapon_type_id": 23707
},
{
"alliance_id": 99009547,
"character_id": 95748579,
"corporation_id": 98618666,
"damage_done": 0,
"final_blow": false,
"security_status": -7.9,
"ship_type_id": 643,
"weapon_type_id": 16497
},
{
"alliance_id": 99006941,
"character_id": 2114899882,
"corporation_id": 98416134,
"damage_done": 0,
"final_blow": false,
"security_status": -1.7,
"ship_type_id": 12017,
"weapon_type_id": 484
},
{
"alliance_id": 99006941,
"character_id": 95624225,
"corporation_id": 98416134,
"damage_done": 0,
"final_blow": false,
"security_status": -9.2,
"ship_type_id": 12017,
"weapon_type_id": 37608
},
{
"alliance_id": 99006941,
"character_id": 93452185,
"corporation_id": 98416134,
"damage_done": 0,
"final_blow": false,
"security_status": -2.1,
"ship_type_id": 22474,
"weapon_type_id": 7537
},
{
"alliance_id": 99006941,
"character_id": 2114109824,
"corporation_id": 98416134,
"damage_done": 0,
"final_blow": false,
"security_status": -2.1,
"ship_type_id": 49713,
"weapon_type_id": 484
},
{
"alliance_id": 99006941,
"character_id": 2113100583,
"corporation_id": 98416134,
"damage_done": 0,
"final_blow": false,
"security_status": -0.2,
"ship_type_id": 49713,
"weapon_type_id": 484
}
],
"killmail_id": 81973979,
"killmail_time": "2020-03-01T13:10:55Z",
"solar_system_id": 30002537,
"victim": {
"alliance_id": 99009333,
"character_id": 93330670,
"corporation_id": 98267621,
"damage_taken": 1127412,
"items": [
{
"flag": 5,
"item_type_id": 41332,
"quantity_destroyed": 3,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 41332,
"quantity_dropped": 3,
"singleton": 0
},
{
"flag": 27,
"item_type_id": 20847,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 155,
"item_type_id": 33474,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 18,
"item_type_id": 2048,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 28,
"item_type_id": 4292,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 29001,
"quantity_dropped": 1,
"singleton": 0
},
{
"flag": 22,
"item_type_id": 41218,
"quantity_dropped": 1,
"singleton": 0
},
{
"flag": 133,
"item_type_id": 16275,
"quantity_destroyed": 1125,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 41330,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 41330,
"quantity_dropped": 4,
"singleton": 0
},
{
"flag": 94,
"item_type_id": 31452,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 20028,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 20028,
"quantity_dropped": 2,
"singleton": 0
},
{
"flag": 155,
"item_type_id": 41489,
"quantity_dropped": 48,
"singleton": 0
},
{
"flag": 13,
"item_type_id": 18708,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 21,
"item_type_id": 1978,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 20026,
"quantity_destroyed": 3,
"singleton": 0
},
{
"flag": 29,
"item_type_id": 20847,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 21,
"item_type_id": 29001,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 155,
"item_type_id": 16275,
"quantity_dropped": 1250,
"singleton": 0
},
{
"flag": 155,
"item_type_id": 16299,
"quantity_destroyed": 6,
"singleton": 0
},
{
"flag": 155,
"item_type_id": 16299,
"quantity_dropped": 2,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 41489,
"quantity_dropped": 12,
"singleton": 0
},
{
"flag": 29,
"item_type_id": 37298,
"quantity_dropped": 1,
"singleton": 0
},
{
"flag": 17,
"item_type_id": 40351,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 19,
"item_type_id": 41491,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 12,
"item_type_id": 2364,
"quantity_dropped": 1,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 20030,
"quantity_dropped": 3,
"singleton": 0
},
{
"flag": 14,
"item_type_id": 18708,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 28999,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 93,
"item_type_id": 30993,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 11,
"item_type_id": 2364,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 20,
"item_type_id": 29001,
"quantity_dropped": 1,
"singleton": 0
},
{
"flag": 15,
"item_type_id": 40351,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 19,
"item_type_id": 41489,
"quantity_dropped": 4,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 21254,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 21254,
"quantity_dropped": 1,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 20032,
"quantity_destroyed": 3,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 20032,
"quantity_dropped": 1,
"singleton": 0
},
{
"flag": 16,
"item_type_id": 40351,
"quantity_dropped": 1,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 20843,
"quantity_dropped": 3,
"singleton": 0
},
{
"flag": 31,
"item_type_id": 37298,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 20845,
"quantity_destroyed": 3,
"singleton": 0
},
{
"flag": 92,
"item_type_id": 30993,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 31,
"item_type_id": 20847,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 133,
"item_type_id": 16274,
"quantity_dropped": 141666,
"singleton": 0
},
{
"flag": 20,
"item_type_id": 1978,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 20847,
"quantity_destroyed": 6,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 20847,
"quantity_dropped": 3,
"singleton": 0
},
{
"flag": 5,
"item_type_id": 21246,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 27,
"item_type_id": 37298,
"quantity_dropped": 1,
"singleton": 0
},
{
"flag": 90,
"item_type_id": 585,
"items": [
{
"flag": 94,
"item_type_id": 31159,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 20,
"item_type_id": 3831,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 93,
"item_type_id": 31159,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 22,
"item_type_id": 9568,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 12,
"item_type_id": 1405,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 92,
"item_type_id": 31159,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 21,
"item_type_id": 2553,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 11,
"item_type_id": 1405,
"quantity_destroyed": 1,
"singleton": 0
},
{
"flag": 19,
"item_type_id": 5971,
"quantity_destroyed": 1,
"singleton": 0
}
],
"quantity_destroyed": 1,
"singleton": 0
}
],
"position": {
"x": 55026869426.47358,
"y": 7310382040.828209,
"z": -163690355689.8978
},
"ship_type_id": 19720
}
}

View File

@@ -0,0 +1,15 @@
[
{
"killmail_id": 81973979,
"zkb": {
"locationID": 60004816,
"hash": "e88a5fa7f342fa658ebe74a055b7679e28b05628",
"fittedValue": 1532365686.21,
"totalValue": 3177859026.86,
"points": 1,
"npc": false,
"solo": false,
"awox": false
}
}
]

View File

@@ -1,18 +0,0 @@
{% extends "allianceauth/base.html" %}
{% load i18n %}
{% block page_title %}{% trans "Help" %}{% endblock page_title %}
{% block content %}
<div class="col-lg-12">
<h1 class="page-header text-center">{% trans "Help" %}</h1>
<div class="container-fluid">
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="https://allianceauth.readthedocs.io/en/latest/features/"></iframe>
</div>
</div>
</div>
{% endblock content %}

View File

@@ -26,15 +26,7 @@
{% endif %}
{% menu_items %}
{% if user.is_superuser %}
<li>
<a class="{% navactive request 'authentication:help' %}"
href="{% url 'authentication:help' %}">
<i class="fa fa-question fa-fw"></i> {% trans "Help" %}
</a>
</li>
{% endif %}
</ul>
</div>
</div>

View File

@@ -39,6 +39,13 @@
{% else %}
<li><a href="{% url 'authentication:login' %}">{% trans "Login" %}</a></li>
{% endif %}
{% if user.is_superuser %}
<li>
<a class="navbar-brand" style="margin-left: -4px;" href="https://allianceauth.readthedocs.io/" target="_blank">
<i class="fa fa-question-circle fa-fw"></i>
</a>
</li>
{% endif %}
</ul>
<form id="f-lang-select" class="navbar-form navbar-right" action="{% url 'set_language' %}" method="post">
{% csrf_token %}

View File

@@ -1,13 +1,15 @@
from django.views.generic.base import View
from django.http import HttpResponseRedirect
from django.shortcuts import redirect
from django.contrib import messages
class NightModeRedirectView(View):
SESSION_VAR = 'NIGHT_MODE'
SESSION_VAR = "NIGHT_MODE"
def get(self, request, *args, **kwargs):
request.session[self.SESSION_VAR] = not self.night_mode_state(request)
return HttpResponseRedirect(request.GET.get('next', '/'))
return HttpResponseRedirect(request.GET.get("next", "/"))
@classmethod
def night_mode_state(cls, request):
@@ -17,3 +19,39 @@ class NightModeRedirectView(View):
# Session is middleware
# Sometimes request wont have a session attribute
return False
def Generic500Redirect(request):
messages.error(
request,
"Auth encountered an error processing your request, please try again. "
"If the error persists, please contact the administrators. (500 Internal Server Error)",
)
return redirect("authentication:dashboard")
def Generic404Redirect(request, exception):
messages.error(
request,
"Page does not exist. If you believe this is in error please contact the administrators. "
"(404 Page Not Found)",
)
return redirect("authentication:dashboard")
def Generic403Redirect(request, exception):
messages.error(
request,
"You do not have permission to access the requested page. "
"If you believe this is in error please contact the administrators. (403 Permission Denied)",
)
return redirect("authentication:dashboard")
def Generic400Redirect(request, exception):
messages.error(
request,
"Auth encountered an error processing your request, please try again. "
"If the error persists, please contact the administrators. (400 Bad Request)",
)
return redirect("authentication:dashboard")

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

View File

@@ -18,7 +18,10 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('.'))
import django
sys.path.insert(0, os.path.abspath('..'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings_all'
django.setup()
# on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
@@ -38,7 +41,9 @@ from recommonmark.transform import AutoStructify
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = []
extensions = [
'sphinx.ext.autodoc',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -148,6 +153,9 @@ man_pages = [
[author], 1)
]
# -- Options for autodoc -------------------------------------------------
add_module_names = False
# -- Options for Texinfo output -------------------------------------------

View File

@@ -0,0 +1,463 @@
# Development on Windows 10 with WSL and Visual Studio Code
This document describes step-by-step how to setup a complete development environment for Alliance Auth apps on Windows 10 with Windows Subsystem for Linux (WSL) and Visual Studio Code.
The main benefit of this setup is that it runs all services and code in the native Linux environment (WSL) and at the same time can be full controlled from within a comfortable Windows IDE (Visual Studio Code) including code debugging.
In addition all tools described in this guide are open source or free software.
```eval_rst
.. hint::
This guide is meant for development purposes only and not for installing AA in a production environment. For production installation please see chapter **Installation**.
```
## Overview
The development environment consists of the following components:
- Visual Studio Code with Remote WSL and Python extension
- WSL with Ubunutu 18.04. LTS
- Python 3.6 environment on WSL
- MySQL server on WSL
- Redis on WSL
- Alliance Auth on WSL
- Celery on WSL
We will use the build-in Django development webserver, so we don't need to setup a WSGI server or a web server.
## Requirement
The only requirement is a PC with Windows 10 and Internet connection in order to download the additional software components.
## Windows installation
### Windows Subsystem for Linux
- Install from here: [Microsoft docs](https://docs.microsoft.com/en-us/windows/wsl/install-win10)
- Choose Ubuntu 18.04. LTS
### Visual Studio Code
- Install from here: [VSC Download](https://code.visualstudio.com/Download)
- Open the app and install the following VSC extensions:
- Remote WSL
- Connect to WSL. This will automatically install the VSC server on the VSC server for WSL
- Once connected to WSL install the Python extension on the WSL side
## WSL Installation
Open a WSL bash and update all software packets:
```bash
sudo apt update && sudo apt upgrade -y
```
### Install Tools
```bash
sudo apt-get install build-essential
sudo apt-get install gettext
```
### Install Python
For AA we want to develop with Python 3.6, because that provides the maximum compatibility with today's AA installations. This also happens to be the default Python 3 version for Ubuntu 18.04. at the point of this writing.
```eval_rst
.. hint::
To check your system's Python 3 version you can enter: ``python3 --version``
```
```eval_rst
.. note::
Should your Ubuntu come with a newer version of Python we recommend to still setup your dev environment with the oldest Python 3 version supported by AA, e.g Python 3.6
You an check out this `page <https://askubuntu.com/questions/682869/how-do-i-install-a-different-python-version-using-apt-get/1195153>`_ on how to install additional Python versions on Ubuntu.
```
Use the following command to install Python 3 with all required libraries with the default version:
```bash
sudo apt-get install python3 python3-dev python3-venv python3-setuptools python3-pip python-pip
```
### Installing the DBMS
Install MySQL and required libraries with the following command:
```bash
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
```
```eval_rst
.. note::
We chose to use MySQL instead of MariaDB, because the standard version of MariaDB that comes with this Ubuntu distribution will not work with AA.
```
We need to apply a permission fix to mysql or you will get a warning with every startup:
```bash
sudo usermod -d /var/lib/mysql/ mysql
```
Start the mysql server
```bash
sudo service mysql start
```
Create database and user for AA
```bash
sudo mysql -u root
```
```sql
CREATE USER 'aa_dev'@'localhost' IDENTIFIED BY 'PASSWORD';
CREATE DATABASE aa_dev CHARACTER SET utf8mb4;
GRANT ALL PRIVILEGES ON aa_dev . * TO 'aa_dev'@'localhost';
CREATE DATABASE test_aa_dev CHARACTER SET utf8mb4;
GRANT ALL PRIVILEGES ON test_aa_dev . * TO 'aa_dev'@'localhost';
exit;
```
Add timezone info to mysql
```bash
sudo mysql_tzinfo_to_sql /usr/share/zoneinfo | sudo mysql -u root mysql
```
### Install redis and other tools
```bash
sudo apt-get install unzip git redis-server curl libssl-dev libbz2-dev libffi-dev
```
Start redis
```bash
sudo redis-server --daemonize yes
```
```eval_rst
.. note::
WSL does not have an init.d service, so it will not automatically start your services such as MySQL and Redis when you boot your Windows machine. For convenience we recommend putting the commands for starting these services in a bash script. Here is an example: ::
#/bin/bash
# start services for AA dev
sudo service mysql start
sudo redis-server --daemonize yes
In addition it is possible to configure Windows to automatically start WSL services, but that procedure goes beyond the scopes of this guide.
```
### Setup dev folder on WSL
Setup your folders on WSL bash for your dev project. Our approach will setup one AA project with one venv and multiple apps running under the same AA project, but each in their own folder and git.
A good location for setting up this folder structure is your home folder or a subfolder of your home:
```text
~/aa-dev
|- venv
|- myauth
|- my_app_1
|- my_app_2
|- ...
```
Following this approach you can also setup additional AA projects, e.g. aa-dev-2, aa-dev-3 if needed.
Create the root folder aa-dev.
### setup virtual Python environment for aa-dev
Create the virtual environment. Run this in your aa-dev folder:
```bash
python3 -m venv venv
```
And activate your venv:
```bash
source venv/bin/activate
```
### install Python packages
```bash
pip install --upgrade pip
pip install wheel
```
## Alliance Auth installation
## Install and create AA instance
```bash
pip install allianceauth
```
Now we are ready to setup our AA instance. Make sure to run this command in your aa-dev folder:
```bash
allianceauth start myauth
```
Next we will setup our VSC project for aa-dev by starting it directly from the WSL bash:
```bash
code .
```
First you want to make sure exclude the venv folder from VSC as follows:
Open settings and go to Files:Exclude
Add pattern: `**/venv`
### Update settings
Open the settings file with VSC. Its under `myauth/myauth/settings/local.py`
Make sure to have the settings of your Eve Online app ready.
Turn on DEBUG mode to ensure your static files get served by Django:
```python
DEBUG = True
```
Update name, user and password of your DATABASE configuration.
```python
DATABASES['default'] = {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'aa_dev',
'USER': 'aa_dev',
'PASSWORD': 'PASSWORD',
'HOST': '127.0.0.1',
'PORT': '3306',
'OPTIONS': {'charset': 'utf8mb4'},
}
```
For the Eve Online related setup you need to create a SSO app on the developer site:
- Create your Eve Online SSO App on the [Eve Online developer site](https://developers.eveonline.com/)
- Add all ESI scopes
- Set callback URL to: `http://localhost:8000/sso/callback`
Then update local.py with your settings:
```python
ESI_SSO_CLIENT_ID = 'YOUR-ID'
ESI_SSO_CLIENT_SECRET = 'YOUR_SECRET'
ESI_SSO_CALLBACK_URL = 'http://localhost:8000/sso/callback'
```
Disable email registration:
```python
REGISTRATION_VERIFY_EMAIL = False
```
### Migrations and superuser
Before we can start AA we need to run migrations:
```bash
cd myauth
python manage.py migrate
```
We also need to create a superuser for our AA installation:
```bash
python /home/allianceserver/myauth/manage.py createsuperuser
```
## Running Alliance Auth
## AA instance
We are now ready to run out AA instance with the following command:
```bash
python manage.py runserver
```
Once running you can access your auth site on the browser under `http://localhost:8000`. Or the admin site under `http://localhost:8000/admin`
```eval_rst
.. hint::
You can start your AA server directly from a terminal window in VSC or with a VSC debug config (see chapter about debugging for details).
```
```eval_rst
.. note::
**Debug vs. Non-Debug mode**
Usually it is best to run your dev AA instance in debug mode, so you get all the detailed error messages that helps a lot for finding errors. But there might be cases where you want to test features that do not exist in debug mode (e.g. error pages) or just want to see how your app behaves in non-debug / production mode.
When you turn off debug mode you will see a problem though: Your pages will not render correctly. The reason is that Django will stop serving your static files in production mode and expect you to serve them from a real web server. Luckily, there is an option that forces Django to continue serving your static files directly even when not in debug mode. Just start your server with the following option: ``python manage.py runserver --insecure``
```
### Celery
In addition you can start a celery worker instance for myauth. For development purposed it makes sense to only start one instance and add some additional logging.
This can be done from the command line with the following command in the myauth folder (where manage.py is located):
```bash
celery -E -A myauth worker -l info -P solo
```
Same as AA itself you can start Celery from any terminal session, from a terminal window within VSC or as a debug config in VSC (see chapter about debugging for details). For convenience we recommend starting Celery as debug config.
## Debugging setup
To be able to debug your code you need to add debugging configuration to VSC. At least one for AA and one for celery.
### Breakpoints
By default VSC will break on any uncaught exception. Since every error raised by your tests will cause an uncaught exception we recommend to deactivate this feature.
To deactivate open click on the debug icon to switch to the debug view. Then un-check "Uncaught Exceptions" on the breakpoints window.
### AA debug config
In VSC click on Debug / Add Configuration and choose "Django". Should Django not appear as option make sure to first open a Django file (e.g. the local.py settings) to help VSC detect that you are using Django.
The result should look something like this:
```python
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/myauth/manage.py",
"args": [
"runserver",
"--noreload"
],
"django": true
}
```
### Debug celery
For celery we need another debug config, so that we can run it in parallel to our AA instance.
Here is an example debug config for Celery:
```javascript
{
"name": "Python: Celery",
"type": "python",
"request": "launch",
"module": "celery",
"cwd": "${workspaceFolder}/myauth",
"console": "integratedTerminal",
"args": [
"-E",
"-A",
"myauth",
"worker",
"-l",
"info",
"-P",
"solo",
],
"django": true
},
```
### Debug config for unit tests
Finally it makes sense to have a dedicated debug config for running unit tests. Here is an example config for running all tests of the app `example`.
```javascript
{
"name": "Python: myauth unit tests",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/myauth/manage.py",
"args": [
"test",
"-v 2",
"--keepdb",
"--debug-mode",
"--failfast",
"example",
],
"django": true
},
```
You can also specify to run just a part of your test suite down to a test method. Just give the full path to the test you want to run, e.g. `example.test.test_models.TestDemoModel.test_this_method`
### Debugging normal python scripts
Finally you may also want to have a debug config to debug a non-Django Python script:
```javascript
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
```
## Additional tools
The following additional tools are very helpful when developing for AA.
### Code Spell Checker
Typos in your user facing comments can be quite embarrassing. This spell checker helps you avoid them.
Install from here: [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker)
### DBeaver
DBeaver is a free universal database tool and works with many different kinds of databases include MySQL. It can be installed on Windows 10 and will be able to help manage your MySQL databases running on WSL.
Install from here. [DBeaver](https://dbeaver.io/)
### django-extensions
[django-extensions](https://django-extensions.readthedocs.io/en/latest/) is a swiss army knife for django developers with adds a lot of very useful features to your Django site. Here are a few highlights:
- shell_plus - An enhanced version of the Django shell. It will auto-load all your models at startup so you don't have to import anything and can use them right away.
- graph_models - Creates a dependency graph of Django models. Visualizing a model dependency structure can be very useful for trying to understand how an existing Django app works, or e.g. how all the AA models work together.
- runserver_plus - The standard runserver stuff but with the Werkzeug debugger baked in. This is a must have for any serious debugging.
## Adding apps for development
The idea behind the particular folder structure of aa-dev is to have each and every app in its own folder and git repo. To integrate them with the AA instance they need to be installed once using the -e option that enabled editing of the package. And then added to the INSTALLED_APPS settings.
To demonstrate let's add the example plugin to our environment.
Open a WSL bash and navigate to the aa-dev folder. Make sure you have activate your virtual environment. (`source venv/bin/activate`)
Run these commands:
```bash
git clone https://gitlab.com/ErikKalkoken/allianceauth-example-plugin.git
pip install -e allianceauth-example-plugin
```
Add `'example'` to INSTALLED_APPS in your `local.py` settings.
Run migrations and restart your AA server, e.g.:
```bash
cd myauth
python manage.py migrate
```

View File

@@ -0,0 +1,10 @@
# Setup dev environment for AA
Here you find guides on how to setup your development environment for AA.
```eval_rst
.. toctree::
:maxdepth: 1
aa-dev-setup-wsl-vsc-v2
```

View File

@@ -8,4 +8,6 @@
custom/index
aa_core/index
dev_setup/index
tech_docu/index
```

View File

@@ -0,0 +1,39 @@
======================
django-esi
======================
The django-esi package provides an interface for easy access to the ESI.
Location: ``esi``
This is an external package. Please also see `here <https://gitlab.com/allianceauth/django-esi>`_ for it's official documentation.
clients
===========
.. automodule:: esi.clients
:members: esi_client_factory
:undoc-members:
decorators
===========
.. automodule:: esi.decorators
:members:
:undoc-members:
errors
===========
.. automodule:: esi.errors
:members:
:undoc-members:
models
===========
.. automodule:: esi.models
:members: Scope, Token
:exclude-members: objects, provider
:undoc-members:

View File

@@ -0,0 +1,30 @@
===============================
evelinks
===============================
This package generates profile URLs for eve entities on 3rd party websites like evewho and zKillboard.
Location: ``allianceauth.eveonline.evelinks``
dotlan
===============
.. automodule:: allianceauth.eveonline.evelinks.dotlan
:members:
:undoc-members:
eveho
==============
.. automodule:: allianceauth.eveonline.evelinks.evewho
:members:
:undoc-members:
zkillboard
===================
.. automodule:: allianceauth.eveonline.evelinks.zkillboard
:members:
:undoc-members:

View File

@@ -0,0 +1,15 @@
======================
eveonline
======================
The eveonline package provides models for commonly used Eve Online entities like characters, corporations and alliances. All models have the ability to be loaded from ESI.
Location: ``allianceauth.eveonline``
models
======
.. automodule:: allianceauth.eveonline.models
:members:
:exclude-members: objects, provider
:undoc-members:

View File

@@ -0,0 +1,13 @@
# API
To reduce redundancy and help speed up development we encourage developers to utilize the following packages when developing apps for Alliance Auth.
```eval_rst
.. toctree::
:maxdepth: 1
esi
evelinks
eveonline
testutils
```

View File

@@ -0,0 +1,14 @@
=============================
tests
=============================
Here you find utility functions and classes, which can help speed up writing test cases for AA.
Location: ``allianceauth.tests.auth_utils``
auth_utils
===========
.. automodule:: allianceauth.tests.auth_utils
:members:
:undoc-members:

View File

@@ -0,0 +1,204 @@
# Celery FAQ
**Alliance Auth** uses Celery for asynchronous task management. This page aims to give developers some guidance on how to use Celery when developing apps for Alliance Auth.
For a complete documentation of Celery please refer to the [official Celery documentation](http://docs.celeryproject.org/en/latest/index.html).
## When should I use Celery in my app?
There are two main cases for using celery. Long duration of a process and recurrence of a process.
### Duration
Alliance Auth is an online web application and as such the user expects fast and immediate responses to any of his clicks or actions. Same as with any other good web site. Good response times are measures in ms and a user will perceive everything that takes longer than 1 sec as an interruption of his flow of thought (see also [Response Times: The 3 Important Limits](https://www.nngroup.com/articles/response-times-3-important-limits/)).
As a rule of thumb we therefore recommend to use celery tasks for every process that can take longer than 1 sec to complete (also think about how long your process might take with large amounts of data).
```eval_rst
.. note::
Another solution for dealing with long response time in particular when loading pages is to load parts of a page asynchronously, for example with AJAX.
```
### Recurrence
Another case for using celery tasks is when you need recurring execution of tasks. For example you may want to update the list of characters in a corporation from ESI every hour.
These are called periodic tasks and Alliance Auth uses [celery beat](https://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html) to implement them.
## What is a celery task?
For the most part a celery task is a Python functions that is configured to be executed asynchronously and controlled by Celery. Celery tasks can be automatically retried, executed periodically, executed in work flows and much more. See the [celery docs](https://docs.celeryproject.org/en/latest/userguide/tasks.html) for a more detailed description.
## How should I use Celery in my app?
Please use the following approach to ensure your tasks are working properly with Alliance Auth:
- All tasks should be defined in a module of your app's package called `tasks.py`
- Every task is a Python function with has the `@shared_task` decorator.
- Task functions and the tasks module should be kept slim, just like views by mostly utilizing business logic defined in your models/managers.
- Tasks should always have logging, so their function and potential errors can be monitored properly
Here is an example implementation of a task:
```Python
import logging
from celery import shared_task
logger = logging.getLogger(__name__)
@shared_task
def example():
logger.info('example task started')
```
This task can then be started from any another Python module like so:
```Python
from .tasks import example
example.delay()
```
## How should I use celery tasks in the UI?
There is a well established pattern for integrating asynchronous processes in the UI, for example when the user asks your app to perform a longer running action:
1. Notify the user immediately (with a Django message) that the process for completing the action has been started and that he will receive a report once completed.
2. Start the celery task
3. Once the celery task is completed it should send a notification containing the result of the action to the user. It's important to send that notification also in case of errors.
## Can I use long running tasks?
Long running tasks are possible, but in general Celery works best with short running tasks. Therefore we strongly recommend to try and break down long running tasks into smaller tasks if possible.
If contextually possible try to break down your long running task in shorter tasks that can run in parallel.
However, many long running tasks consist of several smaller processes that need to run one after the other. For example you may have a loop where you perform the same action on hundreds of objects. In those cases you can define each of the smaller processes as it's own task and then link them together, so that they are run one after the other. That is called chaining in Celery and is the preferred approach for implementing long running processes.
Example implementation for a celery chain:
```Python
import logging
from celery import shared_task, chain
logger = logging.getLogger(__name__)
@shared_task
def example():
logger.info('example task')
@shared_task
def long_runner():
logger.info('started long runner')
my_tasks = list()
for _ in range(10):
task_signature = example.si()
my_task.append(task_signature)
chain(my_tasks).delay()
```
In this example we fist add 10 example tasks that need to run one after the other to a list. This can be done by creating a so called signature for a task. Those signature are a kind of wrapper for tasks and can be used in various ways to compose work flow for tasks.
The list of task signatures is then converted to a chain and started asynchronously.
```eval_rst
.. hint::
In our example we use ``si()``, which is a shortcut for "immutable signatures" and prevents us from having to deal with result sharing between tasks.
For more information on signature and work flows see the official documentation on `Canvas <https://docs.celeryproject.org/en/latest/userguide/canvas.html>`_.
In this context please note that Alliance Auth currently only supports chaining, because all other variants require a so called results back, which Alliance Auth does not have.
```
## How can I define periodic tasks for my app?
Periodic tasks are normal celery tasks which are added the scheduler for periodic execution. The convention for defining periodic tasks for an app is to define them in the local settings. So user will need to add those settings manually to his local settings during the installation process.
Example setting:
```Python
CELERYBEAT_SCHEDULE['structures_update_all_structures'] = {
'task': 'structures.tasks.update_all_structures',
'schedule': crontab(minute='*/30'),
}
```
- `structures_update_all_structures` is the name of the scheduling entry. You can chose any name, but the convention is name of your app plus name of the task.
- `'task'`: Name of your task (full path)
- `'schedule'`: Schedule definition (see Celery documentation on [Periodic Tasks](https://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html) for details)
## How can I use priorities for tasks?
In Alliance Auth we have defined task priorities from 0 - 9 as follows:
```eval_rst
====== ========= ===========
Number Priority Description
====== ========= ===========
0 Reserved Reserved for Auth and may not be used by apps
1, 2 Highest Needs to run right now
3, 4 High needs to run as soon as practical
5 Normal default priority for most tasks
6, 7 Low needs to run soonish, but is less urgent than most tasks
8, 9 Lowest not urgent, can be run whenever there is time
====== ========= ===========
```
```eval_rst
.. warning::
Please make sure to use task priorities with care and especially do not use higher priorities without a good reason. All apps including Alliance Auth share the same task queues, so using higher task priorities excessively can potentially prevent more important tasks (of other apps) from completing on time.
You also want to make sure to run use lower priorities if you have a large amount of tasks or long running tasks, which are not super urgent. (e.g. the regular update of all Eve characters from ESI runs with priority 7)
```
```eval_rst
.. hint::
If no priority is specified all tasks will be started with the default priority, which is 5.
```
To run a task with a different priority you need to specify it when starting it.
Example for starting a task with priority 3:
```Python
example.apply_async(priority=3)
```
```eval_rst
.. hint::
For defining a priority to tasks you can not use the convenient shortcut ``delay()``, but instead need to start a task with ``apply_async()``, which also requires you to pass parameters to your task function differently. Please check out the `official docs <https://docs.celeryproject.org/en/stable/reference/celery.app.task.html#celery.app.task.Task.apply_async>`_ for details.
```
## What special features should I be aware of?
Every Alliance Auth installation will come with a couple of special celery related features "out-of-the-box" that you can make use of in your apps.
### celery-once
Celery-once is a celery extension "that allows you to prevent multiple execution and queuing of celery tasks". What that means is that you can ensure that only one instance of a celery task runs at any given time. This can be useful for example if you do not want multiple instances of you task to talk to the same external service at the same time.
We use a custom backend for celery_once in Alliance Auth defined [here](https://gitlab.com/allianceauth/allianceauth/-/blob/master/allianceauth/services/tasks.py#L14)
You can import it for use like so:
```Python
from allianceauth.services.tasks import QueueOnce
```
An example of AllianceAuth's use within the `@sharedtask` decorator, can be seen [here](https://gitlab.com/allianceauth/allianceauth/-/blob/master/allianceauth/services/modules/discord/tasks.py#L62) in the discord module
You can use it like so:
```Python
@shared_task(bind=True, name='your_modules.update_task', base=QueueOnce)
```
Please see the [official documentation](hhttps://pypi.org/project/celery_once/) of celery-once for details.
### task priorities
Alliance Auth is using task priorities to enable priority based scheduling of task execution. Please see [How can I use priorities for tasks?](#how-can-i-use-priorities-for-tasks) for details.

View File

@@ -0,0 +1,5 @@
# Core models
The following diagram shows the core models of AA and Django and their relationships:
![aa_core](/_static/images/development/aa_core.png)

View File

@@ -0,0 +1,13 @@
# Developing apps
In this section you find topics useful for app developers.
```eval_rst
.. toctree::
:maxdepth: 1
api/index
celery
core_models
templatetags
```

View File

@@ -0,0 +1,16 @@
=============
Template Tags
=============
The following template tags are available to be used by all apps. To use them just load the respeetive template tag in your template like so:
.. code-block:: html
{% load evelinks %}
evelinks
========
.. automodule:: allianceauth.eveonline.templatetags.evelinks
:members:
:undoc-members:

View File

@@ -28,7 +28,7 @@ Alliance Auth can be installed on any Unix like operating system. Dependencies a
### Python
Alliance Auth requires python3.5 or higher. Ensure it is installed on your server before proceeding.
Alliance Auth requires Python 3.6 or higher. Ensure it is installed on your server before proceeding.
Ubuntu:
@@ -83,7 +83,8 @@ apt-get install unzip git redis-server curl libssl-dev libbz2-dev libffi-dev
CentOS:
```bash
yum install gcc gcc-c++ unzip git redis curl bzip2-devel
yum install gcc gcc-c++ unzip git redis curl
2-devel
```
```eval_rst
@@ -113,7 +114,7 @@ mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
```eval_rst
.. note::
You may see errors when you add the timezone tables. To make sure that they were correctly added run the following commands and check for the ``time_zone`` tables::
mysql -u root -p
use mysql;
show tables;

View File

@@ -53,7 +53,7 @@ setup(
extras_require={
'testing': testing_extras
},
python_requires='~=3.5',
python_requires='~=3.6',
license='GPLv2',
packages=['allianceauth'],
url='https://gitlab.com/allianceauth/allianceauth',
@@ -71,8 +71,7 @@ setup(
'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',

View File

@@ -12,4 +12,7 @@ urlpatterns += [
url(r'^second-page/$', views.page, name='p1'),
]
handler500 = 'allianceauth.views.Generic500Redirect'
handler404 = 'allianceauth.views.Generic404Redirect'
handler403 = 'allianceauth.views.Generic403Redirect'
handler400 = 'allianceauth.views.Generic400Redirect'

View File

@@ -1,14 +1,13 @@
[tox]
skipsdist = true
usedevelop = true
envlist = py{35,36,37,38}-{all}
envlist = py{36,37,38}-{all}
[testenv]
setenv =
all: DJANGO_SETTINGS_MODULE = tests.settings_all
core: DJANGO_SETTINGS_MODULE = tests.settings_core
basepython =
py35: python3.5
basepython =
py36: python3.6
py37: python3.7
py38: python3.8
@@ -19,5 +18,6 @@ install_command = pip install -e ".[testing]" -U {opts} {packages}
commands =
all: coverage run runtests.py -v 2
all: coverage report -m
all: coverage xml
core: coverage run runtests.py allianceauth.authentication.tests.test_app_settings -v 2
all: coverage xml