зеркало из https://github.com/mozilla/FlightDeck.git
adding a /services/admin page
This page requires superuser access, and only provides buttons which trigger hardcoded tasks to be run, such as indexing all the Packages again.
This commit is contained in:
Родитель
84e1acf05d
Коммит
e8ad84276f
|
@ -0,0 +1,30 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}Mozilla FlightDeck Admin Area{% endblock title %}
|
||||
|
||||
{% block head_prejs %}
|
||||
<style type="text/css">
|
||||
.UI_Forms .UI_Form_Actions li {
|
||||
float:none;
|
||||
display:inline-block;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block app_content %}
|
||||
<form method="post" action="" class="UI_Forms">
|
||||
<h2 class="UI_Heading" style="padding-top:3em;">Search</h2>
|
||||
{% if message %}
|
||||
<p><strong>{{message}}</strong></p>
|
||||
{% endif %}
|
||||
{% csrf_token %}
|
||||
<ul class="UI_Form_Actions">
|
||||
<li>
|
||||
<button name="action" value="setup_mapping" type="submit">Setup Mapping</button>
|
||||
</li>
|
||||
<li>
|
||||
<button name="action" value="index_all" type="submit">Index All</button>
|
||||
</li>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
|
@ -6,4 +6,5 @@ urlpatterns = patterns('',
|
|||
name='graphite'),
|
||||
url('^services/monitor$', 'base.views.monitor', name='monitor'),
|
||||
url('^services/settings$', 'base.views.site_settings', name='settings'),
|
||||
url('^services/admin$', 'base.views.admin', name='admin_triggers'),
|
||||
)
|
||||
|
|
|
@ -10,10 +10,11 @@ from django.shortcuts import render_to_response
|
|||
from django.template import RequestContext, loader
|
||||
from django.views.debug import get_safe_settings
|
||||
|
||||
from jetpack.models import Package, SDK
|
||||
import base.tasks
|
||||
from base.models import CeleryResponse
|
||||
from elasticutils import get_es
|
||||
import base.tasks
|
||||
from search.cron import index_all, setup_mapping
|
||||
from jetpack.models import Package, SDK
|
||||
from base.models import CeleryResponse
|
||||
|
||||
log = commonware.log.getLogger('f.monitor')
|
||||
|
||||
|
@ -44,6 +45,25 @@ def site_settings(request):
|
|||
{'settings': safe},
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
@user_passes_test(lambda u: u.is_superuser)
|
||||
def admin(request):
|
||||
msg = ''
|
||||
if request.method == 'POST':
|
||||
action = request.POST.get('action')
|
||||
log_msg = '[admin] %s by %s (id: %d)'
|
||||
if action == 'setup_mapping':
|
||||
msg = 'setup_mapping triggered'
|
||||
log.info(log_msg % (msg, request.user, request.user.pk))
|
||||
setup_mapping()
|
||||
elif action == 'index_all':
|
||||
msg = 'index_all triggered'
|
||||
log.info(log_msg % (msg , request.user, request.user.pk))
|
||||
index_all()
|
||||
|
||||
return render_to_response('admin.html', {
|
||||
'message': msg
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def monitor(request):
|
||||
status = True
|
||||
|
|
|
@ -111,7 +111,8 @@ authors:
|
|||
-moz-border-radius: 6px;
|
||||
}
|
||||
|
||||
.UI_Forms .UI_Form_Actions li input {
|
||||
.UI_Forms .UI_Form_Actions li input,
|
||||
.UI_Forms .UI_Form_Actions li button {
|
||||
background: -moz-linear-gradient(270deg, #C5F3AE, #96CE79);
|
||||
border-top: solid 1px #fff;
|
||||
display: block;
|
||||
|
|
Загрузка…
Ссылка в новой задаче