mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-22 02:32:29 +02:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a02e5f400a | ||
|
65c168939d | ||
|
313cac6ac7 | ||
|
0145ea82c8 | ||
|
0cdc5ffbd5 | ||
|
0bdd044378 | ||
|
ad266ea2ee | ||
|
7ea8c9e50d | ||
|
9a015fd582 | ||
|
7ca1c87c87 |
@ -4,5 +4,5 @@ from __future__ import absolute_import, unicode_literals
|
|||||||
# Django starts so that shared_task will use this app.
|
# Django starts so that shared_task will use this app.
|
||||||
from .celeryapp import app as celery_app # noqa
|
from .celeryapp import app as celery_app # noqa
|
||||||
|
|
||||||
__version__ = '1.15.4'
|
__version__ = '1.15.5'
|
||||||
NAME = 'Alliance Auth v%s' % __version__
|
NAME = 'Alliance Auth v%s' % __version__
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -36,5 +36,5 @@ class Fat(models.Model):
|
|||||||
unique_together = (('character', 'fatlink'),)
|
unique_together = (('character', 'fatlink'),)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
output = "Fat-link for %s" % self.character.character_name
|
return "Fat-link for %s" % self.character.character_name
|
||||||
return output.encode('utf-8')
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -52,8 +52,12 @@ class CorpStat(object):
|
|||||||
fatlink__fatdatetime__gte=start_of_month).filter(fatlink__fatdatetime__lte=start_of_next_month).count()
|
fatlink__fatdatetime__gte=start_of_month).filter(fatlink__fatdatetime__lte=start_of_next_month).count()
|
||||||
self.blue = self.corp.is_blue
|
self.blue = self.corp.is_blue
|
||||||
|
|
||||||
|
@property
|
||||||
def avg_fat(self):
|
def avg_fat(self):
|
||||||
|
try:
|
||||||
return "%.2f" % (float(self.n_fats) / float(self.corp.member_count))
|
return "%.2f" % (float(self.n_fats) / float(self.corp.member_count))
|
||||||
|
except ZeroDivisionError:
|
||||||
|
return "%.2f" % 0
|
||||||
|
|
||||||
|
|
||||||
class MemberStat(object):
|
class MemberStat(object):
|
||||||
@ -70,8 +74,12 @@ class MemberStat(object):
|
|||||||
self.n_fats = Fat.objects.filter(user_id=member['user_id']).filter(
|
self.n_fats = Fat.objects.filter(user_id=member['user_id']).filter(
|
||||||
fatlink__fatdatetime__gte=start_of_month).filter(fatlink__fatdatetime__lte=start_of_next_month).count()
|
fatlink__fatdatetime__gte=start_of_month).filter(fatlink__fatdatetime__lte=start_of_next_month).count()
|
||||||
|
|
||||||
|
@property
|
||||||
def avg_fat(self):
|
def avg_fat(self):
|
||||||
|
try:
|
||||||
return "%.2f" % (float(self.n_fats) / float(self.n_chars))
|
return "%.2f" % (float(self.n_fats) / float(self.n_chars))
|
||||||
|
except ZeroDivisionError:
|
||||||
|
return "%.2f" % 0
|
||||||
|
|
||||||
|
|
||||||
def first_day_of_next_month(year, month):
|
def first_day_of_next_month(year, month):
|
||||||
@ -132,7 +140,7 @@ def fatlink_statistics_corp_view(request, corpid, year=None, month=None):
|
|||||||
# collect and sort stats
|
# collect and sort stats
|
||||||
stat_list = [fat_stats[x] for x in fat_stats]
|
stat_list = [fat_stats[x] for x in fat_stats]
|
||||||
stat_list.sort(key=lambda stat: stat.mainchar.character_name)
|
stat_list.sort(key=lambda stat: stat.mainchar.character_name)
|
||||||
stat_list.sort(key=lambda stat: (stat.n_fats, stat.n_fats / stat.n_chars), reverse=True)
|
stat_list.sort(key=lambda stat: (stat.n_fats, stat.avg_fat), reverse=True)
|
||||||
|
|
||||||
context = {'fatStats': stat_list, 'month': start_of_month.strftime("%B"), 'year': year,
|
context = {'fatStats': stat_list, 'month': start_of_month.strftime("%B"), 'year': year,
|
||||||
'previous_month': start_of_previous_month, 'corpid': corpid}
|
'previous_month': start_of_previous_month, 'corpid': corpid}
|
||||||
@ -170,7 +178,7 @@ def fatlink_statistics_view(request, year=datetime.date.today().year, month=date
|
|||||||
# collect and sort stats
|
# collect and sort stats
|
||||||
stat_list = [fat_stats[x] for x in fat_stats]
|
stat_list = [fat_stats[x] for x in fat_stats]
|
||||||
stat_list.sort(key=lambda stat: stat.corp.corporation_name)
|
stat_list.sort(key=lambda stat: stat.corp.corporation_name)
|
||||||
stat_list.sort(key=lambda stat: (stat.n_fats, stat.n_fats / stat.corp.member_count), reverse=True)
|
stat_list.sort(key=lambda stat: (stat.n_fats, stat.avg_fat), reverse=True)
|
||||||
|
|
||||||
context = {'fatStats': stat_list, 'month': start_of_month.strftime("%B"), 'year': year,
|
context = {'fatStats': stat_list, 'month': start_of_month.strftime("%B"), 'year': year,
|
||||||
'previous_month': start_of_previous_month}
|
'previous_month': start_of_previous_month}
|
||||||
|
@ -21,5 +21,4 @@ class optimer(models.Model):
|
|||||||
eve_character = models.ForeignKey(EveCharacter)
|
eve_character = models.ForeignKey(EveCharacter)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
output = self.operation_name
|
return self.operation_name
|
||||||
return output.encode('utf-8')
|
|
||||||
|
@ -5,7 +5,7 @@ dnspython
|
|||||||
passlib
|
passlib
|
||||||
requests>=2.9.1
|
requests>=2.9.1
|
||||||
bcrypt
|
bcrypt
|
||||||
slugify
|
python-slugify>=1.2
|
||||||
requests-oauthlib
|
requests-oauthlib
|
||||||
sleekxmpp
|
sleekxmpp
|
||||||
redis
|
redis
|
||||||
@ -23,4 +23,4 @@ django-celery-beat
|
|||||||
# awating pyghassen/openfire-restapi #1 to fix installation issues
|
# awating pyghassen/openfire-restapi #1 to fix installation issues
|
||||||
git+https://github.com/adarnof/openfire-restapi
|
git+https://github.com/adarnof/openfire-restapi
|
||||||
|
|
||||||
git+https://github.com/adarnof/adarnauth-esi
|
adarnauth-esi>=1.4.1,<2.0
|
||||||
|
@ -15,6 +15,7 @@ def auth_settings(request):
|
|||||||
'IPS4_URL': settings.IPS4_URL,
|
'IPS4_URL': settings.IPS4_URL,
|
||||||
'SMF_URL': settings.SMF_URL,
|
'SMF_URL': settings.SMF_URL,
|
||||||
'MARKET_URL': settings.MARKET_URL,
|
'MARKET_URL': settings.MARKET_URL,
|
||||||
|
'SEAT_URL': settings.SEAT_URL,
|
||||||
'EXTERNAL_MEDIA_URL': settings.EXTERNAL_MEDIA_URL,
|
'EXTERNAL_MEDIA_URL': settings.EXTERNAL_MEDIA_URL,
|
||||||
'CURRENT_UTC_TIME': timezone.now(),
|
'CURRENT_UTC_TIME': timezone.now(),
|
||||||
'BLUE_API_MASK': settings.BLUE_API_MASK,
|
'BLUE_API_MASK': settings.BLUE_API_MASK,
|
||||||
|
@ -27,11 +27,11 @@ class srpManager:
|
|||||||
r = requests.get(url, headers=headers)
|
r = requests.get(url, headers=headers)
|
||||||
result = r.json()[0]
|
result = r.json()[0]
|
||||||
if result:
|
if result:
|
||||||
ship_type = result['victim']['shipTypeID']
|
ship_type = result['victim']['ship_type_id']
|
||||||
logger.debug("Ship type for kill ID %s is determined to be %s" % (kill_id, ship_type))
|
logger.debug("Ship type for kill ID %s is %s" % (kill_id, ship_type))
|
||||||
ship_value = result['zkb']['totalValue']
|
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_name = result['victim']['characterName']
|
victim_id = result['victim']['character_id']
|
||||||
return ship_type, ship_value, victim_name
|
return ship_type, ship_value, victim_id
|
||||||
else:
|
else:
|
||||||
raise ValueError("Invalid Kill ID")
|
raise ValueError("Invalid Kill ID")
|
||||||
|
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
|||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
import math
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from requests_oauthlib import OAuth2Session
|
from requests_oauthlib import OAuth2Session
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
@ -50,12 +51,20 @@ class DiscordApiTooBusy(DiscordApiException):
|
|||||||
|
|
||||||
class DiscordApiBackoff(DiscordApiException):
|
class DiscordApiBackoff(DiscordApiException):
|
||||||
def __init__(self, retry_after, global_ratelimit):
|
def __init__(self, retry_after, global_ratelimit):
|
||||||
|
"""
|
||||||
|
:param retry_after: int time to retry after in milliseconds
|
||||||
|
:param global_ratelimit: bool Is the API under a global backoff
|
||||||
|
"""
|
||||||
super(DiscordApiException, self).__init__()
|
super(DiscordApiException, self).__init__()
|
||||||
self.retry_after = retry_after
|
self.retry_after = retry_after
|
||||||
self.global_ratelimit = global_ratelimit
|
self.global_ratelimit = global_ratelimit
|
||||||
|
|
||||||
|
@property
|
||||||
|
def retry_after_seconds(self):
|
||||||
|
return math.ceil(self.retry_after / 1000)
|
||||||
|
|
||||||
cache_time_format = '%Y-%m-%d %H:%M:%S'
|
|
||||||
|
cache_time_format = '%Y-%m-%d %H:%M:%S.%f'
|
||||||
|
|
||||||
|
|
||||||
def api_backoff(func):
|
def api_backoff(func):
|
||||||
@ -117,12 +126,12 @@ def api_backoff(func):
|
|||||||
retry_after = int(e.response.headers['Retry-After'])
|
retry_after = int(e.response.headers['Retry-After'])
|
||||||
except (TypeError, KeyError):
|
except (TypeError, KeyError):
|
||||||
# Pick some random time
|
# Pick some random time
|
||||||
retry_after = 5
|
retry_after = 5000
|
||||||
|
|
||||||
logger.info("Received backoff from API of %s seconds, handling" % retry_after)
|
logger.info("Received backoff from API of %s seconds, handling" % retry_after)
|
||||||
# Store value in redis
|
# Store value in redis
|
||||||
backoff_until = (datetime.datetime.utcnow() +
|
backoff_until = (datetime.datetime.utcnow() +
|
||||||
datetime.timedelta(seconds=retry_after))
|
datetime.timedelta(milliseconds=retry_after))
|
||||||
global_backoff = bool(e.response.headers.get('X-RateLimit-Global', False))
|
global_backoff = bool(e.response.headers.get('X-RateLimit-Global', False))
|
||||||
if global_backoff:
|
if global_backoff:
|
||||||
logger.info("Global backoff!!")
|
logger.info("Global backoff!!")
|
||||||
@ -138,7 +147,7 @@ def api_backoff(func):
|
|||||||
# Sleep if we're blocking
|
# Sleep if we're blocking
|
||||||
if blocking:
|
if blocking:
|
||||||
logger.info("Blocking Back off from API calls for %s seconds" % bo.retry_after)
|
logger.info("Blocking Back off from API calls for %s seconds" % bo.retry_after)
|
||||||
time.sleep(10 if bo.retry_after > 10 else bo.retry_after)
|
time.sleep((10 if bo.retry_after > 10 else bo.retry_after) / 1000)
|
||||||
else:
|
else:
|
||||||
# Otherwise raise exception and let caller handle the backoff
|
# Otherwise raise exception and let caller handle the backoff
|
||||||
raise DiscordApiBackoff(retry_after=bo.retry_after, global_ratelimit=bo.global_ratelimit)
|
raise DiscordApiBackoff(retry_after=bo.retry_after, global_ratelimit=bo.global_ratelimit)
|
||||||
|
@ -75,8 +75,8 @@ class DiscordTasks:
|
|||||||
DiscordOAuthManager.update_groups(user.discord.uid, groups)
|
DiscordOAuthManager.update_groups(user.discord.uid, groups)
|
||||||
except DiscordApiBackoff as bo:
|
except DiscordApiBackoff as bo:
|
||||||
logger.info("Discord group sync API back off for %s, "
|
logger.info("Discord group sync API back off for %s, "
|
||||||
"retrying in %s seconds" % (user, bo.retry_after))
|
"retrying in %s seconds" % (user, bo.retry_after_seconds))
|
||||||
raise task_self.retry(countdown=bo.retry_after)
|
raise task_self.retry(countdown=bo.retry_after_seconds)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if task_self:
|
if task_self:
|
||||||
logger.exception("Discord group sync failed for %s, retrying in 10 mins" % user)
|
logger.exception("Discord group sync failed for %s, retrying in 10 mins" % user)
|
||||||
|
@ -402,7 +402,7 @@ class DiscordManagerTestCase(TestCase):
|
|||||||
|
|
||||||
m.patch(request_url,
|
m.patch(request_url,
|
||||||
request_headers=headers,
|
request_headers=headers,
|
||||||
headers={'Retry-After': '200'},
|
headers={'Retry-After': '200000'},
|
||||||
status_code=429)
|
status_code=429)
|
||||||
|
|
||||||
# Act & Assert
|
# Act & Assert
|
||||||
@ -410,7 +410,7 @@ class DiscordManagerTestCase(TestCase):
|
|||||||
try:
|
try:
|
||||||
DiscordOAuthManager.update_groups(user_id, groups, blocking=False)
|
DiscordOAuthManager.update_groups(user_id, groups, blocking=False)
|
||||||
except manager.DiscordApiBackoff as bo:
|
except manager.DiscordApiBackoff as bo:
|
||||||
self.assertEqual(bo.retry_after, 200, 'Retry-After time must be equal to Retry-After set in header')
|
self.assertEqual(bo.retry_after, 200000, 'Retry-After time must be equal to Retry-After set in header')
|
||||||
self.assertFalse(bo.global_ratelimit, 'global_ratelimit must be False')
|
self.assertFalse(bo.global_ratelimit, 'global_ratelimit must be False')
|
||||||
raise bo
|
raise bo
|
||||||
|
|
||||||
@ -437,7 +437,7 @@ class DiscordManagerTestCase(TestCase):
|
|||||||
|
|
||||||
m.patch(request_url,
|
m.patch(request_url,
|
||||||
request_headers=headers,
|
request_headers=headers,
|
||||||
headers={'Retry-After': '200', 'X-RateLimit-Global': 'true'},
|
headers={'Retry-After': '200000', 'X-RateLimit-Global': 'true'},
|
||||||
status_code=429)
|
status_code=429)
|
||||||
|
|
||||||
# Act & Assert
|
# Act & Assert
|
||||||
@ -445,7 +445,7 @@ class DiscordManagerTestCase(TestCase):
|
|||||||
try:
|
try:
|
||||||
DiscordOAuthManager.update_groups(user_id, groups, blocking=False)
|
DiscordOAuthManager.update_groups(user_id, groups, blocking=False)
|
||||||
except manager.DiscordApiBackoff as bo:
|
except manager.DiscordApiBackoff as bo:
|
||||||
self.assertEqual(bo.retry_after, 200, 'Retry-After time must be equal to Retry-After set in header')
|
self.assertEqual(bo.retry_after, 200000, 'Retry-After time must be equal to Retry-After set in header')
|
||||||
self.assertTrue(bo.global_ratelimit, 'global_ratelimit must be True')
|
self.assertTrue(bo.global_ratelimit, 'global_ratelimit must be True')
|
||||||
raise bo
|
raise bo
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ def srp_request_view(request, fleet_srp):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
srp_kill_link = srpManager.get_kill_id(srp_request.killboard_link)
|
srp_kill_link = srpManager.get_kill_id(srp_request.killboard_link)
|
||||||
(ship_type_id, ship_value, victim_name) = srpManager.get_kill_data(srp_kill_link)
|
(ship_type_id, ship_value, victim_id) = srpManager.get_kill_data(srp_kill_link)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
logger.debug("User %s Submitted Invalid Killmail Link %s or server could not be reached" % (
|
logger.debug("User %s Submitted Invalid Killmail Link %s or server could not be reached" % (
|
||||||
request.user, srp_request.killboard_link))
|
request.user, srp_request.killboard_link))
|
||||||
@ -235,7 +235,7 @@ def srp_request_view(request, fleet_srp):
|
|||||||
|
|
||||||
characters = EveManager.get_characters_by_owner_id(request.user.id)
|
characters = EveManager.get_characters_by_owner_id(request.user.id)
|
||||||
for character in characters:
|
for character in characters:
|
||||||
if character.character_name == victim_name:
|
if character.character_id == str(victim_id):
|
||||||
srp_request.srp_ship_name = EveManager.get_itemtype(ship_type_id).name
|
srp_request.srp_ship_name = EveManager.get_itemtype(ship_type_id).name
|
||||||
srp_request.kb_total_loss = ship_value
|
srp_request.kb_total_loss = ship_value
|
||||||
srp_request.post_time = post_time
|
srp_request.post_time = post_time
|
||||||
@ -247,8 +247,8 @@ def srp_request_view(request, fleet_srp):
|
|||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
messages.error(request,
|
messages.error(request,
|
||||||
_("%(charname)s does not belong to your Auth account. Please add the API key for this character and try again")
|
_("Character ID %(charid)s does not belong to your Auth account. Please add the API key for this character and try again")
|
||||||
% {"charname": victim_name})
|
% {"charid": victim_id})
|
||||||
return redirect("auth_srp_management_view")
|
return redirect("auth_srp_management_view")
|
||||||
else:
|
else:
|
||||||
logger.debug("Returning blank SrpFleetUserRequestForm")
|
logger.debug("Returning blank SrpFleetUserRequestForm")
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<head lang="en">
|
<head lang="en">
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>{{ SITE_NAME }}</title>
|
<title>{{ SITE_NAME }}</title>
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
background: url('{% static 'img/index_images/index_blank_bg.jpg' %}') no-repeat scroll;
|
background: url('{% static 'img/index_images/index_blank_bg.jpg' %}') no-repeat scroll;
|
||||||
@ -22,6 +23,7 @@
|
|||||||
margin-top: -100px;
|
margin-top: -100px;
|
||||||
margin-left: -200px;
|
margin-left: -200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#logo {
|
#logo {
|
||||||
height: 200px;
|
height: 200px;
|
||||||
width: 900px;
|
width: 900px;
|
||||||
@ -31,9 +33,18 @@
|
|||||||
margin-top: -100px;
|
margin-top: -100px;
|
||||||
margin-left: -450px;
|
margin-left: -450px;
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a:link, a:hover, a:visited, a:active {
|
||||||
|
font-family: 'Roboto', sans-serif;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 36px;
|
||||||
|
padding: 10px 20px 10px 20px;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -44,29 +55,31 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<p style="text-align:center">
|
<p style="text-align:center">
|
||||||
<a href="/dashboard/">
|
<a href="/dashboard/">auth</a>
|
||||||
<img src="{% static 'img/index_images/auth.png' %}" alt="Auth">
|
|
||||||
</a>
|
|
||||||
</p>
|
</p>
|
||||||
{% if FORUM_URL %}
|
{% if FORUM_URL %}
|
||||||
<p style="text-align:center">
|
<p style="text-align:center">
|
||||||
<a href="{{FORUM_URL}}">
|
<a href="{{FORUM_URL}}">forum</a>
|
||||||
<img src="{% static 'img/index_images/forums.png' %}" alt="Forums">
|
</p>
|
||||||
</a>
|
{% endif %}
|
||||||
|
{% if MARKET_URL %}
|
||||||
|
<p style="text-align:center">
|
||||||
|
<a href="{{MARKET_URL}}">market</a>
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
{% if SEAT_URL %}
|
||||||
|
<p style="text-align:center">
|
||||||
|
<a href="{{SEAT_URL}}">seat</a>
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if KILLBOARD_URL %}
|
{% if KILLBOARD_URL %}
|
||||||
<p style="text-align:center">
|
<p style="text-align:center">
|
||||||
<a href="{{KILLBOARD_URL}}">
|
<a href="{{KILLBOARD_URL}}">killboard</a>
|
||||||
<img src="{% static 'img/index_images/killboard.png' %}" alt="Killboard">
|
|
||||||
</a>
|
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if EXTERNAL_MEDIA_URL %}
|
{% if EXTERNAL_MEDIA_URL %}
|
||||||
<p style="text-align:center">
|
<p style="text-align:center">
|
||||||
<a href="{{EXTERNAL_MEDIA_URL}}">
|
<a href="{{EXTERNAL_MEDIA_URL}}">media</a>
|
||||||
<img src="{% static 'img/index_images/media.png' %}" alt="External Media">
|
|
||||||
</a>
|
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user