0001-wcs-add-db-cache-refresh-to-formdef-category-cells-2.patch
combo/apps/wcs/__init__.py | ||
---|---|---|
34 | 34 |
from . import urls |
35 | 35 |
return urls.urlpatterns |
36 | 36 | |
37 |
def hourly(self): |
|
38 |
self.update_db_cache() |
|
39 | ||
40 |
def update_db_cache(self): |
|
41 |
from combo.data.models import CellBase |
|
42 |
from .models import WcsFormCell, WcsCategoryCell, WcsFormsOfCategoryCell |
|
43 |
for cell in CellBase.get_cells( |
|
44 |
cell_filter=lambda x: x in (WcsFormCell, WcsCategoryCell, WcsFormsOfCategoryCell)): |
|
45 |
cell.save() |
|
46 | ||
37 | 47 |
default_app_config = 'combo.apps.wcs.AppConfig' |
tests/test_wcs.py | ||
---|---|---|
11 | 11 |
import time |
12 | 12 |
import os |
13 | 13 | |
14 |
from django.apps import apps |
|
14 | 15 |
from django.conf import settings |
15 | 16 |
from django.core.cache import cache |
16 | 17 |
from django.test import override_settings |
... | ... | |
267 | 268 |
'url': 'http://127.0.0.1:8999/form-title/', |
268 | 269 |
'text': ''}] |
269 | 270 | |
271 |
# artificially change title |
|
272 |
WcsFormCell.objects.filter(id=cell.id).update(cached_title='XXX') |
|
273 |
assert WcsFormCell.objects.get(id=cell.id).cached_title == 'XXX' |
|
274 |
# run update db cache |
|
275 |
appconfig = apps.get_app_config('wcs') |
|
276 |
appconfig.update_db_cache() |
|
277 |
assert WcsFormCell.objects.get(id=cell.id).cached_title == 'form title' |
|
270 | 278 | |
271 | 279 |
@wcsctl_present |
272 | 280 |
def test_form_cell_load(): |
273 |
- |