mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-12 05:50:16 +02:00
parent
a630b5b397
commit
b4b739ee61
@ -13,6 +13,8 @@ from eveonline.managers import EveManager
|
||||
from fleetactivitytracking.forms import FatlinkForm
|
||||
from fleetactivitytracking.models import Fatlink, Fat
|
||||
|
||||
from esi.decorators import token_required
|
||||
|
||||
from slugify import slugify
|
||||
|
||||
from collections import OrderedDict
|
||||
@ -177,51 +179,54 @@ def fatlink_monthly_personal_statistics_view(request, year, month, char_id=None)
|
||||
|
||||
|
||||
@login_required
|
||||
def click_fatlink_view(request, hash, fatname):
|
||||
# Take IG-header data and register the fatlink if not existing already.
|
||||
# use obj, created = Fat.objects.get_or_create()
|
||||
# onload="CCPEVE.requestTrust('http://www.mywebsite.com')"
|
||||
@token_required(scopes=['esi-location.read_location.v1', 'esi-location.read_ship_type.v1', 'esi-universe.read_structures.v1'])
|
||||
def click_fatlink_view(request, token, hash, fatname):
|
||||
try:
|
||||
fatlink = Fatlink.objects.filter(hash=hash)[0]
|
||||
|
||||
if 'HTTP_EVE_TRUSTED' in request.META and request.META['HTTP_EVE_TRUSTED'] == "Yes":
|
||||
# Retrieve the latest fatlink using the hash.
|
||||
try:
|
||||
fatlink = Fatlink.objects.filter(hash=hash)[0]
|
||||
if (timezone.now() - fatlink.fatdatetime) < datetime.timedelta(seconds=(fatlink.duration * 60)):
|
||||
|
||||
if (timezone.now() - fatlink.fatdatetime) < datetime.timedelta(seconds=(fatlink.duration * 60)):
|
||||
character = EveManager.get_character_by_id(token.character_id)
|
||||
|
||||
character = EveManager.get_character_by_id(request.META['HTTP_EVE_CHARID'])
|
||||
|
||||
if character:
|
||||
fat = Fat()
|
||||
fat.system = request.META['HTTP_EVE_SOLARSYSTEMNAME']
|
||||
if 'HTTP_EVE_STATIONNAME' in request.META:
|
||||
fat.station = request.META['HTTP_EVE_STATIONNAME']
|
||||
else:
|
||||
fat.station = "No Station"
|
||||
fat.shiptype = request.META['HTTP_EVE_SHIPTYPENAME']
|
||||
fat.fatlink = fatlink
|
||||
fat.character = character
|
||||
fat.user = character.user
|
||||
try:
|
||||
fat.full_clean()
|
||||
fat.save()
|
||||
context = {'trusted': True, 'registered': True}
|
||||
except ValidationError as e:
|
||||
messages = []
|
||||
for errorname, message in e.message_dict.items():
|
||||
messages.append(message[0].decode())
|
||||
context = {'trusted': True, 'errormessages': messages}
|
||||
if character:
|
||||
# get data
|
||||
c = token.get_esi_client()
|
||||
location = c.Location.get_characters_character_id_location(character_id=token.character_id).result()
|
||||
ship = c.Location.get_characters_character_id_ship(character_id=token.character_id).result()
|
||||
location['solar_system_name'] = c.Universe.get_universe_systems_system_id(system_id=location['solar_system_id']).result()['solar_system_name']
|
||||
if location['structure_id']:
|
||||
location['station_name'] = c.Universe.get_universe_structures_structure_id(structure_id=location['structure_id']).result()['name']
|
||||
elif location['station_id']:
|
||||
location['station_name'] = c.Universe.get_universe_stations_station_id(station_id=location['station_id']).result()['station_name']
|
||||
else:
|
||||
context = {'character_id': request.META['HTTP_EVE_CHARID'],
|
||||
'character_name': request.META['HTTP_EVE_CHARNAME']}
|
||||
return render(request, 'public/characternotexisting.html', context=context)
|
||||
location['station_name'] = "No Station"
|
||||
ship['ship_type_name'] = c.Universe.get_universe_types_type_id(type_id=ship['ship_type_id']).result()['type_name']
|
||||
|
||||
fat = Fat()
|
||||
fat.system = location['solar_system_name']
|
||||
fat.station = location['station_name']
|
||||
fat.shiptype = ship['ship_type_name']
|
||||
fat.fatlink = fatlink
|
||||
fat.character = character
|
||||
fat.user = character.user
|
||||
try:
|
||||
fat.full_clean()
|
||||
fat.save()
|
||||
context = {'registered': True}
|
||||
except ValidationError as e:
|
||||
messages = []
|
||||
for errorname, message in e.message_dict.items():
|
||||
messages.append(message[0].decode())
|
||||
context = {'errormessages': messages}
|
||||
else:
|
||||
context = {'trusted': True, 'expired': True}
|
||||
except ObjectDoesNotExist:
|
||||
context = {'trusted': True}
|
||||
else:
|
||||
context = {'trusted': False, 'fatname': fatname}
|
||||
return render(request, 'public/clickfatlinkview.html', context=context)
|
||||
context = {'character_id': token.character_id,
|
||||
'character_name': token.character_name}
|
||||
return render(request, 'registered/characternotexisting.html', context=context)
|
||||
else:
|
||||
context = {'expired': True}
|
||||
except (ObjectDoesNotExist, KeyError):
|
||||
context = {}
|
||||
return render(request, 'registered/clickfatlinkview.html', context=context)
|
||||
|
||||
|
||||
@login_required
|
||||
|
@ -1,90 +0,0 @@
|
||||
{% load staticfiles %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
<title>Fleet participation</title>
|
||||
|
||||
<!-- Bootstrap Core CSS -->
|
||||
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
|
||||
<!-- Custom Fonts -->
|
||||
<link href="{% static 'css/font-awesome.min.css' %}" rel="stylesheet" type="text/css">
|
||||
<link href="{% static 'css/sb-admin-2.css' %}" rel="stylesheet">
|
||||
{% block extra_css %}{% endblock extra_css %}
|
||||
<style>
|
||||
.grayiconecolor {
|
||||
color: #505050;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body onload=CCPEVE.requestTrust('{{ DOMAIN }}')>
|
||||
<div id="wrapper">
|
||||
<!-- Navigation -->
|
||||
|
||||
<nav class="navbar navbar-inverse navbar-static-top" role="navigation">
|
||||
|
||||
<div class="navbar-header ">
|
||||
<a class="navbar-brand " href="/dashboard/">
|
||||
<div class="fa fa-cog fa-spin"></div>
|
||||
{% if IS_CORP %}
|
||||
{{ CORP_NAME }}
|
||||
{% else %}
|
||||
{{ ALLIANCE_NAME }}
|
||||
{% endif %}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- /.navbar-header -->
|
||||
|
||||
<ul class="nav navbar-top-links navbar-right">
|
||||
{% if user.is_authenticated %}
|
||||
<li><a href="{% url 'auth_logout_user' %}">Logout</a></li>
|
||||
{% else %}
|
||||
<li><a href="{% url 'auth_login_user' %}">Login</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<!-- /.navbar-static-side -->
|
||||
</nav>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header text-center">Character not found!</h1>
|
||||
<div class="col-lg-12 container" id="example">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">{{ character_name }}</div>
|
||||
<div class="panel-body">
|
||||
<div class="col-lg-2 col-sm-2">
|
||||
<img class="ra-avatar img-responsive" src="https://image.eveonline.com/Character/{{ character_id }}_128.jpg">
|
||||
</div>
|
||||
<div class="col-lg-10 col-sm-2">
|
||||
<div class="alert alert-danger" role="alert">Character not registered!</div>
|
||||
This character is not part of any registered API-key. You must go to <a href=" {% url 'auth_api_key_management' %}">API key management</a> and add an API with the character on before being able to click fleet attendance links.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<script src="{% static 'js/jquery.min.js' %}"></script>
|
||||
<script src="{% static 'js/jquery.datetimepicker.js' %}"></script>
|
||||
<script src="{% static 'js/bootstrap.min.js' %}"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,96 +0,0 @@
|
||||
{% load staticfiles %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
<title>Fleet participation</title>
|
||||
|
||||
<!-- Bootstrap Core CSS -->
|
||||
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
|
||||
<!-- Custom Fonts -->
|
||||
<link href="{% static 'css/font-awesome.min.css' %}" rel="stylesheet" type="text/css">
|
||||
<link href="{% static 'css/sb-admin-2.css' %}" rel="stylesheet">
|
||||
{% block extra_css %}{% endblock extra_css %}
|
||||
<style>
|
||||
.grayiconecolor {
|
||||
color: #505050;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body onload=CCPEVE.requestTrust('{{ DOMAIN }}')>
|
||||
<div id="wrapper">
|
||||
<!-- Navigation -->
|
||||
|
||||
<nav class="navbar navbar-inverse navbar-static-top" role="navigation">
|
||||
|
||||
<div class="navbar-header ">
|
||||
<a class="navbar-brand " href="/dashboard/">
|
||||
<div class="fa fa-cog fa-spin"></div>
|
||||
{% if IS_CORP %}
|
||||
{{ CORP_NAME }}
|
||||
{% else %}
|
||||
{{ ALLIANCE_NAME }}
|
||||
{% endif %}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- /.navbar-header -->
|
||||
|
||||
<ul class="nav navbar-top-links navbar-right">
|
||||
{% if user.is_authenticated %}
|
||||
<li><a href="{% url 'auth_logout_user' %}">Logout</a></li>
|
||||
{% else %}
|
||||
<li><a href="{% url 'auth_login_user' %}">Login</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<!-- /.navbar-static-side -->
|
||||
</nav>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-lg-12">
|
||||
{% if registered %}<h1 class="page-header text-center">Fleet registered!</h1> {% elif expired%}<h1 class="page-header text-center">This link has expired.</h1> {% elif errormessages%}<h1 class="page-header text-center">Something horrible happened. Shoot your FC!</h1>{% else %}<h1 class="page-header text-center">Invalid link.</h1>{% endif %}
|
||||
<div class="col-lg-12 container" id="example">
|
||||
{% for message in errormessages %}
|
||||
<div class="alert alert-danger" role="alert">{{ message }}</div>
|
||||
{% endfor %}
|
||||
{% if trusted %}
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Fleet stats</div>
|
||||
<div class="panel-body">
|
||||
<div class="col-lg-2 col-sm-2">
|
||||
<img class="ra-avatar img-responsive" src="https://image.eveonline.com/{% if IS_CORP %}Corporation/{{ CORPORATION_ID }}{% else %}Alliance/{{ ALLIANCE_ID }}{% endif %}_128.png">
|
||||
</div>
|
||||
<div class="col-lg-7 col-sm-2">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
<div class="alert alert-danger" role="alert">This page requires trust to operate.</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<script src="{% static 'js/jquery.min.js' %}"></script>
|
||||
<script src="{% static 'js/jquery.datetimepicker.js' %}"></script>
|
||||
<script src="{% static 'js/bootstrap.min.js' %}"></script>
|
||||
</body>
|
||||
</html>
|
25
stock/templates/registered/characternotexisting.html
Normal file
25
stock/templates/registered/characternotexisting.html
Normal file
@ -0,0 +1,25 @@
|
||||
{% extends 'public/base.html' %}
|
||||
{% block title %}Fleet Participation{% endblock %}
|
||||
{% block page_title %}Fleet Participation{% endblock %}
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header text-center">Character not found!</h1>
|
||||
<div class="col-lg-12 container" id="example">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">{{ character_name }}</div>
|
||||
<div class="panel-body">
|
||||
<div class="col-lg-2 col-sm-2">
|
||||
<img class="ra-avatar img-responsive" src="https://image.eveonline.com/Character/{{ character_id }}_128.jpg">
|
||||
</div>
|
||||
<div class="col-lg-10 col-sm-2">
|
||||
<div class="alert alert-danger" role="alert">Character not registered!</div>
|
||||
This character is not part of any registered API-key. You must go to <a href=" {% url 'auth_api_key_management' %}">API key management</a> and add an API with the character on before being able to click fleet attendance links.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
36
stock/templates/registered/clickfatlinkview.html
Normal file
36
stock/templates/registered/clickfatlinkview.html
Normal file
@ -0,0 +1,36 @@
|
||||
{% extends 'public/base.html' %}
|
||||
{% block title %}Fleet participation{% endblock %}
|
||||
{% block page_title %}Fleet Participation{% endblock %}
|
||||
{% block content %}
|
||||
<div class="col-lg-12">
|
||||
{% if registered %}
|
||||
<h1 class="page-header text-center">Fleet registered!</h1>
|
||||
{% elif expired%}
|
||||
<h1 class="page-header text-center">This link has expired.</h1>
|
||||
{% elif errormessages%}
|
||||
<h1 class="page-header text-center">Something horrible happened. Shoot your FC!</h1>
|
||||
{% else %}
|
||||
<h1 class="page-header text-center">Invalid link.</h1>
|
||||
{% endif %}
|
||||
<div class="col-lg-12 container" id="example">
|
||||
{% for message in errormessages %}
|
||||
<div class="alert alert-danger" role="alert">{{ message }}</div>
|
||||
{% endfor %}
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Fleet Stats</div>
|
||||
<div class="panel-body">
|
||||
<div class="col-lg-2 col-sm-2">
|
||||
<img class="ra-avatar img-responsive" src="https://image.eveonline.com/{% if IS_CORP %}Corporation/{{ CORPORATION_ID }}{% else %}Alliance/{{ ALLIANCE_ID }}{% endif %}_128.png">
|
||||
</div>
|
||||
<div class="col-lg-7 col-sm-2">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user