mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-12 22:10:16 +02:00
Merge branch 'v2-dev-master-merge' of https://github.com/allianceauth/allianceauth into v2-dev
This commit is contained in:
commit
4f5fc18c66
@ -37,8 +37,12 @@ class CorpStat(object):
|
|||||||
self.n_fats = Fat.objects.filter(character__corporation_id=self.corp.corporation_id).filter(
|
self.n_fats = Fat.objects.filter(character__corporation_id=self.corp.corporation_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.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):
|
||||||
@ -55,8 +59,12 @@ class MemberStat(object):
|
|||||||
self.n_fats = Fat.objects.filter(user_id=member.pk).filter(
|
self.n_fats = Fat.objects.filter(user_id=member.pk).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):
|
||||||
@ -117,7 +125,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}
|
||||||
@ -153,7 +161,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}
|
||||||
|
@ -12,7 +12,7 @@ class ChoiceInline(admin.TabularInline):
|
|||||||
|
|
||||||
class QuestionAdmin(admin.ModelAdmin):
|
class QuestionAdmin(admin.ModelAdmin):
|
||||||
fieldsets = [
|
fieldsets = [
|
||||||
(None, {'fields': ['title', 'help_text']}),
|
(None, {'fields': ['title', 'help_text', 'multi_select']}),
|
||||||
]
|
]
|
||||||
inlines = [ChoiceInline]
|
inlines = [ChoiceInline]
|
||||||
|
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10 on 2017-10-20 13:51
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('hrapplications', '0005_remove_legacy_models'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='applicationquestion',
|
||||||
|
name='multi_select',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
@ -9,6 +9,7 @@ from allianceauth.eveonline.models import EveCorporationInfo
|
|||||||
class ApplicationQuestion(models.Model):
|
class ApplicationQuestion(models.Model):
|
||||||
title = models.CharField(max_length=254, verbose_name='Question')
|
title = models.CharField(max_length=254, verbose_name='Question')
|
||||||
help_text = models.CharField(max_length=254, blank=True, null=True)
|
help_text = models.CharField(max_length=254, blank=True, null=True)
|
||||||
|
multi_select = models.BooleanField(default=False)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Question: " + self.title
|
return "Question: " + self.title
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<div cass="text-center">{{ question.help_text }}</div>
|
<div cass="text-center">{{ question.help_text }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for choice in question.choices.all %}
|
{% for choice in question.choices.all %}
|
||||||
<input type="radio" name="{{ question.pk }}" id="id_{{ question.pk }}" value="{{ choice.choice_text }}" />
|
<input type={% if question.multi_select == False %}"radio"{% else %}"checkbox"{% endif %} name="{{ question.pk }}" id="id_{{ question.pk }}" value="{{ choice.choice_text }}" />
|
||||||
<label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br />
|
<label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br />
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<textarea class="form-control" cols="30" id="id_{{ question.pk }}" name="{{ question.pk }}" rows="4"></textarea>
|
<textarea class="form-control" cols="30" id="id_{{ question.pk }}" name="{{ question.pk }}" rows="4"></textarea>
|
||||||
|
@ -62,8 +62,8 @@ def hr_application_create_view(request, form_id=None):
|
|||||||
application.save()
|
application.save()
|
||||||
for question in app_form.questions.all():
|
for question in app_form.questions.all():
|
||||||
response = ApplicationResponse(question=question, application=application)
|
response = ApplicationResponse(question=question, application=application)
|
||||||
response.answer = request.POST.get(str(question.pk),
|
response.answer = "\n".join(request.POST.getlist(str(question.pk),
|
||||||
"Failed to retrieve answer provided by applicant.")
|
""))
|
||||||
response.save()
|
response.save()
|
||||||
logger.info("%s created %s" % (request.user, application))
|
logger.info("%s created %s" % (request.user, application))
|
||||||
return redirect('hrapplications:view')
|
return redirect('hrapplications:view')
|
||||||
|
@ -26,11 +26,12 @@ 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")
|
||||||
|
|
||||||
|
@ -186,7 +186,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))
|
||||||
@ -196,7 +196,7 @@ def srp_request_view(request, fleet_srp):
|
|||||||
"Your SRP request Killmail link is invalid. Please make sure you are using zKillboard."))
|
"Your SRP request Killmail link is invalid. Please make sure you are using zKillboard."))
|
||||||
return redirect("srp:management")
|
return redirect("srp:management")
|
||||||
|
|
||||||
if request.user.character_ownerships.filter(character__character_name=victim_name).exists():
|
if request.user.character_ownerships.filter(character__character_id=str(victim_id)).exists():
|
||||||
srp_request.srp_ship_name = provider.get_itemtype(ship_type_id).name
|
srp_request.srp_ship_name = provider.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
|
||||||
@ -209,8 +209,8 @@ def srp_request_view(request, fleet_srp):
|
|||||||
else:
|
else:
|
||||||
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 %(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("srp:management")
|
return redirect("srp:management")
|
||||||
else:
|
else:
|
||||||
logger.debug("Returning blank SrpFleetUserRequestForm")
|
logger.debug("Returning blank SrpFleetUserRequestForm")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user