Removed zadmin's ability to re-index (bug 859919)
This commit is contained in:
Родитель
13ffdeb5f2
Коммит
fa199caab4
|
@ -2,10 +2,6 @@
|
|||
|
||||
{% block title %}Elastic Search {{ super() }}{% endblock %}
|
||||
|
||||
{% block extrahead %}
|
||||
<style>form { margin-bottom: 1em }</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<ul>
|
||||
<li><a href="#mapping">Mappings</a></li>
|
||||
|
@ -14,21 +10,6 @@
|
|||
<li><a href="#nodes">Nodes</a></li>
|
||||
</ul>
|
||||
<h3 id="mapping">Mappings</h3>
|
||||
<form method="post" action="">
|
||||
{{ csrf() }}
|
||||
<button name="recreate" value="1">Recreate {{ index }} index</button>
|
||||
</form>
|
||||
<form method="post" action="">
|
||||
{{ csrf() }}
|
||||
<b>Choices:</b>
|
||||
<ul>
|
||||
{% for choice in choices|sort %}
|
||||
<li>{{ choice }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<input name="reindex" placeholder="mapping name">
|
||||
<button>Reindex</button>
|
||||
</form>
|
||||
{% for index, mapping in mappings %}
|
||||
<h4>{{ index }}</h4>
|
||||
<pre>{{ mapping|dictsort|pprint }}</pre>
|
||||
|
|
|
@ -162,8 +162,8 @@ class BulkValidationTest(amo.tests.TestCase):
|
|||
self.addon = Addon.objects.get(pk=3615)
|
||||
self.creator = UserProfile.objects.get(username='editor')
|
||||
self.version = self.addon.get_version()
|
||||
ApplicationsVersions.objects.filter(application=1,
|
||||
version=self.version).update(
|
||||
ApplicationsVersions.objects.filter(
|
||||
application=1, version=self.version).update(
|
||||
max=AppVersion.objects.get(application=1, version='3.7a1pre'))
|
||||
self.application_version = self.version.apps.all()[0]
|
||||
self.application = self.application_version.application
|
||||
|
@ -1862,22 +1862,6 @@ class TestElastic(amo.tests.ESTestCase):
|
|||
self.assertRedirects(self.client.get(self.url),
|
||||
reverse('users.login') + '?to=/en-US/admin/elastic')
|
||||
|
||||
@mock.patch('zadmin.views.elasticutils')
|
||||
@mock.patch('zadmin.views.create_es_index_if_missing')
|
||||
@mock.patch('zadmin.views.setup_mapping')
|
||||
def test_recreate_index(self, setup_mapping, _create, es):
|
||||
self.client.post(self.url, {'recreate': 1})
|
||||
index = settings.ES_INDEXES['default']
|
||||
index in es.get_es().delete_index_if_exists.call_args_list[0][0]
|
||||
assert setup_mapping.called
|
||||
index in _create.call_args_list[0][0]
|
||||
|
||||
def test_reindex_addons(self):
|
||||
eq_(list(Addon.search()), [])
|
||||
self.client.post(self.url, {'reindex': 'addons'})
|
||||
self.refresh()
|
||||
eq_(list(Addon.search()), list(Addon.objects.all()))
|
||||
|
||||
|
||||
class TestEmailDevs(amo.tests.TestCase):
|
||||
fixtures = ['base/addon_3615', 'base/users']
|
||||
|
@ -1993,7 +1977,7 @@ class TestEmailDevs(amo.tests.TestCase):
|
|||
self.addon.update(type=amo.ADDON_EXTENSION)
|
||||
res = self.post(recipients='all_extensions')
|
||||
self.assertNoFormErrors(res)
|
||||
eq_(len(mail.outbox), 1)
|
||||
eq_(len(mail.outbox), 1)
|
||||
|
||||
def test_ignore_deleted_always(self):
|
||||
self.addon.update(status=amo.STATUS_DELETED)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import csv
|
||||
from decimal import Decimal
|
||||
import json
|
||||
import re
|
||||
from decimal import Decimal
|
||||
from urlparse import urlparse
|
||||
|
||||
from django import http
|
||||
|
@ -26,7 +25,6 @@ from tower import ugettext as _
|
|||
|
||||
import amo
|
||||
from addons.cron import reindex_addons, reindex_apps
|
||||
from addons.search import setup_mapping
|
||||
from addons.decorators import addon_view
|
||||
from addons.models import Addon, AddonUser, CompatOverride
|
||||
from amo import messages, get_user
|
||||
|
@ -34,7 +32,7 @@ from amo.decorators import (any_permission_required, json_view, login_required,
|
|||
post_required)
|
||||
from amo.mail import FakeEmailBackend
|
||||
from amo.urlresolvers import reverse
|
||||
from amo.utils import chunked, create_es_index_if_missing, sorted_groupby
|
||||
from amo.utils import chunked, sorted_groupby
|
||||
from bandwagon.cron import reindex_collections
|
||||
from bandwagon.models import Collection
|
||||
from compat.cron import compatibility_report
|
||||
|
@ -45,7 +43,6 @@ from files.tasks import start_upgrade as start_upgrade_task
|
|||
from files.utils import find_jetpacks, JetpackUpgrader
|
||||
from market.utils import update_from_csv
|
||||
from stats.cron import index_latest_stats
|
||||
from stats.search import setup_indexes
|
||||
from users.cron import reindex_users
|
||||
from users.models import UserProfile
|
||||
from versions.compare import version_int as vint
|
||||
|
@ -125,7 +122,7 @@ def langpacks(request):
|
|||
if request.method == 'POST':
|
||||
try:
|
||||
tasks.fetch_langpacks.delay(request.POST['path'])
|
||||
except ValueError, e:
|
||||
except ValueError:
|
||||
messages.error(request, "Invalid language pack sub-path provided.")
|
||||
|
||||
return redirect('zadmin.langpacks')
|
||||
|
@ -599,23 +596,6 @@ def elastic(request):
|
|||
'stats_latest': index_latest_stats,
|
||||
'mkt_stats': index_mkt_stats,
|
||||
'mkt_stats_latest': index_latest_mkt_stats}
|
||||
if request.method == 'POST':
|
||||
if request.POST.get('recreate'):
|
||||
es.delete_index_if_exists(INDEX)
|
||||
# We must set up the mappings before we create the index again.
|
||||
setup_mapping()
|
||||
setup_indexes()
|
||||
if setup_mkt_indexes:
|
||||
setup_mkt_indexes()
|
||||
create_es_index_if_missing(INDEX)
|
||||
messages.info(request, 'Deleting %s index.' % INDEX)
|
||||
if request.POST.get('reindex') in mappings:
|
||||
name = request.POST['reindex']
|
||||
# Reindex.
|
||||
if mappings.get(name):
|
||||
mappings[name]()
|
||||
messages.info(request, 'Reindexing %s.' % name)
|
||||
return redirect('zadmin.elastic')
|
||||
|
||||
indexes = set(settings.ES_INDEXES.values())
|
||||
es_mappings = es.get_mapping(None, indexes)
|
||||
|
@ -761,7 +741,7 @@ def general_search(request, app_id, model_id):
|
|||
# Override search_fields_response on the ModelAdmin object
|
||||
# if you'd like to pass something else back to the front end.
|
||||
lookup = getattr(obj, 'search_fields_response', None)
|
||||
return [{'value':o.pk, 'label':getattr(o, lookup) if lookup else str(o)}
|
||||
return [{'value': o.pk, 'label': getattr(o, lookup) if lookup else str(o)}
|
||||
for o in qs[:limit]]
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче