mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-12 14:00:17 +02:00
Correct old template URLs.
Remove redundant name from fatlink. Remove optimer app dependency. And other general cleanup. Thanks @TargetZ3R0
This commit is contained in:
parent
2fa1d9998d
commit
1bd5eecd54
@ -2,11 +2,9 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from allianceauth.optimer.models import OpTimer
|
|
||||||
|
|
||||||
|
|
||||||
class FatlinkForm(forms.Form):
|
class FatlinkForm(forms.Form):
|
||||||
fatname = forms.CharField(label=_('Name of fat-link'), required=True)
|
fleet = forms.CharField(label=_("Fleet Name"), max_length=50)
|
||||||
duration = forms.IntegerField(label=_("Duration of fat-link"), required=True, initial=30, min_value=1,
|
duration = forms.IntegerField(label=_("Duration of fat-link"), required=True, initial=30, min_value=1,
|
||||||
max_value=2147483647)
|
max_value=2147483647, help_text=_('minutes'))
|
||||||
fleet = forms.ModelChoiceField(label=_("Fleet"), queryset=OpTimer.objects.all().order_by('operation_name'))
|
|
||||||
|
@ -2,12 +2,10 @@
|
|||||||
# Generated by Django 1.10.1 on 2016-09-05 21:39
|
# Generated by Django 1.10.1 on 2016-09-05 21:39
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
from django.utils.timezone import utc
|
from django.utils import timezone
|
||||||
|
|
||||||
import allianceauth.fleetactivitytracking.models
|
import allianceauth.fleetactivitytracking.models
|
||||||
|
|
||||||
@ -36,9 +34,9 @@ class Migration(migrations.Migration):
|
|||||||
name='Fatlink',
|
name='Fatlink',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('fatdatetime', models.DateTimeField(default=datetime.datetime(2016, 9, 5, 21, 39, 17, 307954, tzinfo=utc))),
|
('fatdatetime', models.DateTimeField(default=timezone.now)),
|
||||||
('duration', models.PositiveIntegerField()),
|
('duration', models.PositiveIntegerField()),
|
||||||
('fleet', models.CharField(default=b'', max_length=254)),
|
('fleet', models.CharField(default='', max_length=254)),
|
||||||
('name', models.CharField(max_length=254)),
|
('name', models.CharField(max_length=254)),
|
||||||
('hash', models.CharField(max_length=254, unique=True)),
|
('hash', models.CharField(max_length=254, unique=True)),
|
||||||
('creator', models.ForeignKey(on_delete=models.SET(
|
('creator', models.ForeignKey(on_delete=models.SET(
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
# Generated by Django 2.0.2 on 2018-02-28 18:00
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('fleetactivitytracking', '0004_make_strings_more_stringy'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='fatlink',
|
||||||
|
name='name',
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='fatlink',
|
||||||
|
name='fleet',
|
||||||
|
field=models.CharField(max_length=254),
|
||||||
|
),
|
||||||
|
]
|
@ -12,13 +12,12 @@ def get_sentinel_user():
|
|||||||
class Fatlink(models.Model):
|
class Fatlink(models.Model):
|
||||||
fatdatetime = models.DateTimeField(default=timezone.now)
|
fatdatetime = models.DateTimeField(default=timezone.now)
|
||||||
duration = models.PositiveIntegerField()
|
duration = models.PositiveIntegerField()
|
||||||
fleet = models.CharField(max_length=254, default="")
|
fleet = models.CharField(max_length=254)
|
||||||
name = models.CharField(max_length=254)
|
|
||||||
hash = models.CharField(max_length=254, unique=True)
|
hash = models.CharField(max_length=254, unique=True)
|
||||||
creator = models.ForeignKey(User, on_delete=models.SET(get_sentinel_user))
|
creator = models.ForeignKey(User, on_delete=models.SET(get_sentinel_user))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.fleet
|
||||||
|
|
||||||
|
|
||||||
class Fat(models.Model):
|
class Fat(models.Model):
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-lg-10 col-sm-2">
|
<div class="col-lg-10 col-sm-2">
|
||||||
<div class="alert alert-danger" role="alert">{% trans "Character not registered!" %}</div>
|
<div class="alert alert-danger" role="alert">{% trans "Character not registered!" %}</div>
|
||||||
{% trans "This character is not part of any registered API-key. You must go to" %} <a href=" {% url 'auth_api_key_management' %}">{% trans "API key management</a> and add an API with the character on before being able to click fleet attendance links." %}
|
{% trans "This character is not associated with an auth account." %} <a href=" {% url 'authentication:add_character' %}">{% trans "Add it here" %}</a> {% trans "before attempting to click fleet attendance links." %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -10,12 +10,12 @@
|
|||||||
<h1 class="page-header text-center">{% blocktrans %}Participation data statistics for {{ month }}, {{ year }}{% endblocktrans %}
|
<h1 class="page-header text-center">{% blocktrans %}Participation data statistics for {{ month }}, {{ year }}{% endblocktrans %}
|
||||||
{% if char_id %}
|
{% if char_id %}
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<a href="{% url 'fatlink:user_statistics_month' char_id previous_month|date:"Y" previous_month|date:"m" %}" class="btn btn-info">{% trans "Previous month" %}</a>
|
<a href="{% url 'fatlink:user_statistics_month' char_id previous_month|date:'Y' previous_month|date:'m' %}" class="btn btn-info">{% trans "Previous month" %}</a>
|
||||||
<a href="{% url 'fatlink:user_statistics_month' char_id next_month|date:"Y" next_month|date:"m" %}" class="btn btn-info">{% trans "Next month" %}</a>
|
<a href="{% url 'fatlink:user_statistics_month' char_id next_month|date:'Y' next_month|date:'m' %}" class="btn btn-info">{% trans "Next month" %}</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</h1>
|
</h1>
|
||||||
<h2>{% blocktrans %}{{ user }} has collected {{ n_fats }} links this month.{% endblocktrans %}</h2>
|
<h2>{% blocktrans %}{{ user }} has collected {{ n_fats }} link{{ n_fats|pluralize }} this month.{% endblocktrans %}</h2>
|
||||||
<table class="table table-responsive">
|
<table class="table table-responsive">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="col-md-2 text-center">{% trans "Ship" %}</th>
|
<th class="col-md-2 text-center">{% trans "Ship" %}</th>
|
||||||
@ -29,26 +29,24 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
{% if created_fats %}
|
{% if created_fats %}
|
||||||
<h2>{% blocktrans %}{{ user }} has created {{ n_created_fats }} links this month.{% endblocktrans %}</h2>
|
<h2>{% blocktrans %}{{ user }} has created {{ n_created_fats }} link{{ n_created_fats|pluralize }} this month.{% endblocktrans %}</h2>
|
||||||
{% if created_fats %}
|
{% if created_fats %}
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="text-center">{% trans "Name" %}</th>
|
|
||||||
<th class="text-center">{% trans "Creator" %}</th>
|
|
||||||
<th class="text-center">{% trans "Fleet" %}</th>
|
<th class="text-center">{% trans "Fleet" %}</th>
|
||||||
|
<th class="text-center">{% trans "Creator" %}</th>
|
||||||
<th class="text-center">{% trans "Eve Time" %}</th>
|
<th class="text-center">{% trans "Eve Time" %}</th>
|
||||||
<th class="text-center">{% trans "Duration" %}</th>
|
<th class="text-center">{% trans "Duration" %}</th>
|
||||||
<th class="text-center">{% trans "Edit" %}</th>
|
<th class="text-center">{% trans "Edit" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for link in created_fats %}
|
{% for link in created_fats %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="text-center"><a href="{% url 'auth_click_fatlink_view' %}{{ link.hash }}/{{ link.name }}">{{ link.name }}</a></td>
|
<td class="text-center"><a href="{% url 'fatlink:click' link.hash %}" class="label label-primary">{{ link.fleet }}</a></td>
|
||||||
<td class="text-center">{{ link.creator.username }}</td>
|
<td class="text-center">{{ link.creator.username }}</td>
|
||||||
<td class="text-center">{{ link.fleet }}</td>
|
|
||||||
<td class="text-center">{{ link.fatdatetime }}</td>
|
<td class="text-center">{{ link.fatdatetime }}</td>
|
||||||
<td class="text-center">{{ link.duration }}</td>
|
<td class="text-center">{{ link.duration }}</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<a href="{% url 'auth_modify_fatlink_view' %}{{ link.hash }}/{{ link.name }}">
|
<a href="{% url 'fatlink:modify' link.hash %}">
|
||||||
<button type="button" class="btn btn-info"><span
|
<button type="button" class="btn btn-info"><span
|
||||||
class="glyphicon glyphicon-edit"></span></button>
|
class="glyphicon glyphicon-edit"></span></button>
|
||||||
</a>
|
</a>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
{% if fats %}
|
{% if fats %}
|
||||||
<table class="table table-responsive">
|
<table class="table table-responsive">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="text-center">{% trans "fatname" %}</th>
|
<th class="text-center">{% trans "Fleet" %}</th>
|
||||||
<th class="text-center">{% trans "Character" %}</th>
|
<th class="text-center">{% trans "Character" %}</th>
|
||||||
<th class="text-center">{% trans "System" %}</th>
|
<th class="text-center">{% trans "System" %}</th>
|
||||||
<th class="text-center">{% trans "Ship" %}</th>
|
<th class="text-center">{% trans "Ship" %}</th>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% for fat in fats %}
|
{% for fat in fats %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="text-center">{{ fat.fatlink.name }}</td>
|
<td class="text-center">{{ fat.fatlink.fleet }}</td>
|
||||||
<td class="text-center">{{ fat.character.character_name }}</td>
|
<td class="text-center">{{ fat.character.character_name }}</td>
|
||||||
{% if fat.station != "No Station" %}
|
{% if fat.station != "No Station" %}
|
||||||
<td class="text-center">{% blocktrans %}Docked in {% endblocktrans %}{{ fat.system }}</td>
|
<td class="text-center">{% blocktrans %}Docked in {% endblocktrans %}{{ fat.system }}</td>
|
||||||
@ -79,13 +79,13 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% for link in fatlinks %}
|
{% for link in fatlinks %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="text-center"><a href="{% url 'fatlink:click_fatlink' %}{{ link.hash }}/{{ link.name }}">{{ link.name }}</a></td>
|
<td class="text-center"><a href="{% url 'fatlink:click' link.hash %}" class="label label-primary">{{ link.fleet }}</a></td>
|
||||||
<td class="text-center">{{ link.creator.username }}</td>
|
<td class="text-center">{{ link.creator.username }}</td>
|
||||||
<td class="text-center">{{ link.fleet }}</td>
|
<td class="text-center">{{ link.fleet }}</td>
|
||||||
<td class="text-center">{{ link.fatdatetime }}</td>
|
<td class="text-center">{{ link.fatdatetime }}</td>
|
||||||
<td class="text-center">{{ link.duration }}</td>
|
<td class="text-center">{{ link.duration }}</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<a href="{% url 'fatlink:modify' %}{{ link.hash }}/{{ link.name }}" class="btn btn-info">
|
<a href="{% url 'fatlink:modify' link.hash %}" class="btn btn-info">
|
||||||
<span class="glyphicon glyphicon-edit"></span>
|
<span class="glyphicon glyphicon-edit"></span>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
@ -25,10 +25,6 @@ urlpatterns = [
|
|||||||
views.fatlink_monthly_personal_statistics_view,
|
views.fatlink_monthly_personal_statistics_view,
|
||||||
name='user_statistics_month'),
|
name='user_statistics_month'),
|
||||||
url(r'^create/$', views.create_fatlink_view, name='create'),
|
url(r'^create/$', views.create_fatlink_view, name='create'),
|
||||||
url(r'^modify/$', views.modify_fatlink_view, name='modify'),
|
url(r'^modify/(?P<fat_hash>[a-zA-Z0-9_-]+)/$', views.modify_fatlink_view, name='modify'),
|
||||||
url(r'^modify/(?P<hash>[a-zA-Z0-9_-]+)/([a-z0-9_-]+)$',
|
url(r'^link/(?P<fat_hash>[a-zA-Z0-9]+)/$', views.click_fatlink_view, name='click'),
|
||||||
views.modify_fatlink_view),
|
|
||||||
url(r'^link/$', views.fatlink_view, name='click_fatlink'),
|
|
||||||
url(r'^link/(?P<hash>[a-zA-Z0-9]+)/(?P<fatname>[a-z0-9_-]+)/$',
|
|
||||||
views.click_fatlink_view),
|
|
||||||
]
|
]
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import random
|
|
||||||
import string
|
|
||||||
|
|
||||||
from allianceauth.authentication.models import CharacterOwnership
|
from allianceauth.authentication.models import CharacterOwnership
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
@ -17,7 +15,7 @@ from esi.decorators import token_required
|
|||||||
from allianceauth.eveonline.providers import provider
|
from allianceauth.eveonline.providers import provider
|
||||||
from .forms import FatlinkForm
|
from .forms import FatlinkForm
|
||||||
from .models import Fatlink, Fat
|
from .models import Fatlink, Fat
|
||||||
from slugify import slugify
|
from django.utils.crypto import get_random_string
|
||||||
|
|
||||||
from allianceauth.eveonline.models import EveAllianceInfo
|
from allianceauth.eveonline.models import EveAllianceInfo
|
||||||
from allianceauth.eveonline.models import EveCharacter
|
from allianceauth.eveonline.models import EveCharacter
|
||||||
@ -181,7 +179,7 @@ def fatlink_personal_statistics_view(request, year=datetime.date.today().year):
|
|||||||
|
|
||||||
personal_fats = Fat.objects.select_related('fatlink').filter(user=user).order_by('id')
|
personal_fats = Fat.objects.select_related('fatlink').filter(user=user).order_by('id')
|
||||||
|
|
||||||
monthlystats = [0 for month in range(1, 13)]
|
monthlystats = [0 for i in range(1, 13)]
|
||||||
|
|
||||||
for fat in personal_fats:
|
for fat in personal_fats:
|
||||||
fatdate = fat.fatlink.fatdatetime
|
fatdate = fat.fatlink.fatdatetime
|
||||||
@ -236,8 +234,8 @@ def fatlink_monthly_personal_statistics_view(request, year, month, char_id=None)
|
|||||||
@login_required
|
@login_required
|
||||||
@token_required(
|
@token_required(
|
||||||
scopes=['esi-location.read_location.v1', 'esi-location.read_ship_type.v1', 'esi-universe.read_structures.v1'])
|
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):
|
def click_fatlink_view(request, token, fat_hash=None):
|
||||||
fatlink = get_object_or_404(Fatlink, hash=hash, name=fatname)
|
fatlink = get_object_or_404(Fatlink, hash=fat_hash)
|
||||||
|
|
||||||
if (timezone.now() - fatlink.fatdatetime) < datetime.timedelta(seconds=(fatlink.duration * 60)):
|
if (timezone.now() - fatlink.fatdatetime) < datetime.timedelta(seconds=(fatlink.duration * 60)):
|
||||||
|
|
||||||
@ -298,12 +296,11 @@ def create_fatlink_view(request):
|
|||||||
logger.debug("Submitting fleetactivitytracking by user %s" % request.user)
|
logger.debug("Submitting fleetactivitytracking by user %s" % request.user)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
fatlink = Fatlink()
|
fatlink = Fatlink()
|
||||||
fatlink.name = slugify(form.cleaned_data["fatname"])
|
|
||||||
fatlink.fleet = form.cleaned_data["fleet"]
|
fatlink.fleet = form.cleaned_data["fleet"]
|
||||||
fatlink.duration = form.cleaned_data["duration"]
|
fatlink.duration = form.cleaned_data["duration"]
|
||||||
fatlink.fatdatetime = timezone.now()
|
fatlink.fatdatetime = timezone.now()
|
||||||
fatlink.creator = request.user
|
fatlink.creator = request.user
|
||||||
fatlink.hash = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(10))
|
fatlink.hash = get_random_string(length=15)
|
||||||
try:
|
try:
|
||||||
fatlink.full_clean()
|
fatlink.full_clean()
|
||||||
fatlink.save()
|
fatlink.save()
|
||||||
@ -331,25 +328,19 @@ def create_fatlink_view(request):
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('auth.fleetactivitytracking')
|
@permission_required('auth.fleetactivitytracking')
|
||||||
def modify_fatlink_view(request, hash=""):
|
def modify_fatlink_view(request, fat_hash=None):
|
||||||
logger.debug("modify_fatlink_view called by user %s" % request.user)
|
logger.debug("modify_fatlink_view called by user %s" % request.user)
|
||||||
if not hash:
|
fatlink = get_object_or_404(Fatlink, hash=fat_hash)
|
||||||
return redirect('fatlink:view')
|
|
||||||
|
|
||||||
try:
|
|
||||||
fatlink = Fatlink.objects.get(hash=hash)
|
|
||||||
except Fatlink.DoesNotExist:
|
|
||||||
raise Http404
|
|
||||||
|
|
||||||
if request.GET.get('removechar', None):
|
if request.GET.get('removechar', None):
|
||||||
character_id = request.GET.get('removechar')
|
character_id = request.GET.get('removechar')
|
||||||
character = EveCharacter.objects.get(character_id=character_id)
|
character = EveCharacter.objects.get(character_id=character_id)
|
||||||
logger.debug("Removing character %s from fleetactivitytracking %s" % (character.character_name, fatlink.name))
|
logger.debug("Removing character %s from fleetactivitytracking %s" % (character.character_name, fatlink))
|
||||||
|
|
||||||
Fat.objects.filter(fatlink=fatlink).filter(character=character).delete()
|
Fat.objects.filter(fatlink=fatlink).filter(character=character).delete()
|
||||||
|
|
||||||
if request.GET.get('deletefat', None):
|
if request.GET.get('deletefat', None):
|
||||||
logger.debug("Removing fleetactivitytracking %s" % fatlink.name)
|
logger.debug("Removing fleetactivitytracking %s" % fatlink)
|
||||||
fatlink.delete()
|
fatlink.delete()
|
||||||
return redirect('fatlink:view')
|
return redirect('fatlink:view')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user