Skip to content

Commit e5a1265

Browse files
committed
Merge branch 'master' into #6_support_django_2
2 parents 6ab98c3 + a247cf4 commit e5a1265

File tree

9 files changed

+42
-142
lines changed

9 files changed

+42
-142
lines changed

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Changelog
22
---------
33

4+
0.8.0 (2018-11-13)
5+
^^^^^^^^^^^^^^^^^^^^^^
6+
* fix `#6 support Django 2 <https://github.com/HBS-HBX/django-elastic-migrations/issues/6>`_
7+
* fix `#43 remove es_deactivate <https://github.com/HBS-HBX/django-elastic-migrations/issues/43>`_
8+
* fix `#44 add django 1.10 and 1.11 to test matrix <https://github.com/HBS-HBX/django-elastic-migrations/issues/44>`_
9+
* fix `#45 remove support for python 2 <https://github.com/HBS-HBX/django-elastic-migrations/issues/45>`_
10+
* In practice, Python 2 may work, but it is removed from the test matrix and won't be updated
11+
412
0.7.8 (2018-11-13)
513
^^^^^^^^^^^^^^^^^^^^^^
614
* fix `#7 Convert Readme to rst for pypi <https://github.com/HBS-HBX/django-elastic-migrations/issues/7>`_

README.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Django Elastic Migrations
33
=========================
44

5-
Django Elastic Migrations is a Django app for creating, indexing and changing schemas of Elasticsearch indexes.
5+
`django-elastic-migrations`_ is a Django app for creating, indexing and changing schemas of Elasticsearch indexes.
66

77

88
.. image:: https://travis-ci.com/HBS-HBX/django-elastic-migrations.svg?branch=master
@@ -14,6 +14,7 @@ Django Elastic Migrations is a Django app for creating, indexing and changing sc
1414
:target: https://codecov.io/gh/HBS-HBX/django-elastic-migrations
1515
:alt: codecov
1616

17+
.. _django-elastic-migrations: https://pypi.org/project/django-elastic-migrations/
1718

1819
Overview
1920
--------
@@ -100,7 +101,7 @@ Usage
100101
Installation
101102
~~~~~~~~~~~~
102103

103-
#. ``pip install django-elastic-migrations``
104+
#. ``pip install django-elastic-migrations``; see `django-elastic-migrations`_ on PyPI
104105
#. Put a reference to this package in your ``requirements.txt``
105106
#. Ensure that a valid ``elasticsearch-dsl-py`` version is accessible, and configure
106107
the path to your configured Elasticsearch singleton client in your django settings:

django_elastic_migrations/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from django_elastic_migrations.utils import loading
99
from django_elastic_migrations.utils.django_elastic_migrations_log import get_logger
1010

11-
__version__ = '0.7.8'
11+
__version__ = '0.8.0'
1212

1313
default_app_config = 'django_elastic_migrations.apps.DjangoElasticMigrationsConfig' # pylint: disable=invalid-name
1414

django_elastic_migrations/indexes.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -342,16 +342,6 @@ def activate_index(cls, index_name, exact_mode=False):
342342
action = ActivateIndexAction()
343343
return cls._start_action_for_indexes(action, index_name, exact_mode)
344344

345-
@classmethod
346-
def deactivate_index(cls, index_name, exact_mode=False):
347-
"""
348-
Given the named index, activate the latest version of the index
349-
"""
350-
# avoid circular import
351-
from django_elastic_migrations.models import DeactivateIndexAction
352-
action = DeactivateIndexAction()
353-
return cls._start_action_for_indexes(action, index_name, exact_mode)
354-
355345
@classmethod
356346
def clear_index(cls, index_name, exact_mode=False, older_mode=False):
357347
"""

django_elastic_migrations/management/commands/es.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
'create': 'Create indexes; calls es_create',
1010
'activate': 'Activate indexes; calls es_activate',
1111
'update': 'Update indexes; calls es_update',
12-
'deactivate': 'Deactivate indexes; calls es_drop',
1312
'clear': 'Clears indexes; calls es_clear',
1413
'drop': 'Drop indexes; calls es_drop',
1514
'dangerous_reset': 'Dangerously drops all indexes and recreates all indexes (!)'
Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +0,0 @@
1-
from django_elastic_migrations import DEMIndexManager
2-
from django_elastic_migrations.management.commands.es import ESCommand
3-
4-
5-
class Command(ESCommand):
6-
help = "django-elastic-migrations: deactivate an index"
7-
8-
def add_arguments(self, parser):
9-
self.get_index_specifying_arguments(parser)
10-
11-
def handle(self, *args, **options):
12-
indexes, exact_mode, apply_all, _, _ = self.get_index_specifying_options(options)
13-
14-
if apply_all:
15-
DEMIndexManager.deactivate_index(
16-
'all',
17-
exact_mode=exact_mode,
18-
)
19-
elif indexes:
20-
for index_name in indexes:
21-
DEMIndexManager.deactivate_index(
22-
index_name,
23-
exact_mode=exact_mode,
24-
)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11 on 2018-11-12 09:37
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('django_elastic_migrations', '0006_auto_20180709_2101'),
12+
]
13+
14+
operations = [
15+
migrations.DeleteModel(
16+
name='DeactivateIndexAction',
17+
),
18+
migrations.AlterField(
19+
model_name='indexaction',
20+
name='action',
21+
field=models.CharField(choices=[('create_index', 'create_index'), ('update_index', 'update_index'), ('activate_index', 'activate_index'), ('clear_index', 'clear_index'), ('drop_index', 'drop_index'), ('partial_update_index', 'partial_update_index')], max_length=64),
22+
),
23+
]

django_elastic_migrations/models.py

Lines changed: 6 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,6 @@ def get_new_version(self, dem_index=None):
6363
version.save()
6464
return version
6565

66-
def deactivate(self):
67-
"""
68-
Remove any active version from this index
69-
"""
70-
if self.active_version:
71-
self.active_version = None
72-
self.save()
73-
7466
def get_available_versions(self):
7567
return self.indexversion_set.filter(deleted_time__isnull=True)
7668

@@ -216,13 +208,12 @@ class IndexAction(models.Model):
216208
ACTION_CREATE_INDEX = 'create_index'
217209
ACTION_UPDATE_INDEX = 'update_index'
218210
ACTION_ACTIVATE_INDEX = 'activate_index'
219-
ACTION_DEACTIVATE_INDEX = 'deactivate_index'
220211
ACTION_CLEAR_INDEX = 'clear_index'
221212
ACTION_DROP_INDEX = 'drop_index'
222213
ACTION_PARTIAL_UPDATE_INDEX = 'partial_update_index'
223214
ACTIONS_ALL = [
224215
ACTION_CREATE_INDEX, ACTION_UPDATE_INDEX, ACTION_ACTIVATE_INDEX,
225-
ACTION_DEACTIVATE_INDEX, ACTION_CLEAR_INDEX, ACTION_DROP_INDEX, ACTION_PARTIAL_UPDATE_INDEX
216+
ACTION_CLEAR_INDEX, ACTION_DROP_INDEX, ACTION_PARTIAL_UPDATE_INDEX
226217
]
227218
ACTIONS_ALL_CHOICES = [(i, i) for i in ACTIONS_ALL]
228219

@@ -497,7 +488,6 @@ class ActivateIndexAction(IndexAction):
497488
DEFAULT_ACTION = IndexAction.ACTION_ACTIVATE_INDEX
498489

499490
def __init__(self, *args, **kwargs):
500-
self.deactivate = kwargs.pop('deactivate', False)
501491
super(ActivateIndexAction, self).__init__(*args, **kwargs)
502492

503493
class Meta:
@@ -513,16 +503,10 @@ def perform_action(self, dem_index, *args, **kwargs):
513503
self.index_version = version_model
514504
index = self.index
515505

516-
if self.deactivate and index.active_version == version_model:
517-
index.active_version = None
518-
self.add_log(
519-
"Deactivating index version '{index_version_name}' "
520-
"because you said to do so.".format(**msg_params))
521-
else:
522-
index.active_version = version_model
523-
self.add_log(
524-
"Activating index version '{index_version_name}' "
525-
"because you said to do so.".format(**msg_params))
506+
index.active_version = version_model
507+
self.add_log(
508+
"Activating index version '{index_version_name}' "
509+
"because you said to do so.".format(**msg_params))
526510
index.save()
527511
# by reinitializing, we ensure this worker knows about the update immediately
528512
DEMIndexManager.initialize()
@@ -543,22 +527,7 @@ def perform_action(self, dem_index, *args, **kwargs):
543527
active_version = self.index.active_version
544528
msg_params.update({"index_version_name": latest_version.name})
545529

546-
if self.deactivate:
547-
if self.index.active_version:
548-
self.index.active_version = None
549-
self.add_log(
550-
"For index '{index_name}', DEactivating "
551-
"'{index_version_name}' "
552-
"because you said so.".format(
553-
**msg_params))
554-
self.index.save()
555-
else:
556-
self.add_log(
557-
"For index '{index_name}', there is no active version; "
558-
"so there is no version to deactivate. \n"
559-
"No action performed.".format(**msg_params)
560-
)
561-
elif active_version != latest_version:
530+
if active_version != latest_version:
562531
self.index.active_version = latest_version
563532
self.index.save()
564533
# by reinitializing, we ensure this worker knows about the update immediately
@@ -712,70 +681,6 @@ def perform_action(self, dem_index, *args, **kwargs):
712681
)
713682

714683

715-
class DeactivateIndexAction(IndexAction):
716-
DEFAULT_ACTION = IndexAction.ACTION_DEACTIVATE_INDEX
717-
718-
class Meta:
719-
# https://docs.djangoproject.com/en/2.0/topics/db/models/#proxy-models
720-
proxy = True
721-
722-
def perform_action(self, dem_index, *args, **kwargs):
723-
msg_params = {"index_name": self.index.name}
724-
if dem_index.get_version_id():
725-
# we have instantiated this DEMIndex with a specific IndexVersion
726-
version_model = dem_index.get_version_model()
727-
msg_params.update({"index_version_name": version_model.name})
728-
self.index_version = version_model
729-
index = self.index
730-
731-
index.active_version = None
732-
if index.active_version == version_model:
733-
self.add_log(
734-
"Deactivating formerly active index version "
735-
"'{index_version_name}' "
736-
"because you said to do so.".format(**msg_params))
737-
index.save()
738-
# re-initialize so as to ensure this worker gets the message
739-
DEMIndexManager.initialize()
740-
else:
741-
self.add_log(
742-
"There is no need to deactivate '{index_version_name}' "
743-
"because is it not active.".format(**msg_params))
744-
745-
else:
746-
# use the active version of the index if one exists.
747-
748-
# first, check if *any* version exists.
749-
latest_version = self.index.get_latest_version()
750-
if not latest_version:
751-
raise NoCreatedIndexVersion(
752-
"You must have created a version of the "
753-
"'{index_name}' index to call es_deactivate "
754-
"index.".format(**msg_params)
755-
)
756-
757-
# at least one version is available.
758-
759-
msg_params.update({"index_version_name": latest_version.name})
760-
761-
if self.index.active_version:
762-
self.index.active_version = None
763-
self.add_log(
764-
"For index '{index_name}', DEactivating "
765-
"'{index_version_name}' "
766-
"because you said so.".format(
767-
**msg_params))
768-
self.index.save()
769-
# re-initialize so as to ensure this worker gets the message
770-
DEMIndexManager.initialize()
771-
else:
772-
self.add_log(
773-
"For index '{index_name}', there is no active version; "
774-
"so there is no version to deactivate. \n"
775-
"No action performed.".format(**msg_params)
776-
)
777-
778-
779684
class DropIndexAction(OlderModeMixin, IndexAction):
780685
DEFAULT_ACTION = IndexAction.ACTION_DROP_INDEX
781686

setup.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def get_version(*file_paths):
5656
zip_safe=False,
5757
keywords='Django Elasticsearch',
5858
classifiers=[
59-
'Development Status :: 3 - Alpha',
59+
'Development Status :: 4 - Beta',
6060
'Framework :: Django',
6161
'Framework :: Django :: 1.9',
6262
'Framework :: Django :: 1.10',
@@ -65,8 +65,6 @@ def get_version(*file_paths):
6565
'Intended Audience :: Developers',
6666
'License :: OSI Approved :: MIT License',
6767
'Natural Language :: English',
68-
'Programming Language :: Python :: 2',
69-
'Programming Language :: Python :: 2.7',
7068
'Programming Language :: Python :: 3',
7169
'Programming Language :: Python :: 3.6',
7270
],

0 commit comments

Comments
 (0)