Move templates and urls to apps.

Implement url hooks.
Many apps are now removable.
Default to assuming services have been migrated.
This commit is contained in:
Adarnof
2017-06-07 22:49:46 -04:00
parent 9cc9a36766
commit 97fe2ddfd0
62 changed files with 685 additions and 469 deletions

26
timerboard/auth_hooks.py Normal file
View File

@@ -0,0 +1,26 @@
from services.hooks import MenuItemHook, UrlHook
from alliance_auth import hooks
from timerboard import urls
class TimerboardMenu(MenuItemHook):
def __init__(self):
MenuItemHook.__init__(self, 'Structure Timers',
'fa fa-clock-o fa-fw grayiconecolor',
'timerboard:view',
navactive=['timerboard:'])
def render(self, request):
if request.user.has_perm('auth.timer_view'):
return MenuItemHook.render(self, request)
return ''
@hooks.register('menu_item_hook')
def register_menu():
return TimerboardMenu()
@hooks.register('url_hook')
def register_url():
return UrlHook(urls, 'timerboard', r'^timers/')

View File

@@ -0,0 +1,29 @@
{% extends "registered/base.html" %}
{% load bootstrap %}
{% load staticfiles %}
{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
{% block title %}{% trans "Alliance Auth - Structure Timer Create" %}{% endblock %}
{% block page_title %}{% trans "Timer Create" %}{% endblock page_title %}
{% block content %}
<div class="col-lg-12">
<h1 class="page-header text-center">{% trans "Create Structure Timer" %}</h1>
<div class="container-fluid">
<div class="col-md-4 col-md-offset-4">
<div class="row">
<form class="form-signin" role="form" action="" method="POST">
{% csrf_token %}
{{ form|bootstrap }}
<br/>
<button class="btn btn-lg btn-primary btn-block" type="submit">{% trans "Create Timer" %}</button>
</form>
</div>
</div>
</div>
</div>
{% endblock content %}

View File

@@ -0,0 +1,519 @@
{% extends "registered/base.html" %}
{% load staticfiles %}
{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
{% block title %}Alliance Auth{% endblock %}
{% block page_title %}{% trans "Structure Timer Management" %}{% endblock page_title %}
{% block extra_css %}{% endblock extra_css %}
{% block content %}
<div class="col-lg-12">
<h1 class="page-header text-center">{% trans "Structure Timers" %}
<div class="text-right">
{% if perms.auth.timer_management %}
<a href="{% url 'timerboard:add' %}" class="btn btn-success">{% trans "Create Structure Timer" %}</a>
{% endif %}
</div>
</h1>
<div class="col-lg-12 text-center">
<div class="label label-info text-left">
<b>{% trans "Current Eve Time:" %} </b>
</div><div class="label label-info text-left" id="current-time"></div>
</div>
{% if corp_timers %}
<h4><b>{% trans "Corp Timers" %}</b></h4>
<table class="table">
<tr>
<th style="width:150px" class="text-center">{% trans "Details" %}</th>
<th class="text-center">{% trans "Objective" %}</th>
<th class="text-center">{% trans "System" %}</th>
<th class="text-center">{% trans "Structure" %}</th>
<th class="text-center">{% trans "Eve Time" %}</th>
<th class="text-center">{% trans "Local Time" %}</th>
<th class="text-center">{% trans "Creator" %}</th>
{% if perms.auth.timer_management %}
<th class="text-center">{% trans "Action" %}</th>
{% endif %}
</tr>
{% for timer in corp_timers %}
{% ifequal timer.important True %}
<tr class="danger">
{% else %}
<tr class="info">
{% endifequal %}
<td style="width:150px" class="text-center">{{ timer.details }}</td>
<td class="text-center">
{% ifequal timer.objective "Hostile" %}
<div class="label label-danger">
{% trans "Hostile" %}
</div>
{% endifequal %}
{% ifequal timer.objective "Friendly" %}
<div class="label label-primary">
{% trans "Friendly" %}
</div>
{% endifequal %}
{% ifequal timer.objective "Neutral" %}
<div class="label label-default">
{% trans "Neutral" %}
</div>
{% endifequal %}
</td>
<td class="text-center"><a
href="http://evemaps.dotlan.net/system/{{ timer.system }}">{{ timer.system }} {{ timer.planet_moon }} </a>
</td>
<td class="text-center">
{% ifequal timer.structure "I-HUB" %}
<div class="label label-warning">
I-HUB
</div>
{% endifequal %}
{% ifequal timer.structure "POCO" %}
<div class="label label-success">
POCO
</div>
{% endifequal %}
{% ifequal timer.structure "POS[S]" %}
<div class="label label-info">
POS [S]
</div>
{% endifequal %}
{% ifequal timer.structure "POS[M]" %}
<div class="label label-info">
POS [M]
</div>
{% endifequal %}
{% ifequal timer.structure "POS[L]" %}
<div class="label label-info">
POS [L]
</div>
{% endifequal %}
{% ifequal timer.structure "Citadel[M]" %}
<div class="label label-danger">
Citadel [M]
</div>
{% endifequal %}
{% ifequal timer.structure "Citadel[L]" %}
<div class="label label-danger">
Citadel [L]
</div>
{% endifequal %}
{% ifequal timer.structure "Citadel[XL]" %}
<div class="label label-danger">
Citadel [XL]
</div>
{% endifequal %}
{% ifequal timer.structure "Engineering Complex[M]" %}
<div class="label label-warning">
Engineering Complex [M]
</div>
{% endifequal %}
{% ifequal timer.structure "Engineering Complex[L]" %}
<div class="label label-warning">
Engineering Complex [L]
</div>
{% endifequal %}
{% ifequal timer.structure "Engineering Complex[XL]" %}
<div class="label label-warning">
Engineering Complex [XL]
</div>
{% endifequal %}
{% ifequal timer.structure "Station" %}
<div class="label label-danger">
Station
</div>
{% endifequal %}
{% ifequal timer.structure "TCU" %}
<div class="label label-danger">
TCU
</div>
{% endifequal %}
{% ifequal timer.structure "Other" %}
<div class="label label-default">
Other
</div>
{% endifequal %}
</td>
<td class="text-center" nowrap>{{ timer.eve_time | date:"Y-m-d H:i" }}</td>
<td class="text-center" nowrap>
<div id="localtime{{ timer.id }}"></div>
<div id="countdown{{ timer.id }}"></div>
</td>
<td class="text-center">{{ timer.eve_character.character_name }}</td>
{% if perms.auth.timer_management %}
<td class="text-center">
<a href="{% url 'auth_remove_timer' timer.id %}" class="btn btn-danger">
<span class="glyphicon glyphicon-remove"></span>
</a>
<a href="{% url 'auth_edit_timer' timer.id %}" class="btn btn-info">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</td>
{% endif %}
</tr>
{% endfor %}
</table>
{% endif %}
<h4><b>{% trans "Next Timers" %}</b></h4>
{% if future_timers %}
<table class="table">
<tr>
<th style="width:150px" class="text-center">{% trans "Details" %}</th>
<th class="text-center">{% trans "Objective" %}</th>
<th class="text-center">{% trans "System" %}</th>
<th class="text-center">{% trans "Structure" %}</th>
<th class="text-center">{% trans "Eve Time" %}</th>
<th class="text-center">{% trans "Local Time" %}</th>
<th class="text-center">{% trans "Creator" %}</th>
{% if perms.auth.timer_management %}
<th class="text-center">{% trans "Action" %}</th>
{% endif %}
</tr>
{% for timer in future_timers %}
{% ifequal timer.important True %}
<tr class="danger">
{% else %}
<tr class="info">
{% endifequal %}
<td style="width:150px" class="text-center">{{ timer.details }}</td>
<td class="text-center">
{% ifequal timer.objective "Hostile" %}
<div class="label label-danger">
{% trans "Hostile" %}
</div>
{% endifequal %}
{% ifequal timer.objective "Friendly" %}
<div class="label label-primary">
{% trans "Friendly" %}
</div>
{% endifequal %}
{% ifequal timer.objective "Neutral" %}
<div class="label label-default">
{% trans "Neutral" %}
</div>
{% endifequal %}
</td>
<td class="text-center">
<a href="http://evemaps.dotlan.net/system/{{ timer.system }}">{{ timer.system }} {{ timer.planet_moon }}</a>
</td>
<td class="text-center">
{% ifequal timer.structure "I-HUB" %}
<div class="label label-warning">
I-HUB
</div>
{% endifequal %}
{% ifequal timer.structure "POCO" %}
<div class="label label-success">
POCO
</div>
{% endifequal %}
{% ifequal timer.structure "POS[S]" %}
<div class="label label-info">
POS [S]
</div>
{% endifequal %}
{% ifequal timer.structure "POS[M]" %}
<div class="label label-info">
POS [M]
</div>
{% endifequal %}
{% ifequal timer.structure "POS[L]" %}
<div class="label label-info">
POS [L]
</div>
{% endifequal %}
{% ifequal timer.structure "Citadel[M]" %}
<div class="label label-danger">
Citadel [M]
</div>
{% endifequal %}
{% ifequal timer.structure "Citadel[L]" %}
<div class="label label-danger">
Citadel [L]
</div>
{% endifequal %}
{% ifequal timer.structure "Citadel[XL]" %}
<div class="label label-danger">
Citadel [XL]
</div>
{% endifequal %}
{% ifequal timer.structure "Engineering Complex[M]" %}
<div class="label label-warning">
Engineering Complex [M]
</div>
{% endifequal %}
{% ifequal timer.structure "Engineering Complex[L]" %}
<div class="label label-warning">
Engineering Complex [L]
</div>
{% endifequal %}
{% ifequal timer.structure "Engineering Complex[XL]" %}
<div class="label label-warning">
Engineering Complex [XL]
</div>
{% endifequal %}
{% ifequal timer.structure "Station" %}
<div class="label label-danger">
Station
</div>
{% endifequal %}
{% ifequal timer.structure "TCU" %}
<div class="label label-danger">
TCU
</div>
{% endifequal %}
{% ifequal timer.structure "Other" %}
<div class="label label-default">
Other
</div>
{% endifequal %}
</td>
<td class="text-center" nowrap>{{ timer.eve_time | date:"Y-m-d H:i" }}</td>
<td class="text-center" nowrap>
<div id="localtime{{ timer.id }}"></div>
<div id="countdown{{ timer.id }}"></div>
</td>
<td class="text-center">{{ timer.eve_character.character_name }}</td>
{% if perms.auth.timer_management %}
<td class="text-center">
<a href="{% url 'timerboard:remove' timer.id %}" class="btn btn-danger">
<span class="glyphicon glyphicon-remove"></span>
</a>
<a href="{% url 'timerboard:edit' timer.id %}" class="btn btn-info">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</td>
{% endif %}
</tr>
{% endfor %}
</table>
{% else %}
<div class="alert alert-warning text-center">{% trans "No upcoming timers." %}</div>
{% endif %}
<h4><b>{% trans "Past Timers" %}</b></h4>
{% if past_timers %}
<table class="table">
<tr>
<th style="width:150px" class="text-center">{% trans "Details" %}</th>
<th class="text-center">{% trans "Objective" %}</th>
<th class="text-center">{% trans "System" %}</th>
<th class="text-center">{% trans "Structure" %}</th>
<th class="text-center">{% trans "Eve Time" %}</th>
<th class="text-center">{% trans "Local Time" %}</th>
<th class="text-center">{% trans "Creator" %}</th>
{% if perms.auth.timer_management %}
<th class="text-center">{% trans "Action" %}</th>
{% endif %}
</tr>
{% for timer in past_timers %}
{% ifequal timer.important True %}
<tr class="danger">
{% else %}
<tr class="info">
{% endifequal %}
<td style="width:150px" class="text-center">{{ timer.details }}</td>
<td class="text-center">
{% ifequal timer.objective "Hostile" %}
<div class="label label-danger">
{% trans "Hostile" %}
</div>
{% endifequal %}
{% ifequal timer.objective "Friendly" %}
<div class="label label-primary">
{% trans "Friendly" %}
</div>
{% endifequal %}
{% ifequal timer.objective "Neutral" %}
<div class="label label-default">
{% trans "Neutral" %}
</div>
{% endifequal %}
</td>
<td class="text-center">
<a href="http://evemaps.dotlan.net/system/{{ timer.system }}">{{ timer.system }} {{ timer.planet_moon }}</a>
</td>
<td class="text-center">
{% ifequal timer.structure "I-HUB" %}
<div class="label label-warning">
I-HUB
</div>
{% endifequal %}
{% ifequal timer.structure "POCO" %}
<div class="label label-success">
POCO
</div>
{% endifequal %}
{% ifequal timer.structure "POS[S]" %}
<div class="label label-info">
POS [S]
</div>
{% endifequal %}
{% ifequal timer.structure "POS[M]" %}
<div class="label label-info">
POS [M]
</div>
{% endifequal %}
{% ifequal timer.structure "POS[L]" %}
<div class="label label-info">
POS [L]
</div>
{% endifequal %}
{% ifequal timer.structure "Citadel[M]" %}
<div class="label label-danger">
Citadel [M]
</div>
{% endifequal %}
{% ifequal timer.structure "Citadel[L]" %}
<div class="label label-danger">
Citadel [L]
</div>
{% endifequal %}
{% ifequal timer.structure "Citadel[XL]" %}
<div class="label label-danger">
Citadel [XL]
</div>
{% endifequal %}
{% ifequal timer.structure "Engineering Complex[M]" %}
<div class="label label-warning">
Engineering Complex [M]
</div>
{% endifequal %}
{% ifequal timer.structure "Engineering Complex[L]" %}
<div class="label label-warning">
Engineering Complex [L]
</div>
{% endifequal %}
{% ifequal timer.structure "Engineering Complex[XL]" %}
<div class="label label-warning">
Engineering Complex [XL]
</div>
{% endifequal %}
{% ifequal timer.structure "Station" %}
<div class="label label-danger">
Station
</div>
{% endifequal %}
{% ifequal timer.structure "TCU" %}
<div class="label label-danger">
TCU
</div>
{% endifequal %}
{% ifequal timer.structure "Other" %}
<div class="label label-default">
Other
</div>
{% endifequal %}
</td>
<td class="text-center" nowrap>{{ timer.eve_time | date:"Y-m-d H:i" }}</td>
<td class="text-center" nowrap>
<div id="localtime{{ timer.id }}"></div>
<div id="countdown{{ timer.id }}"></div>
</td>
<td class="text-center">{{ timer.eve_character.character_name }}</td>
{% if perms.auth.timer_management %}
<td class="text-center">
<a href="{% url 'auth_remove_timer' timer.id %}" class="btn btn-danger">
<span class="glyphicon glyphicon-remove"></span>
</a>
<a href="{% url 'auth_edit_timer' timer.id %}" class="btn btn-info">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</td>
{% endif %}
</tr>
{% endfor %}
</table>
{% else %}
<div class="alert alert-warning text-center">{% trans "No past timers." %}</div>
{% endif %}
</div>
{% include 'bundles/moment-js.html' with locale=True %}
<script src="{% static 'js/timers.js' %}"></script>
<script type="text/javascript">
var locale = "{{ LANGUAGE_CODE }}";
var timers = [
{% for timer in timers %}
{
'id': {{ timer.id }},
'targetDate': moment("{{ timer.eve_time | date:"c" }}"),
'expired': false
},
{% endfor %}
{% for timer in corp_timers %}
{
'id': {{ timer.id }},
'targetDate': moment("{{ timer.eve_time | date:"c" }}"),
'expired': false
},
{% endfor %}
];
moment.locale(locale);
// Set initial values
setAllLocalTimes();
timedUpdate();
// Start timed updates
setInterval(timedUpdate, 1000);
function timedUpdate() {
updateClock();
updateAllTimers();
}
function updateAllTimers () {
var l = timers.length;
for (var i=0; i < l; ++i) {
if (timers[i].expired) continue;
updateTimer(timers[i]);
}
}
/**
* Update a timer
* @param timer Timer information
* @param timer.targetDate Date of the timer
* @param timer.id Id number of the timer
* @param timer.expired
*/
function updateTimer(timer) {
if (timer.targetDate.isAfter(Date.now())) {
duration = moment.duration(timer.targetDate - moment(), 'milliseconds');
document.getElementById("countdown" + timer.id).innerHTML = getDurationString(duration);
} else {
timer.expired = true;
document.getElementById("countdown" + timer.id).innerHTML = "";
}
}
/**
* Set all local time fields
*/
function setAllLocalTimes() {
var l = timers.length;
for (var i=0; i < l; ++i) {
setLocalTime(timers[i]);
}
}
/**
* Set the local time info for the timer
* @param timer Timer information
* @param timer.targetDate Date of the timer
* @param timer.id Id number of the timer
*/
function setLocalTime(timer) {
document.getElementById("localtime" + timer.id).innerHTML = timer.targetDate.format("ddd @ LT");
}
function updateClock() {
document.getElementById("current-time").innerHTML = "<b>" + moment().format('LLLL') + "</b>";
}
</script>
{% endblock content %}

View File

@@ -0,0 +1,35 @@
{% extends "registered/base.html" %}
{% load bootstrap %}
{% load staticfiles %}
{% load i18n %}
{% block title %}Alliance Auth - Update Structure Timer {% endblock %}
{% block page_title %}{% trans "Update AAR Link" %}{% endblock page_title %}
{% block content %}
<div class="col-lg-12">
<h1 class="page-header text-center">{% trans "Update Structure Timer" %}</h1>
<div class="container-fluid">
<div class="col-md-4 col-md-offset-4">
<div class="row">
{% if no_fleet_id %}
<div class="alert alert-danger" role="alert">{% trans "Structure Timer Does Not Exist" %}</div>
{% else %}
<form class="form-signin" role="form" action="" method="POST">
{% csrf_token %}
{{ form|bootstrap }}
<br/>
<button class="btn btn-lg btn-primary btn-block" type="submit">{% trans "Update Structure Timer" %}
</button>
</form>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock content %}

11
timerboard/urls.py Normal file
View File

@@ -0,0 +1,11 @@
from django.conf.urls import url
import timerboard.views
app_name = 'timerboard'
urlpatterns = [
url(r'^$', timerboard.views.timer_view, name='view'),
url(r'^add/$', timerboard.views.add_timer_view, name='add'),
url(r'^remove/(\w+)$', timerboard.views.remove_timer, name='remove'),
url(r'^edit/(\w+)$', timerboard.views.edit_timer, name='edit'),
]

View File

@@ -30,7 +30,6 @@ def timer_view(request):
corp_timers = Timer.objects.all().filter(corp_timer=True).filter(eve_corp=corp)
else:
corp_timers = []
timer_list = Timer.objects.filter(corp_timer=False)
render_items = {'timers': Timer.objects.all().filter(corp_timer=False),
'corp_timers': corp_timers,
'future_timers': Timer.objects.all().filter(corp_timer=False).filter(
@@ -38,7 +37,7 @@ def timer_view(request):
'past_timers': Timer.objects.all().filter(corp_timer=False).filter(
eve_time__lt=datetime.datetime.now())}
return render(request, 'registered/timermanagement.html', context=render_items)
return render(request, 'timerboard/management.html', context=render_items)
@login_required
@@ -84,7 +83,7 @@ def add_timer_view(request):
render_items = {'form': form}
return render(request, 'registered/addtimer.html', context=render_items)
return render(request, 'timerboard/add.html', context=render_items)
@login_required
@@ -150,4 +149,4 @@ def edit_timer(request, timer_id):
'minutes_left': tdminutes,
}
form = TimerForm(initial=data)
return render(request, 'registered/timerupdate.html', context={'form': form})
return render(request, 'timerboard/update.html', context={'form': form})