@@ -63,14 +63,6 @@ def get_new_version(self, dem_index=None):
63
63
version .save ()
64
64
return version
65
65
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
-
74
66
def get_available_versions (self ):
75
67
return self .indexversion_set .filter (deleted_time__isnull = True )
76
68
@@ -216,13 +208,12 @@ class IndexAction(models.Model):
216
208
ACTION_CREATE_INDEX = 'create_index'
217
209
ACTION_UPDATE_INDEX = 'update_index'
218
210
ACTION_ACTIVATE_INDEX = 'activate_index'
219
- ACTION_DEACTIVATE_INDEX = 'deactivate_index'
220
211
ACTION_CLEAR_INDEX = 'clear_index'
221
212
ACTION_DROP_INDEX = 'drop_index'
222
213
ACTION_PARTIAL_UPDATE_INDEX = 'partial_update_index'
223
214
ACTIONS_ALL = [
224
215
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
226
217
]
227
218
ACTIONS_ALL_CHOICES = [(i , i ) for i in ACTIONS_ALL ]
228
219
@@ -497,7 +488,6 @@ class ActivateIndexAction(IndexAction):
497
488
DEFAULT_ACTION = IndexAction .ACTION_ACTIVATE_INDEX
498
489
499
490
def __init__ (self , * args , ** kwargs ):
500
- self .deactivate = kwargs .pop ('deactivate' , False )
501
491
super (ActivateIndexAction , self ).__init__ (* args , ** kwargs )
502
492
503
493
class Meta :
@@ -513,16 +503,10 @@ def perform_action(self, dem_index, *args, **kwargs):
513
503
self .index_version = version_model
514
504
index = self .index
515
505
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 ))
526
510
index .save ()
527
511
# by reinitializing, we ensure this worker knows about the update immediately
528
512
DEMIndexManager .initialize ()
@@ -543,22 +527,7 @@ def perform_action(self, dem_index, *args, **kwargs):
543
527
active_version = self .index .active_version
544
528
msg_params .update ({"index_version_name" : latest_version .name })
545
529
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 :
562
531
self .index .active_version = latest_version
563
532
self .index .save ()
564
533
# by reinitializing, we ensure this worker knows about the update immediately
@@ -712,70 +681,6 @@ def perform_action(self, dem_index, *args, **kwargs):
712
681
)
713
682
714
683
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
-
779
684
class DropIndexAction (OlderModeMixin , IndexAction ):
780
685
DEFAULT_ACTION = IndexAction .ACTION_DROP_INDEX
781
686
0 commit comments