This repository was archived by the owner on Jan 13, 2019. It is now read-only.
forked from allianceauth/allianceauth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initial corputils functionality, for auditing members in corpor…
…ation mode.
- Loading branch information
Showing
12 changed files
with
381 additions
and
200 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from django.conf import settings | ||
from django.shortcuts import render_to_response | ||
from django.template import RequestContext | ||
from django.contrib.auth.decorators import login_required | ||
from django.contrib.auth.decorators import permission_required | ||
|
||
from authentication.managers import AuthServicesInfoManager | ||
from services.managers.eve_api_manager import EveApiManager | ||
from eveonline.models import EveCorporationInfo | ||
from eveonline.models import EveCharacter | ||
from authentication.models import AuthServicesInfo | ||
|
||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
# Because corp-api only exist for the executor corp, this function will only be available in corporation mode. | ||
@login_required | ||
@permission_required('auth.corp_stats') | ||
def corp_member_view(request): | ||
logger.debug("corp_member_view called by user %s" % request.user) | ||
# Get the corp the member is in | ||
auth_info = AuthServicesInfo.objects.get(user=request.user) | ||
logger.debug("Got user %s authservicesinfo model %s" % (request.user, auth_info)) | ||
|
||
if settings.IS_CORP: | ||
corp = EveCorporationInfo.objects.get(corporation_id=settings.CORP_ID) | ||
|
||
member_list = EveApiManager.get_corp_membertracking() | ||
characters_with_api = {} | ||
characters_without_api = {} | ||
for char_id, member_data in member_list.iteritems(): | ||
try: | ||
char = EveCharacter.objects.get(character_id=char_id) | ||
user = char.user | ||
mainid = int(AuthServicesInfoManager.get_auth_service_info(user=user).main_char_id) | ||
characters_with_api.setdefault(mainid,{}).update({char_id:char.character_name}) | ||
except EveCharacter.DoesNotExist: | ||
mainid = char_id | ||
characters_without_api.setdefault(mainid,{}).update({char_id:member_data["name"]}) | ||
|
||
|
||
context = {"corp": corp, | ||
"characters_with_api": characters_with_api, | ||
"characters_without_api": characters_without_api} | ||
|
||
return render_to_response('registered/corputils.html',context, context_instance=RequestContext(request) ) | ||
else: | ||
logger.error("Not running in corporation mode. Cannot provide corp member tracking data." % (request.user, auth_info.main_char_id)) | ||
return render_to_response('registered/corputils.html', None, context_instance=RequestContext(request)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>{% extends "public/base.html" %} | ||
{% block title %}Alliance Auth{% endblock %} | ||
{% block page_title %}Corporation Stats{% endblock page_title %} | ||
{% load corputils_extras %} | ||
|
||
{% block content %} | ||
|
||
<div class="col-lg-12"> | ||
<h1 class="page-header text-center">Corporation Member Data</h1> | ||
{% if perms.auth.member %} | ||
<div class="col-lg-12 container" id="example"> | ||
{% if corp %} | ||
<div class="row"> | ||
<div class="col-lg-12"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Corporation</div> | ||
|
||
<div class="panel-body"> | ||
<div class="col-lg-5 col-sm-2"><img class= | ||
"ra-avatar img-responsive" src= | ||
"https://image.eveonline.com/Corporation/{{ corp.corporation_id }}_128.png"> | ||
</div> | ||
|
||
<div class="col-lg-7 col-sm-2"> | ||
<h4 class="">Name: {{ corp.corporation_name }}</h4> | ||
|
||
<p>Ticker: {{ corp.corporation_ticker }}</p> | ||
|
||
<p>Member: {{ corp.member_count }}</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
<div class="col-lg-12"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Registered Characters</div> | ||
<div class="panel-body"> | ||
<div style="overflow:auto;overflow-y:auto;"> | ||
<table class="table table-condensed"> | ||
<tr> | ||
<th class="text-center">Main character</th> | ||
<th class="text-center">Character list</th> | ||
</tr> | ||
{% for mainid, alts in characters_with_api.items %} | ||
<tr> | ||
<td class="text-center"> | ||
<p class="">{{ alts|get_dict_item:mainid }}</p> | ||
</td> | ||
<td class="text-center"> | ||
{% for charid, name in alts.items %} | ||
<p class="">{{ name}}</p> | ||
{% endfor %} | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
{% for mainid, alts in characters_without_api.items %} | ||
<tr bgcolor="#DD5500"> | ||
<td class="text-center"> | ||
<p class="">{{ alts|get_dict_item:mainid }}</p> | ||
</td> | ||
<td class="text-center"> | ||
<p class="">No API registered!</p> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% else %} | ||
<div class="container-fluid"> | ||
<div class="col-md-4 col-md-offset-4"> | ||
<div class="row"> | ||
<div class="alert alert-danger text-center" role="alert">No corporation model found. Contact your admin.</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% else %} | ||
{% if IS_CORP %} | ||
<div class="alert alert-danger" role="alert">You are not in the corporation.</div> | ||
{% else %} | ||
<div class="alert alert-danger" role="alert">You are not in the alliance.</div> | ||
{% endif %} | ||
{% endif %} | ||
</div> | ||
{% endblock content %} | ||
</title> | ||
</head> | ||
<body> | ||
|
||
</body> | ||
</html> |