def setUp(self): self.values_list = ValuesListFactory(values={ 'test1': 'Test 1', 'test2': 'Test 2', 'test3': 'Test 3', }) populate_values_list_cache()
def setUp(self): super().setUp() Model = ContentType.objects.get_for_model(ContractorDeliverable) self.cat1 = CategoryFactory(category_template__metadata_model=Model) self.cat2 = CategoryFactory(category_template__metadata_model=Model) self.user1 = UserFactory( email='*****@*****.**', password='******', is_superuser=True, category=self.cat1, send_behind_schedule_alert_mails=True) self.user1.categories.add(self.cat2) self.user2 = UserFactory( email='*****@*****.**', password='******', is_superuser=True, category=self.cat2, send_behind_schedule_alert_mails=True) self.doc1 = DocumentFactory( category=self.cat1, metadata_factory_class=ContractorDeliverableFactory, revision_factory_class=ContractorDeliverableRevisionFactory) self.doc2 = DocumentFactory( category=self.cat2, metadata_factory_class=ContractorDeliverableFactory, revision_factory_class=ContractorDeliverableRevisionFactory) populate_values_list_cache()
def setUp(self): self.values_list = ValuesListFactory( values={ 'test1': 'Test 1', 'test2': 'Test 2', 'test3': 'Test 3', } ) populate_values_list_cache()
def get_choices_from_list(list_index): """Load the values list from cache. Cache is populated in multiple places: - post-migrate signal handler - when admin form is submitted - using the `reload_metadata_cache` task """ cache_key = 'values_list_{}'.format(list_index) if cache_key not in cache: # The only reason it would fail is because the # db is not ready. So we'll try again later. try: populate_values_list_cache() except: # noqa pass values = cache.get(cache_key, []) return values
def get_choices_from_list(list_index): """Load the values list from cache. Cache is populated in multiple places: - post-migrate signal handler - when admin form is submitted - using the `reload_metadata_cache` task """ cache_key = 'values_list_{}'.format(list_index) if cache_key not in cache: # The only reason it would fail is because the # db is not ready. So we'll try again later. try: populate_values_list_cache() except: pass values = cache.get(cache_key, []) return values
def handle(self, *args, **options): logger.info('Populating values list cache') populate_values_list_cache()
def save_formset(self, request, form, formset, change): super(ValuesListAdmin, self).save_formset(request, form, formset, change) populate_values_list_cache()