Skip to content

Commit

Permalink
Merge pull request #16 from ppfeufer/development
Browse files Browse the repository at this point in the history
Release: v0.4.0
  • Loading branch information
ppfeufer authored Sep 11, 2020
2 parents 4ea3352 + 0d3225d commit 147b790
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 30 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Alliance Auth AFAT - Another Fleet Activity Tracker

[![version](https://img.shields.io/pypi/v/allianceauth-afat?label=release)](https://pypi.org/project/allianceauth-afat/)
[![license](https://img.shields.io/badge/license-GPLv3-green)](https://pypi.org/project/allianceauth-afat/)
[![python](https://img.shields.io/pypi/pyversions/allianceauth-afat)](https://pypi.org/project/allianceauth-afat/)
[![django](https://img.shields.io/pypi/djversions/allianceauth-afat?label=django)](https://pypi.org/project/allianceauth-afat/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](http://black.readthedocs.io/en/latest/)

An Improved FAT/PAP System for [Alliance Auth](https://gitlab.com/allianceauth/allianceauth).

AFAT is a privately maintained whitelabel of ImicusFAT. Updates will only be pushed when ImicusFAT get updates to keep on par with it.
Expand Down
2 changes: 1 addition & 1 deletion afat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
default_app_config = "afat.apps.AfatConfig"

__title__ = "Fleet Activity Tracking"
__version__ = "0.3.5"
__version__ = "0.4.0"
2 changes: 1 addition & 1 deletion afat/auth_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ def register_menu():

@hooks.register("url_hook")
def register_url():
return UrlHook(urls, "afat", r"^afat/")
return UrlHook(urls, "afat", r"^fleetactivitytracking/")
23 changes: 20 additions & 3 deletions afat/templates/afat/ally_stat.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,31 @@
{% block page_title %}{{ alliance }} {% trans "Statistics" %}{% endblock %}

{% block content %}
<script type="text/javascript" src="{% static 'afat/javascript/chart-js/Chart.min.js' %}"></script>
<script type="application/javascript" src="{% static 'afat/javascript/chart-js/Chart.min.js' %}"></script>

<div class="col-lg-12">
<br>
{% include 'afat/menu.html' %}

<h2>{{ alliance }} {% trans "Statistics" %}</h2>
<h4>{{ month|month }} {{ year }}</h4>
<h4>
{% if month == '1' %}
<a class="btn btn-primary" href="{% url 'afat:stats_ally' ally.alliance_id 12 year_prev %}" title='{% trans "Previous Month" %}'><i class="fas fa-backward"></i></a>
{% else %}
<a class="btn btn-primary" href="{% url 'afat:stats_ally' ally.alliance_id month_prev year %}" title='{% trans "Previous Month" %}'><i class="fas fa-backward"></i></a>
{% endif %}

{{ month|month }} {{ year }}

{% if month_next > month_current and year_next > year_current %}
{% elif month == '12' %}
<a class="btn btn-primary" href="{% url 'afat:stats_ally' ally.alliance_id 1 year_next %}" title='{% trans "Next Month" %}'><i class="fas fa-forward"></i></a>
<a class="btn btn-primary" href="{% url 'afat:stats_ally' ally.alliance_id month_current year_current %}" title='{% trans "Current Month" %}'><i class="fas fa-fast-forward"></i></a>
{% else %}
<a class="btn btn-primary" href="{% url 'afat:stats_ally' ally.alliance_id month_next year %}" title='{% trans "Next Month" %}'><i class="fas fa-forward"></i></a>
<a class="btn btn-primary" href="{% url 'afat:stats_ally' ally.alliance_id month_current year_current %}" title='{% trans "Current Month" %}'><i class="fas fa-fast-forward"></i></a>
{% endif %}
</h4>

<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#graphs">{% trans "Graphs" %}</a></li>
Expand Down Expand Up @@ -161,7 +178,7 @@ <h3>{{ alliance }} {% trans "Member Corps" %}</h3>
<td>{{ value.1 }}</td>
<td>{{ value.2 }}</td>
<td>
<a class="btn btn-primary" href="/afat/stats/corp/{{ value.0 }}/{{ month }}/{{ year }}/">
<a class="btn btn-primary" href="{% url 'afat:stats_corp' value.0 month year %}">
<span class="glyphicon glyphicon-eye-open"></span>
</a>
</td>
Expand Down
29 changes: 23 additions & 6 deletions afat/templates/afat/char_stat.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,34 @@
{% load i18n %}
{% load static %}

{% block page_title %}{{ character }} {% trans "Statistics" %}{% endblock %}
{% block page_title %}{{ character.character_name }} {% trans "FAT Statistics" %}{% endblock %}

{% block content %}
<script type="text/javascript" src="{% static 'afat/javascript/chart-js/Chart.min.js' %}"></script>
<script type="application/javascript" src="{% static 'afat/javascript/chart-js/Chart.min.js' %}"></script>

<div class="col-lg-12">
<br>
{% include 'afat/menu.html' %}

<h2>{{ character }} {% trans "Statistics" %}</h2>
<h4>{{ month|month }} {{ year }}</h4>
<h2>{{ character.character_name }} {% trans "Statistics" %}</h2>
<h4>
{% if month == '1' %}
<a class="btn btn-primary" href="{% url 'afat:stats_char' character.character_id 12 year_prev %}" title='{% trans "Previous Month" %}'><i class="fas fa-backward"></i></a>
{% else %}
<a class="btn btn-primary" href="{% url 'afat:stats_char' character.character_id month_prev year %}" title='{% trans "Previous Month" %}'><i class="fas fa-backward"></i></a>
{% endif %}

{{ month|month }} {{ year }}

{% if month_next > month_current and year_next > year_current %}
{% elif month == '12' %}
<a class="btn btn-primary" href="{% url 'afat:stats_char' character.character_id 1 year_next %}" title='{% trans "Next Month" %}'><i class="fas fa-forward"></i></a>
<a class="btn btn-primary" href="{% url 'afat:stats_char' character.character_id month_current year_current %}" title='{% trans "Current Month" %}'><i class="fas fa-fast-forward"></i></a>
{% else %}
<a class="btn btn-primary" href="{% url 'afat:stats_char' character.character_id month_next year %}" title='{% trans "Next Month" %}'><i class="fas fa-forward"></i></a>
<a class="btn btn-primary" href="{% url 'afat:stats_char' character.character_id month_current year_current %}" title='{% trans "Current Month" %}'><i class="fas fa-fast-forward"></i></a>
{% endif %}
</h4>

<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#graphs">{% trans "Graphs" %}</a></li>
Expand Down Expand Up @@ -53,7 +70,7 @@ <h4>{% trans "FATs by Time of Day" %}</h4>
type: "line",
data: {
datasets: [{
label: "# of FATs",
label: '{% trans "# of FATs" %}',
data: {{ data_time.1|safe }},
backgroundColor: {{ data_time.2|safe }}
}],
Expand All @@ -70,7 +87,7 @@ <h4>{% trans "FATs by Time of Day" %}</h4>

<div id="rawdata" class="tab-pane fade panel-default">
<div class="panel-body">
<h4>{% trans "FATs for" %} {{ character }}</h4>
<h4>{% trans "FATs for" %} {{ character.character_name }}</h4>

<table class="table" id="raw-data">
<thead>
Expand Down
23 changes: 20 additions & 3 deletions afat/templates/afat/corp_stat.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,31 @@
{% block page_title %}{{ corporation }} {% trans "Statistics" %}{% endblock %}

{% block content %}
<script type="text/javascript" src="{% static 'afat/javascript/chart-js/Chart.min.js' %}"></script>
<script type="application/javascript" src="{% static 'afat/javascript/chart-js/Chart.min.js' %}"></script>

<div class="col-lg-12">
<br>
{% include 'afat/menu.html' %}

<h2>{{ corporation }} {% trans "Statistics" %}</h2>
<h4>{{ month|month }} {{ year }}</h4>
<h4>
{% if month == '1' %}
<a class="btn btn-primary" href="{% url 'afat:stats_corp' corp.corporation_id 12 year_prev %}" title='{% trans "Previous Month" %}'><i class="fas fa-backward"></i></a>
{% else %}
<a class="btn btn-primary" href="{% url 'afat:stats_corp' corp.corporation_id month_prev year %}" title='{% trans "Previous Month" %}'><i class="fas fa-backward"></i></a>
{% endif %}

{{ month|month }} {{ year }}

{% if month_next > month_current and year_next > year_current %}
{% elif month == '12' %}
<a class="btn btn-primary" href="{% url 'afat:stats_corp' corp.corporation_id 1 year_next %}" title='{% trans "Next Month" %}'><i class="fas fa-forward"></i></a>
<a class="btn btn-primary" href="{% url 'afat:stats_corp' corp.corporation_id month_current year_current %}" title='{% trans "Current Month" %}'><i class="fas fa-fast-forward"></i></a>
{% else %}
<a class="btn btn-primary" href="{% url 'afat:stats_corp' corp.corporation_id month_next year %}" title='{% trans "Next Month" %}'><i class="fas fa-forward"></i></a>
<a class="btn btn-primary" href="{% url 'afat:stats_corp' corp.corporation_id month_current year_current %}" title='{% trans "Current Month" %}'><i class="fas fa-fast-forward"></i></a>
{% endif %}
</h4>

<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#graphs">{% trans "Graphs" %}</a></li>
Expand Down Expand Up @@ -135,7 +152,7 @@ <h3>{{ corporation }} {% trans "Members" %}</h3>
<td>{{ key }}</td>
<td>{{ value.0 }}</td>
<td>
<a class="btn btn-primary" href="/afat/stats/char/{{ value.1 }}/{{ month }}/{{ year }}/">
<a class="btn btn-primary" href="{% url 'afat:stats_char' value.1 month year %}">
<span class="glyphicon glyphicon-eye-open"></span>
</a>
</td>
Expand Down
6 changes: 4 additions & 2 deletions afat/templates/afat/date_select.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{% include "afat/menu.html" %}

<h2>{{ corporation }} {% trans "Fleet Activity" %}</h2>
<h4>{% trans "Only months with FAT data in the last 12 months are shown." %}</h4>
<h4>{% trans "Only months with FAT data of the current year are shown." %}</h4>

<table class="table">
<thead>
Expand All @@ -26,9 +26,11 @@ <h4>{% trans "Only months with FAT data in the last 12 months are shown." %}</h4
<td>{{ month.0|month }}</td>
<td>{{ month.1 }}</td>
<td>
<a href="/afat/stats/{% if type == 0 %}corp{% elif type == 1 %}ally{% endif %}/{% if corporation == 'No Alliance' %}000{% else %}{{ corpid }}{% endif %}/{{ month.0 }}/{{ year }}/" class="btn btn-primary">
{% if corporation != 'No Alliance' %}
<a href="{% url 'afat:stats' %}{% if type == 0 %}corp{% elif type == 1 %}ally{% endif %}/{{ corpid }}/{{ month.0 }}/{{ year }}/" class="btn btn-primary">
<span class="glyphicon glyphicon-eye-open"></span>
</a>
{% endif %}
</td>
</tr>
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion afat/templates/afat/fleet_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ <h5 class="modal-title" id="modalLongTitle">{% trans "Delete FAT" %}</h5>
{% block extra_javascript %}
{% include 'bundles/datatables-js.html' %}

<script type="text/javascript" src="{% static 'afat/javascript/clipboard-js/clipboard.min.js' %}"></script>
<script type="application/javascript" src="{% static 'afat/javascript/clipboard-js/clipboard.min.js' %}"></script>
{% endblock %}

{% block extra_css %}
Expand Down
14 changes: 8 additions & 6 deletions afat/templates/afat/stats_main.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ <h4>
<div class="tab-content">
<div id="mine" class="tab-pane fade in active panel-default">
<div class="panel-body">
<h4>{% trans "Months" %}</h4>
<h4>{% trans "Your monthly stats" %}</h4>

<p>{% trans "Only months with FAT data in the last 12 months are shown." %}</p>
<p>{% trans "Only months with FAT data of the current year are shown." %}</p>

<ul class="nav nav-pills">
{% for char in charstats %}
Expand Down Expand Up @@ -75,7 +75,7 @@ <h4>{% trans "Months" %}</h4>
<td>{{ key|month }}</td>
<td>{{ value }}</td>
<td>
<a href="/afat/stats/char/{{ char.2 }}/{{ key }}/{{ year }}/" class="btn btn-primary">
<a href="{% url 'afat:stats_char' char.2 key year %}" class="btn btn-primary">
<span class="glyphicon glyphicon-eye-open"></span>
</a>
</td>
Expand Down Expand Up @@ -115,9 +115,11 @@ <h4 class="panel-title">
{{ key }}
</a>

<a class="btn btn-primary btn-sm pull-right" href="/afat/stats/ally/{% if key == 'No Alliance' %}000{% else %}{{ value.0 }}{% endif %}/" role="button">
{% if key != 'No Alliance' %}
<a class="btn btn-primary btn-sm pull-right" href="{% url 'afat:stats_ally' value.0 %}" role="button">
<span class="glyphicon glyphicon-eye-open" style="color: white"></span>
</a>
{% endif %}
</h4>
</div>

Expand All @@ -132,7 +134,7 @@ <h4 class="panel-title">
<td><img src="{{ corp.0|corporation_logo_url:32 }}" /></td>
<td>{{ corp.1 }}</td>
<td>
<a class="btn btn-primary" href="/afat/stats/corp/{{ corp.0 }}/">
<a class="btn btn-primary" href="{% url 'afat:stats_corp' corp.0 %}">
<span class="glyphicon glyphicon-eye-open"></span>
</a>
</td>
Expand All @@ -152,7 +154,7 @@ <h4 class="panel-title">
<td><img src="{{ data.0.0|corporation_logo_url:32 }}" /> </td>
<td>{{ data.0.1 }}</td>
<td>
<a class="btn btn-primary" href="/afat/stats/corp/{{ data.0.0 }}/">
<a class="btn btn-primary" href="{% url 'afat:stats_corp' data.0.0 %}">
<span class="glyphicon glyphicon-eye-open"></span>
</a>
</td>
Expand Down
7 changes: 6 additions & 1 deletion afat/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@

from . import views


app_name = "afat"

urlpatterns = [
url(r"^$", views.afat_view, name="afat_view"),
# stats main page
url(r"^stats/$", views.stats, name="stats"),
url(r"^stats/(?P<year>[0-9]+)/$", views.stats, name="stats"),
# stats corp
url(r"^stats/corp/$", views.stats_corp, name="stats_corp"),
url(r"^stats/corp/(?P<corpid>[0-9]+)/$", views.stats_corp, name="stats_corp"),
url(
r"^stats/corp/(?P<corpid>[0-9]+)/(?P<month>[0-9]+)/(?P<year>[0-9]+)/$",
views.stats_corp,
name="stats_corp",
),
# stats char
url(r"^stats/char/$", views.stats_char, name="stats_char"),
url(r"^stats/char/(?P<charid>[0-9]+)/$", views.stats_char, name="stats_char"),
url(
r"^stats/char/(?P<charid>[0-9]+)/(?P<month>[0-9]+)/(?P<year>[0-9]+)/$",
views.stats_char,
name="stats_char",
),
# stats alliance
url(r"^stats/ally/$", views.stats_alliance, name="stats_ally"),
url(
r"^stats/ally/(?P<allianceid>[0-9]+)/$", views.stats_alliance, name="stats_ally"
Expand All @@ -31,6 +35,7 @@
views.stats_alliance,
name="stats_ally",
),
# fat links
url(r"^links/$", views.links, name="links"),
url(
r"^links/create/esi/(?P<hash>[a-zA-Z0-9]+)/$",
Expand Down
36 changes: 30 additions & 6 deletions afat/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ def afat_view(request):


@login_required()
def stats(request):
def stats(request, year=None):
if year is None:
year = datetime.now().year

if request.user.has_perm("afat.stats_corp_other"):
corps = EveCorporationInfo.objects.all()
alliances = EveAllianceInfo.objects.all()
Expand Down Expand Up @@ -109,7 +112,7 @@ def stats(request):

for char in chars:
char_l = [char.character.character_name]
char_fats = AFat.objects.filter(afatlink__afattime__year=datetime.now().year)
char_fats = AFat.objects.filter(afatlink__afattime__year=year)
char_stats = {}

for i in range(1, 13):
Expand All @@ -127,7 +130,8 @@ def stats(request):
context = {
"data": data,
"charstats": months,
"year": datetime.now().year,
"year": year,
"current_year": datetime.now().year,
}

logger.info("Statistics overview called by %s", request.user)
Expand Down Expand Up @@ -202,9 +206,15 @@ def stats_char(request, charid, month=None, year=None):
]

context = {
"character": character.character_name,
"character": character,
"month": month,
"month_current": datetime.now().month,
"month_prev": int(month) - 1,
"month_next": int(month) + 1,
"year": year,
"year_current": datetime.now().year,
"year_prev": int(year) - 1,
"year_next": int(year) + 1,
"data_ship_type": data_ship_type,
"data_time": data_time,
"fats": fats,
Expand Down Expand Up @@ -349,9 +359,16 @@ def stats_corp(request, corpid, month=None, year=None):
chars[char.character_name] = (fat_c, char.character_id)

context = {
"corp": corp,
"corporation": corp.corporation_name,
"month": month,
"month_current": datetime.now().month,
"month_prev": int(month) - 1,
"month_next": int(month) + 1,
"year": year,
"year_current": datetime.now().year,
"year_prev": int(year) - 1,
"year_next": int(year) + 1,
"data_stacked": data_stacked,
"data_time": data_time,
"data_weekday": data_weekday,
Expand Down Expand Up @@ -391,7 +408,7 @@ def stats_alliance(request, allianceid, month=None, year=None):
months.append((i, ally_fats))

context = {
"alliance": alliance_name,
"corporation": alliance_name,
"months": months,
"corpid": allianceid,
"year": year,
Expand Down Expand Up @@ -548,8 +565,15 @@ def stats_alliance(request, allianceid, month=None, year=None):

context = {
"alliance": alliance_name,
"ally": ally,
"month": month,
"month_current": datetime.now().month,
"month_prev": int(month) - 1,
"month_next": int(month) + 1,
"year": year,
"year_current": datetime.now().year,
"year_prev": int(year) - 1,
"year_next": int(year) + 1,
"data_stacked": data_stacked,
"data_avgs": data_avgs,
"data_time": data_time,
Expand Down Expand Up @@ -591,7 +615,7 @@ def link_add(request):
if "msg" in request.session:
msg = request.session.pop("msg")

link_types = AFatLinkType.objects.all()
link_types = AFatLinkType.objects.all().order_by("name")

context = {"link_types": link_types, "msg": msg}

Expand Down

0 comments on commit 147b790

Please sign in to comment.