diff --git a/README.md b/README.md index 9bdae977..3456128a 100755 --- a/README.md +++ b/README.md @@ -69,6 +69,10 @@ Special Permissions In Admin: auth | user | timer_management ( Access to create and remove timers) auth | user | timer_view ( Access to timerboard to view timers) auth | user | srp_management ( Allows for an individual to create and remove srp fleets and fleet data) + auth | user | sigtracker_management ( Allows for an individual to create and remove signitures) + auth | user | sigtracker_view ( Allows for an individual view signitures) + auth | user | optimer_management ( Allows for an individual to create and remove fleet operations) + auth | user | optimer_view ( Allows for an individual view fleet operations) Active Developers diff --git a/alliance_auth/urls.py b/alliance_auth/urls.py index c0468ab4..a5f51def 100755 --- a/alliance_auth/urls.py +++ b/alliance_auth/urls.py @@ -170,6 +170,10 @@ urlpatterns = patterns('', url(r'^sigtracker/$', 'sigtracker.views.sigtracker_view', name='auth_signature_view'), url(r'^add_signature/$', 'sigtracker.views.add_signature_view', name='auth_add_signature_view'), url(r'^remove_signature/(\w+)', 'sigtracker.views.remove_signature', name='auth_remove_signature'), - + # Fleet Operations Timers + url(r'^optimer/$', 'optimer.views.optimer_view', name='auth_optimer_view'), + url(r'^add_optimer/$', 'optimer.views.add_optimer_view', name='auth_add_optimer_view'), + url(r'^remove_optimer/(\w+)', 'optimer.views.remove_optimer', name='auth_remove_optimer'), + ) diff --git a/optimer/__init__.py b/optimer/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/optimer/admin.py b/optimer/admin.py new file mode 100644 index 00000000..85271e70 --- /dev/null +++ b/optimer/admin.py @@ -0,0 +1,6 @@ +from django.contrib import admin + +from models import optimer + +admin.site.register(optimer) +# Register your models here. diff --git a/optimer/form.py b/optimer/form.py new file mode 100644 index 00000000..06b895c1 --- /dev/null +++ b/optimer/form.py @@ -0,0 +1,20 @@ +from django import forms +from django.core.validators import MaxValueValidator, MinValueValidator + + + +class opForm(forms.Form): + + doctrine = forms.CharField(max_length=254, required=True, label='Doctrine') + system = forms.CharField(max_length=254, required=True, label="System") + location = forms.CharField(max_length=254, required=True, label="Location") + start_time = forms.CharField(max_length=254, required=True, label="Start Time") + end_time = forms.CharField(max_length=254, required=True, label="End Time") + operation_name = forms.CharField(max_length=254, required=True, label="Operation Name") + fc = forms.CharField(max_length=254, required=True, label="Fleet Commander") + details = forms.CharField(max_length=254, required=False, label="Extra Details") + + + + + diff --git a/optimer/models.py b/optimer/models.py new file mode 100644 index 00000000..79d91d90 --- /dev/null +++ b/optimer/models.py @@ -0,0 +1,21 @@ +from django.db import models +from django.contrib.auth.models import User +from django.utils import timezone +from eveonline.models import EveCharacter +from eveonline.models import EveCorporationInfo + + +class optimer(models.Model): + class Meta: + ordering = ['start_time'] + doctrine = models.CharField(max_length=254, default="") + system = models.CharField(max_length=254, default="") + location = models.CharField(max_length=254, default="") + start_time = models.CharField(max_length=254, default="") + end_time = models.CharField(max_length=254, default="") + operation_name = models.CharField(max_length=254, default="") + fc = models.CharField(max_length=254, default="") + details = models.CharField(max_length=254, default="") + post_time = models.DateTimeField(default=timezone.now) + eve_character = models.ForeignKey(EveCharacter) + diff --git a/optimer/tests.py b/optimer/tests.py new file mode 100644 index 00000000..a39b155a --- /dev/null +++ b/optimer/tests.py @@ -0,0 +1 @@ +# Create your tests here. diff --git a/optimer/views.py b/optimer/views.py new file mode 100644 index 00000000..6c06974e --- /dev/null +++ b/optimer/views.py @@ -0,0 +1,83 @@ + + +from django.http import HttpResponseRedirect +from django.template import RequestContext +from django.shortcuts import render_to_response +from django.contrib.auth.decorators import login_required +from django.contrib.auth.decorators import permission_required +from django.contrib.auth.decorators import user_passes_test +from django.utils import timezone + +from util import check_if_user_has_permission +from authentication.managers import AuthServicesInfoManager +from eveonline.managers import EveManager +from form import opForm +from models import optimer + +import logging + +logger = logging.getLogger(__name__) + +def optimer_util_test(user): + return check_if_user_has_permission(user, 'member') or check_if_user_has_permission(user, 'blue_member') + + +@login_required +@user_passes_test(optimer_util_test) +@permission_required('auth.optimer_view') +def optimer_view(request): + logger.debug("optimer_view called by user %s" % request.user) + optimer_list = optimer.objects.all() + render_items = {'optimer': optimer.objects.all(),} + + return render_to_response('registered/operationmanagement.html', render_items, context_instance=RequestContext(request)) + + +@login_required +@permission_required('auth.optimer_management') +def add_optimer_view(request): + logger.debug("add_optimer_view called by user %s" % request.user) + if request.method == 'POST': + form = opForm(request.POST) + logger.debug("Request type POST contains form valid: %s" % form.is_valid()) + if form.is_valid(): + #Get Current Time + post_time = timezone.now() + # Get character + auth_info = AuthServicesInfoManager.get_auth_service_info(request.user) + character = EveManager.get_character_by_id(auth_info.main_char_id) + # handle valid form + op = optimer() + op.doctrine = form.cleaned_data['doctrine'] + op.system = form.cleaned_data['system'] + op.location = form.cleaned_data['location'] + op.start_time = form.cleaned_data['start_time'] + op.end_time = form.cleaned_data['end_time'] + op.operation_name = form.cleaned_data['operation_name'] + op.fc = form.cleaned_data['fc'] + op.details = form.cleaned_data['details'] + op.create_time = post_time + op.eve_character = character + op.save() + logger.info("User %s created op timer with name %s" % (request.user, op.operation_name)) + return HttpResponseRedirect("/optimer/") + else: + logger.debug("Returning new opForm") + form = opForm() + + render_items = {'form': form} + + return render_to_response('registered/addoperation.html', render_items, context_instance=RequestContext(request)) + + +@login_required +@permission_required('auth.optimer_management') +def remove_optimer(request, optimer_id): + logger.debug("remove_optimer called by user %s for operation id %s" % (request.user, optimer_id)) + if optimer.objects.filter(id=optimer_id).exists(): + op = optimer.objects.get(id=optimer_id) + op.delete() + logger.info("Deleting optimer id %s by user %s" % (optimer_id, request.user)) + else: + logger.error("Unable to delete optimer id %s for user %s - operation matching id not found." % (optimer_id, request.user)) + return HttpResponseRedirect("/optimer/") diff --git a/stock/templates/public/base.html b/stock/templates/public/base.html index e92d1b8a..fc820a98 100755 --- a/stock/templates/public/base.html +++ b/stock/templates/public/base.html @@ -140,18 +140,24 @@ {% endif %} {% if perms.auth.member or perms.auth.blue_member %} -
  • +
  • Signature Tracker
  • - + +
  • + Fleet Operations +
  • + {% if perms.auth.timer_view %}
  • OP Timers + class="fa fa-clock-o fa-fw grayiconecolor"> Structure Timers
  • {% endif %} diff --git a/stock/templates/registered/addoperation.html b/stock/templates/registered/addoperation.html new file mode 100644 index 00000000..bf0aa8d5 --- /dev/null +++ b/stock/templates/registered/addoperation.html @@ -0,0 +1,38 @@ +{% extends "public/base.html" %} +{% load bootstrap %} +{% load staticfiles %} + +{% block title %}Alliance Auth - Fleet Operation Create{% endblock %} + +{% block page_title %}Create Operation{% endblock page_title %} +{% block extra_css %} + {% endblock extra_css %} + +{% block content %} +
    +

    Create Fleet Operation

    + +
    +
    +
    + +
    +
    +
    +
    + +{% endblock content %} + +{% block extra_script %} + + $('#id_eve_time').datetimepicker({ + maskInput: true, + format: 'Y-m-d H:i',minDate:0 + }); + +{% endblock extra_script %} diff --git a/stock/templates/registered/addtimer.html b/stock/templates/registered/addtimer.html index eadd6c01..53939938 100755 --- a/stock/templates/registered/addtimer.html +++ b/stock/templates/registered/addtimer.html @@ -1,38 +1,38 @@ -{% extends "public/base.html" %} -{% load bootstrap %} -{% load staticfiles %} - -{% block title %}Alliance Auth - Timer Create{% endblock %} - -{% block page_title %}Timer Create{% endblock page_title %} -{% block extra_css %} - {% endblock extra_css %} - -{% block content %} -
    -

    Create Timer

    - -
    -
    -
    - -
    -
    -
    -
    - -{% endblock content %} - -{% block extra_script %} - - $('#id_eve_time').datetimepicker({ - maskInput: true, - format: 'Y-m-d H:i',minDate:0 - }); - -{% endblock extra_script %} +{% extends "public/base.html" %} +{% load bootstrap %} +{% load staticfiles %} + +{% block title %}Alliance Auth - Structure Timer Create{% endblock %} + +{% block page_title %}Timer Create{% endblock page_title %} +{% block extra_css %} + {% endblock extra_css %} + +{% block content %} +
    +

    Create Structure Timer

    + +
    +
    +
    + +
    +
    +
    +
    + +{% endblock content %} + +{% block extra_script %} + + $('#id_eve_time').datetimepicker({ + maskInput: true, + format: 'Y-m-d H:i',minDate:0 + }); + +{% endblock extra_script %} diff --git a/stock/templates/registered/operationmanagement.html b/stock/templates/registered/operationmanagement.html new file mode 100644 index 00000000..d05d95dd --- /dev/null +++ b/stock/templates/registered/operationmanagement.html @@ -0,0 +1,71 @@ +{% extends "public/base.html" %} +{% load staticfiles %} + +{% block title %}Alliance Auth{% endblock %} + +{% block page_title %}Fleet Operation Management{% endblock page_title %} +{% block extra_css %}{% endblock extra_css %} + +{% block content %} +
    +

    Fleet Operation Timers + +

    + + + + + + + + + + + {% if perms.auth.optimer_management %} + + + {% endif %} + + + {% for ops in optimer %} + + + + + + + + + + + {% if perms.auth.optimer_management %} + + + + + {% endif %} + + {% endfor %} + +
    Operation NameForm Up SystemForm Up LocationStart TimeEnd TimeFCDetailsPost TimeCreatorAction
    {{ ops.operation_name }} + {{ ops.system }} + {{ ops.location }}{{ ops.start_time }}{{ ops.end_time }}{{ ops.fc }}{{ ops.details }}{{ ops.post_time}}{{ ops.eve_character }} + + + +
    + + +
    + + + + +{% endblock content %} diff --git a/stock/templates/registered/signaturemanagement.html b/stock/templates/registered/signaturemanagement.html index ff7820ad..d9010bcc 100644 --- a/stock/templates/registered/signaturemanagement.html +++ b/stock/templates/registered/signaturemanagement.html @@ -43,18 +43,19 @@ {{ sigt.sigtype }} {{ sigt.status }} {{ sigt.notes }} - {{ sigt.post_time}} + {{ sigt.post_time}} {% if perms.auth.signature_management %} {{ sigt.eve_character }} - - + + - - + + - {% endif %} + {% endif %} + {% endfor %} diff --git a/stock/templates/registered/timermanagement.html b/stock/templates/registered/timermanagement.html index 3af49280..1064ccd8 100755 --- a/stock/templates/registered/timermanagement.html +++ b/stock/templates/registered/timermanagement.html @@ -1,342 +1,342 @@ -{% extends "public/base.html" %} -{% load staticfiles %} - -{% block title %}Alliance Auth{% endblock %} - -{% block page_title %}Timer Management{% endblock page_title %} -{% block extra_css %}{% endblock extra_css %} - -{% block content %} -
    -

    Operation Timers - -

    -
    -
    - Current Eve Time: -
    -
    -

    Next Timer

    - - - - - - - - - - {% if perms.auth.timer_management %} - - {% endif %} - - {% if closest_timer %} - {% ifequal closest_timer.important True %} - - {% else %} - - {% endifequal %} - - - - - - - - {% if perms.auth.timer_management %} - - {% endif %} - {% endif %} - -
    DetailsObjectiveSystemStructureEve TimeLocal TimeCreatorAction
    {{ closest_timer.details }} - {% ifequal closest_timer.objective "Hostile" %} -
    - Hostile -
    - {% endifequal %} - {% ifequal closest_timer.objective "Friendly" %} -
    - Friendly -
    - {% endifequal %} - {% ifequal closest_timer.objective "Neutral" %} -
    - Neutral -
    - {% endifequal %} -
    {{ closest_timer.system }} {{ closest_timer.planet_moon }} - - {% ifequal closest_timer.structure "I-HUB" %} -
    - I-HUB -
    - {% endifequal %} - {% ifequal closest_timer.structure "POCO" %} -
    - POCO -
    - {% endifequal %} - {% ifequal closest_timer.structure "POS[S]" %} -
    - POS [S] -
    - {% endifequal %} - {% ifequal closest_timer.structure "POS[M]" %} -
    - POS [M] -
    - {% endifequal %} - {% ifequal closest_timer.structure "POS[L]" %} -
    - POS [L] -
    - {% endifequal %} - {% ifequal closest_timer.structure "Station" %} -
    - Station -
    - {% endifequal %} - {% ifequal closest_timer.structure "TCU" %} -
    - TCU -
    - {% endifequal %} - {% ifequal closest_timer.structure "Other" %} -
    - Other -
    - {% endifequal %} -
    {{ closest_timer.eve_time | date:"Y-m-d H:i" }}{{ closest_timer.eve_character.character_name }} - - - - -
    - {% if corp_timers %} -

    Corp Timers

    - - - - - - - - - - {% if perms.auth.timer_management %} - - {% endif %} - - {% for timer in corp_timers %} - {% ifequal timer.important True %} - - {% else %} - - {% endifequal %} - - - - - - - - {% if perms.auth.timer_management %} - - {% endif %} - - {% endfor %} -
    DetailsObjectiveSystemStructureEve TimeLocal TimeCreatorAction
    {{ timer.details }} - {% ifequal timer.objective "Hostile" %} -
    - Hostile -
    - {% endifequal %} - {% ifequal timer.objective "Friendly" %} -
    - Friendly -
    - {% endifequal %} - {% ifequal timer.objective "Neutral" %} -
    - Neutral -
    - {% endifequal %} -
    {{ timer.system }} {{ timer.planet_moon }} - - {% ifequal timer.structure "I-HUB" %} -
    - I-HUB -
    - {% endifequal %} - {% ifequal timer.structure "POCO" %} -
    - POCO -
    - {% endifequal %} - {% ifequal timer.structure "POS[S]" %} -
    - POS [S] -
    - {% endifequal %} - {% ifequal timer.structure "POS[M]" %} -
    - POS [M] -
    - {% endifequal %} - {% ifequal timer.structure "POS[L]" %} -
    - POS [L] -
    - {% endifequal %} - {% ifequal timer.structure "Station" %} -
    - Station -
    - {% endifequal %} - {% ifequal timer.structure "TCU" %} -
    - TCU -
    - {% endifequal %} - {% ifequal timer.structure "Other" %} -
    - Other -
    - {% endifequal %} -
    {{ timer.eve_time | date:"Y-m-d H:i" }}
    {{ timer.eve_character.character_name }} - - - -
    - {% endif %} -

    Future Timers

    - - - - - - - - - - {% if perms.auth.timer_management %} - - {% endif %} - - {% for timer in timers %} - {% ifnotequal timer closest_timer %} - {% ifequal timer.important True %} - - {% else %} - - {% endifequal %} - - - - - - - - {% if perms.auth.timer_management %} - - {% endif %} - - {% endifnotequal %} - {% endfor %} -
    DetailsObjectiveSystemStructureEve TimeLocal TimeCreatorAction
    {{ timer.details }} - {% ifequal timer.objective "Hostile" %} -
    - Hostile -
    - {% endifequal %} - {% ifequal timer.objective "Friendly" %} -
    - Friendly -
    - {% endifequal %} - {% ifequal timer.objective "Neutral" %} -
    - Neutral -
    - {% endifequal %} -
    {{ timer.system }} {{ timer.planet_moon }} - - {% ifequal timer.structure "I-HUB" %} -
    - I-HUB -
    - {% endifequal %} - {% ifequal timer.structure "POCO" %} -
    - POCO -
    - {% endifequal %} - {% ifequal timer.structure "POS[S]" %} -
    - POS [S] -
    - {% endifequal %} - {% ifequal timer.structure "POS[M]" %} -
    - POS [M] -
    - {% endifequal %} - {% ifequal timer.structure "POS[L]" %} -
    - POS [L] -
    - {% endifequal %} - {% ifequal timer.structure "Station" %} -
    - Station -
    - {% endifequal %} - {% ifequal timer.structure "TCU" %} -
    - TCU -
    - {% endifequal %} - {% ifequal timer.structure "Other" %} -
    - Other -
    - {% endifequal %} -
    {{ timer.eve_time | date:"Y-m-d H:i" }}
    {{ timer.eve_character.character_name }} - - - -
    -
    - - - - - -{% endblock content %} +{% extends "public/base.html" %} +{% load staticfiles %} + +{% block title %}Alliance Auth{% endblock %} + +{% block page_title %}Structure Timer Management{% endblock page_title %} +{% block extra_css %}{% endblock extra_css %} + +{% block content %} +
    +

    Structure Timers + +

    +
    +
    + Current Eve Time: +
    +
    +

    Next Timer

    + + + + + + + + + + {% if perms.auth.timer_management %} + + {% endif %} + + {% if closest_timer %} + {% ifequal closest_timer.important True %} + + {% else %} + + {% endifequal %} + + + + + + + + {% if perms.auth.timer_management %} + + {% endif %} + {% endif %} + +
    DetailsObjectiveSystemStructureEve TimeLocal TimeCreatorAction
    {{ closest_timer.details }} + {% ifequal closest_timer.objective "Hostile" %} +
    + Hostile +
    + {% endifequal %} + {% ifequal closest_timer.objective "Friendly" %} +
    + Friendly +
    + {% endifequal %} + {% ifequal closest_timer.objective "Neutral" %} +
    + Neutral +
    + {% endifequal %} +
    {{ closest_timer.system }} {{ closest_timer.planet_moon }} + + {% ifequal closest_timer.structure "I-HUB" %} +
    + I-HUB +
    + {% endifequal %} + {% ifequal closest_timer.structure "POCO" %} +
    + POCO +
    + {% endifequal %} + {% ifequal closest_timer.structure "POS[S]" %} +
    + POS [S] +
    + {% endifequal %} + {% ifequal closest_timer.structure "POS[M]" %} +
    + POS [M] +
    + {% endifequal %} + {% ifequal closest_timer.structure "POS[L]" %} +
    + POS [L] +
    + {% endifequal %} + {% ifequal closest_timer.structure "Station" %} +
    + Station +
    + {% endifequal %} + {% ifequal closest_timer.structure "TCU" %} +
    + TCU +
    + {% endifequal %} + {% ifequal closest_timer.structure "Other" %} +
    + Other +
    + {% endifequal %} +
    {{ closest_timer.eve_time | date:"Y-m-d H:i" }}{{ closest_timer.eve_character.character_name }} + + + + +
    + {% if corp_timers %} +

    Corp Timers

    + + + + + + + + + + {% if perms.auth.timer_management %} + + {% endif %} + + {% for timer in corp_timers %} + {% ifequal timer.important True %} + + {% else %} + + {% endifequal %} + + + + + + + + {% if perms.auth.timer_management %} + + {% endif %} + + {% endfor %} +
    DetailsObjectiveSystemStructureEve TimeLocal TimeCreatorAction
    {{ timer.details }} + {% ifequal timer.objective "Hostile" %} +
    + Hostile +
    + {% endifequal %} + {% ifequal timer.objective "Friendly" %} +
    + Friendly +
    + {% endifequal %} + {% ifequal timer.objective "Neutral" %} +
    + Neutral +
    + {% endifequal %} +
    {{ timer.system }} {{ timer.planet_moon }} + + {% ifequal timer.structure "I-HUB" %} +
    + I-HUB +
    + {% endifequal %} + {% ifequal timer.structure "POCO" %} +
    + POCO +
    + {% endifequal %} + {% ifequal timer.structure "POS[S]" %} +
    + POS [S] +
    + {% endifequal %} + {% ifequal timer.structure "POS[M]" %} +
    + POS [M] +
    + {% endifequal %} + {% ifequal timer.structure "POS[L]" %} +
    + POS [L] +
    + {% endifequal %} + {% ifequal timer.structure "Station" %} +
    + Station +
    + {% endifequal %} + {% ifequal timer.structure "TCU" %} +
    + TCU +
    + {% endifequal %} + {% ifequal timer.structure "Other" %} +
    + Other +
    + {% endifequal %} +
    {{ timer.eve_time | date:"Y-m-d H:i" }}
    {{ timer.eve_character.character_name }} + + + +
    + {% endif %} +

    Future Timers

    + + + + + + + + + + {% if perms.auth.timer_management %} + + {% endif %} + + {% for timer in timers %} + {% ifnotequal timer closest_timer %} + {% ifequal timer.important True %} + + {% else %} + + {% endifequal %} + + + + + + + + {% if perms.auth.timer_management %} + + {% endif %} + + {% endifnotequal %} + {% endfor %} +
    DetailsObjectiveSystemStructureEve TimeLocal TimeCreatorAction
    {{ timer.details }} + {% ifequal timer.objective "Hostile" %} +
    + Hostile +
    + {% endifequal %} + {% ifequal timer.objective "Friendly" %} +
    + Friendly +
    + {% endifequal %} + {% ifequal timer.objective "Neutral" %} +
    + Neutral +
    + {% endifequal %} +
    {{ timer.system }} {{ timer.planet_moon }} + + {% ifequal timer.structure "I-HUB" %} +
    + I-HUB +
    + {% endifequal %} + {% ifequal timer.structure "POCO" %} +
    + POCO +
    + {% endifequal %} + {% ifequal timer.structure "POS[S]" %} +
    + POS [S] +
    + {% endifequal %} + {% ifequal timer.structure "POS[M]" %} +
    + POS [M] +
    + {% endifequal %} + {% ifequal timer.structure "POS[L]" %} +
    + POS [L] +
    + {% endifequal %} + {% ifequal timer.structure "Station" %} +
    + Station +
    + {% endifequal %} + {% ifequal timer.structure "TCU" %} +
    + TCU +
    + {% endifequal %} + {% ifequal timer.structure "Other" %} +
    + Other +
    + {% endifequal %} +
    {{ timer.eve_time | date:"Y-m-d H:i" }}
    {{ timer.eve_character.character_name }} + + + +
    +
    + + + + + +{% endblock content %} diff --git a/util/__init__.py b/util/__init__.py index 84a09d70..6c269077 100755 --- a/util/__init__.py +++ b/util/__init__.py @@ -24,6 +24,8 @@ def bootstrap_permissions(): Permission.objects.get_or_create(codename="srp_management", content_type=ct, name="srp_management") Permission.objects.get_or_create(codename="signature_management", content_type=ct, name="signature_management") Permission.objects.get_or_create(codename="signature_view", content_type=ct, name="signature_view") + Permission.objects.get_or_create(codename="optimer_management", content_type=ct, name="optimer_management") + Permission.objects.get_or_create(codename="optimer_view", content_type=ct, name="optimer_view") Group.objects.get_or_create(name=settings.DEFAULT_AUTH_GROUP) Group.objects.get_or_create(name=settings.DEFAULT_BLUE_GROUP) logger.info("Bootstrapped permissions for auth and created default groups.")