mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-05 06:36:19 +01:00
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:
26
optimer/auth_hooks.py
Normal file
26
optimer/auth_hooks.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from services.hooks import MenuItemHook, UrlHook
|
||||
from alliance_auth import hooks
|
||||
from optimer import urls
|
||||
|
||||
|
||||
class OpTimerboardMenu(MenuItemHook):
|
||||
def __init__(self):
|
||||
MenuItemHook.__init__(self, 'Fleet Operations',
|
||||
'fa fa-exclamation fa-fw grayiconecolor',
|
||||
'optimer:view',
|
||||
navactive=['optimer:'])
|
||||
|
||||
def render(self, request):
|
||||
if request.user.has_perm('auth.optimer_view'):
|
||||
return MenuItemHook.render(self, request)
|
||||
return ''
|
||||
|
||||
|
||||
@hooks.register('menu_item_hook')
|
||||
def register_menu():
|
||||
return OpTimerboardMenu()
|
||||
|
||||
|
||||
@hooks.register('url_hook')
|
||||
def register_url():
|
||||
return UrlHook(urls, 'optimer', r'^optimer/')
|
||||
46
optimer/templates/optimer/add.html
Normal file
46
optimer/templates/optimer/add.html
Normal file
@@ -0,0 +1,46 @@
|
||||
{% extends "registered/base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load staticfiles %}
|
||||
{% load i18n %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
|
||||
{% block title %}{% trans "Alliance Auth - Fleet Operation Create" %}{% endblock %}
|
||||
|
||||
{% block page_title %}{% trans "Create Operation" %}{% endblock page_title %}
|
||||
{% block extra_css %}
|
||||
{% include 'bundles/jquery-datetimepicker-css.html' %}
|
||||
{% endblock extra_css %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header text-center">{% trans "Create Fleet Operation" %}</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 Fleet Operation" %}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock content %}
|
||||
|
||||
{% block extra_javascript %}
|
||||
{% include 'bundles/jquery-datetimepicker-js.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
|
||||
$('#id_start').datetimepicker({
|
||||
lang: '{{ LANGUAGE_CODE }}',
|
||||
maskInput: true,
|
||||
format: 'Y-m-d H:i',minDate:0
|
||||
});
|
||||
|
||||
{% endblock extra_script %}
|
||||
44
optimer/templates/optimer/fleetoptable.html
Normal file
44
optimer/templates/optimer/fleetoptable.html
Normal file
@@ -0,0 +1,44 @@
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center col-lg-3">{% trans "Operation Name" %}</th>
|
||||
<th class="text-center col lg-2">{% trans "Doctrine" %}</th>
|
||||
<th class="text-center col-lg-1">{% trans "Form Up System" %}</th>
|
||||
<th class="text-center col-lg-1">{% trans "Start Time" %}</th>
|
||||
<th class="text-center col-lg-1">{% trans "Local Time" %}</th>
|
||||
<th class="text-center col-lg-1">{% trans "Duration" %}</th>
|
||||
<th class="text-center col-lg-1">{% trans "FC" %}</th>
|
||||
{% if perms.auth.optimer_management %}
|
||||
<th class="text-center col-lg-1">{% trans "Creator" %}</th>
|
||||
<th class="text-center col-lg-2">{% trans "Action" %}</th>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</thead>
|
||||
{% for ops in timers %}
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="text-center">{{ ops.operation_name }}</td>
|
||||
<td class="text-center">{{ ops.doctrine }}</td>
|
||||
<td class="text-center">
|
||||
<a href="http://evemaps.dotlan.net/system/{{ ops.system }}">{{ ops.system }}</a>
|
||||
</td>
|
||||
<td class="text-center" nowrap>{{ ops.start | date:"Y-m-d H:i" }}</td>
|
||||
<td class="text-center" nowrap><div id="localtime{{ ops.id }}"></div><div id="countdown{{ ops.id }}"></div></td>
|
||||
<td class="text-center">{{ ops.duration }}</td>
|
||||
<td class="text-center">{{ ops.fc }}</td>
|
||||
{% if perms.auth.optimer_management %}
|
||||
<td class="text-center">{{ ops.eve_character }}</td>
|
||||
<td class="text-center">
|
||||
<a href="{% url 'optimer:remove' ops.id %}" class="btn btn-danger">
|
||||
<span class="glyphicon glyphicon-remove"></span>
|
||||
</a><a href="{% url 'optimer:edit' ops.id %}" class="btn btn-info"><span class="glyphicon glyphicon-pencil"></span></a>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</tbody>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endblock content %}
|
||||
119
optimer/templates/optimer/management.html
Normal file
119
optimer/templates/optimer/management.html
Normal file
@@ -0,0 +1,119 @@
|
||||
{% extends "registered/base.html" %}
|
||||
{% load staticfiles %}
|
||||
{% load i18n %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
|
||||
{% block title %}Alliance Auth{% endblock %}
|
||||
|
||||
{% block page_title %}{% trans "Fleet Operation Management" %}{% endblock page_title %}
|
||||
{% block extra_css %}{% endblock extra_css %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header text-center">{% trans "Fleet Operation Timers" %}
|
||||
<div class="text-right">
|
||||
{% if perms.auth.optimer_management %}
|
||||
<a href="{% url 'optimer:add' %}" class="btn btn-success">{% trans "Create Operation" %}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</h1>
|
||||
|
||||
<div class="col-lg-12 text-center row">
|
||||
<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>
|
||||
<br />
|
||||
</div>
|
||||
|
||||
<h4><b>{% trans "Next Timers" %}</b></h4>
|
||||
{% if future_timers %}
|
||||
{% include "optimer/fleetoptable.html" with timers=future_timers %}
|
||||
{% else %}
|
||||
<div class="alert alert-warning text-center">{% trans "No upcoming timers." %}</div>
|
||||
{% endif %}
|
||||
|
||||
<h4><b>{% trans "Past Timers" %}</b></h4>
|
||||
{% if past_timers %}
|
||||
{% include "optimer/fleetoptable.html" with timers=past_timers %}
|
||||
{% 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">
|
||||
// Data
|
||||
var timers = [
|
||||
{% for op in optimer %}
|
||||
{
|
||||
'id': {{ op.id }},
|
||||
'start': moment("{{ op.start | date:"c" }}"),
|
||||
'expired': false
|
||||
},
|
||||
{% endfor %}
|
||||
];
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
|
||||
timedUpdate();
|
||||
setAllLocalTimes();
|
||||
|
||||
// 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.start Date of the timer
|
||||
* @param timer.id Id number of the timer
|
||||
* @param timer.expired
|
||||
*/
|
||||
function updateTimer(timer) {
|
||||
if (timer.start.isAfter(Date.now())) {
|
||||
var duration = moment.duration(timer.start - 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.start Date of the timer
|
||||
* @param timer.id Id number of the timer
|
||||
*/
|
||||
function setLocalTime(timer) {
|
||||
document.getElementById("localtime" + timer.id).innerHTML = timer.start.format("ddd @ LT");
|
||||
}
|
||||
|
||||
function updateClock() {
|
||||
document.getElementById("current-time").innerHTML = "<b>" + moment.utc().format('LLLL') + "</b>";
|
||||
}
|
||||
</script>
|
||||
{% endblock content %}
|
||||
54
optimer/templates/optimer/update.html
Normal file
54
optimer/templates/optimer/update.html
Normal file
@@ -0,0 +1,54 @@
|
||||
{% extends "registered/base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load staticfiles %}
|
||||
{% load i18n %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
|
||||
{% block title %}Alliance Auth - Update Fleet Operation {% endblock %}
|
||||
|
||||
{% block page_title %}{% trans "Update AAR Link" %}{% endblock page_title %}
|
||||
|
||||
{% block extra_css %}
|
||||
{% include 'bundles/jquery-datetimepicker-css.html' %}
|
||||
{% endblock extra_css %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header text-center">{% trans "Update Fleet Operation" %}</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 "Fleet Operation 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 Fleet Operation" %}
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock content %}
|
||||
|
||||
{% block extra_javascript %}
|
||||
{% include 'bundles/jquery-datetimepicker-js.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
|
||||
$('#id_start').datetimepicker({
|
||||
lang: '{{ LANGUAGE_CODE }}',
|
||||
maskInput: true,
|
||||
format: 'Y-m-d H:i',minDate:0
|
||||
});
|
||||
|
||||
{% endblock extra_script %}
|
||||
11
optimer/urls.py
Normal file
11
optimer/urls.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from django.conf.urls import url
|
||||
import optimer.views
|
||||
|
||||
app_name = 'optimer'
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', optimer.views.optimer_view, name='view'),
|
||||
url(r'^add$', optimer.views.add_optimer_view, name='add'),
|
||||
url(r'^(\w+)/remove$', optimer.views.remove_optimer, name='remove'),
|
||||
url(r'^(\w+)/edit$', optimer.views.edit_optimer, name='edit'),
|
||||
]
|
||||
@@ -24,7 +24,7 @@ def optimer_view(request):
|
||||
'past_timers': OpTimer.objects.all().filter(
|
||||
start__lt=timezone.now()).order_by('-start')}
|
||||
|
||||
return render(request, 'registered/operationmanagement.html', context=render_items)
|
||||
return render(request, 'optimer/management.html', context=render_items)
|
||||
|
||||
|
||||
@login_required
|
||||
@@ -52,14 +52,14 @@ def add_optimer_view(request):
|
||||
op.save()
|
||||
logger.info("User %s created op timer with name %s" % (request.user, op.operation_name))
|
||||
messages.success(request, _('Created operation timer for %(opname)s.') % {"opname": op.operation_name})
|
||||
return redirect("/optimer/")
|
||||
return redirect("optimer:view")
|
||||
else:
|
||||
logger.debug("Returning new opForm")
|
||||
form = OpForm()
|
||||
|
||||
render_items = {'form': form}
|
||||
|
||||
return render(request, 'registered/addoperation.html', context=render_items)
|
||||
return render(request, 'optimer/add.html', context=render_items)
|
||||
|
||||
|
||||
@login_required
|
||||
@@ -70,7 +70,7 @@ def remove_optimer(request, optimer_id):
|
||||
op.delete()
|
||||
logger.info("Deleting optimer id %s by user %s" % (optimer_id, request.user))
|
||||
messages.success(request, _('Removed operation timer for %(opname)s.') % {"opname": op.operation_name})
|
||||
return redirect("auth_optimer_view")
|
||||
return redirect("optimer:view")
|
||||
|
||||
|
||||
@login_required
|
||||
@@ -93,7 +93,7 @@ def edit_optimer(request, optimer_id):
|
||||
logger.info("User %s updating optimer id %s " % (request.user, optimer_id))
|
||||
op.save()
|
||||
messages.success(request, _('Saved changes to operation timer for %(opname)s.') % {"opname": op.operation_name})
|
||||
return redirect("auth_optimer_view")
|
||||
return redirect("optimer:view")
|
||||
else:
|
||||
data = {
|
||||
'doctrine': op.doctrine,
|
||||
@@ -104,4 +104,4 @@ def edit_optimer(request, optimer_id):
|
||||
'fc': op.fc,
|
||||
}
|
||||
form = OpForm(initial=data)
|
||||
return render(request, 'registered/optimerupdate.html', context={'form': form})
|
||||
return render(request, 'optimer/update.html', context={'form': form})
|
||||
|
||||
Reference in New Issue
Block a user