diff --git a/alliance_auth/urls.py b/alliance_auth/urls.py index 58e59e7e..f6de2ca4 100644 --- a/alliance_auth/urls.py +++ b/alliance_auth/urls.py @@ -41,6 +41,7 @@ urlpatterns = patterns('', url(r'^characters/', 'eveonline.views.characters_view', name='auth_characters'), url(r'^main_character_change/(\w+)/$', 'eveonline.views.main_character_change', name='auth_main_character_change'), + url(r'^corporation_stats/$', 'eveonline.views.corp_stats_view', name='auth_corp_stats'), # Group management url(r'^groups/', 'groupmanagement.views.groups_view', name='auth_groups'), diff --git a/eveonline/views.py b/eveonline/views.py index 1dfb19ee..a83025d1 100644 --- a/eveonline/views.py +++ b/eveonline/views.py @@ -3,6 +3,7 @@ from django.http import HttpResponseRedirect 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 util import add_member_permission from util import remove_member_permission @@ -15,6 +16,9 @@ from util.common_task import add_user_to_group from util.common_task import remove_user_from_group from util.common_task import deactivate_services from util.common_task import generate_corp_group_name +from eveonline.models import EveCorporationInfo +from eveonline.models import EveCharacter +from authentication.models import AuthServicesInfo def disable_alliance_member(user, char_id): @@ -127,3 +131,27 @@ def main_character_change(request, char_id): return HttpResponseRedirect("/characters") return HttpResponseRedirect("/characters") + +@login_required +@permission_required('auth.corp_stats') +def corp_stats_view(request): + # Get the corp the member is in + auth_info = AuthServicesInfo.objects.get(user=request.user) + main_char = EveCharacter.objects.get(character_id=auth_info.main_char_id) + corp = EveCorporationInfo.objects.get(corporation_id=main_char.corporation_id) + current_count = 0 + allcharacters = [] + all_auth = AuthServicesInfo.objects.all() + for auth in all_auth: + if auth.main_char_id != "": + user_char = EveCharacter.objects.get(character_id=auth.main_char_id) + + if user_char.corporation_id == corp.corporation_id: + current_count = current_count + 1 + allcharacters.append(user_char) + + context = {"corp": corp, + "currentCount": current_count, + "characters": allcharacters} + + return render_to_response('registered/corpstats.html', context, context_instance=RequestContext(request)) diff --git a/templates/public/base.html b/templates/public/base.html index fdf04e6f..e51631fc 100644 --- a/templates/public/base.html +++ b/templates/public/base.html @@ -108,6 +108,14 @@ href="{% url 'password_change' %}">Change Password + {% if perms.auth.corp_stats %} +
  • + Corporation Stats +
  • + {% endif %} + {% if perms.auth.group_management %}
  • +

    Corporation Stats

    + {% if perms.auth.alliance_member %} +
    + +
    +
    +
    +
    Corporation
    + +
    +
    +
    + +
    +

    Name: {{ corp.corporation_name }}

    + +

    Ticker: {{ corp.corporation_ticker }}

    + +

    Memeber: {{ corp.member_count }}

    + +

    Total Authed Members: {{ currentCount }}

    +
    +
    +
    +
    + + +
    +
    +
    Registered Characters
    +
    +
    + + {% for character in characters %} + + + + {% endfor %} +
    +

    {{ character.character_name }}

    +
    +
    +
    +
    +
    + +
    +
    + {% else %} +

    Not part of the alliance

    + {% endif %} + +{% endblock content %} diff --git a/templates/registered/dashboard.html b/templates/registered/dashboard.html index 5ec0b070..93df6fbd 100644 --- a/templates/registered/dashboard.html +++ b/templates/registered/dashboard.html @@ -41,9 +41,9 @@
    Groups
    -
    +
    - {% for group in user.groups.all %} + {% for char in user.groups.all %}

    {{ group.name }}

    diff --git a/util/__init__.py b/util/__init__.py index 0b27fd27..3c873e26 100644 --- a/util/__init__.py +++ b/util/__init__.py @@ -12,6 +12,7 @@ def bootstrap_permissions(): Permission.objects.get_or_create(codename="jabber_broadcast", content_type=ct, name="jabber_broadcast") Permission.objects.get_or_create(codename="human_resources", content_type=ct, name="human_resources") Permission.objects.get_or_create(codename="blue_member", content_type=ct, name="blue_member") + Permission.objects.get_or_create(codename="corp_stats", content_type=ct, name="corp_stats") Group.objects.get_or_create(name=settings.DEFAULT_ALLIANCE_GROUP) Group.objects.get_or_create(name=settings.DEFAULT_BLUE_GROUP)