0004-data-disconnect-signals-during-snapshot-loading-5147.patch
combo/data/models.py | ||
---|---|---|
598 | 598 |
# try reusing existing page |
599 | 599 |
return Page.snapshots.get(snapshot=self) |
600 | 600 |
except Page.DoesNotExist: |
601 |
page = Page.load_serialized_page(self.serialization, snapshot=self) |
|
602 |
page.load_serialized_cells(self.serialization['cells']) |
|
603 |
return page |
|
601 |
return self.load_page(self.serialization, snapshot=self) |
|
604 | 602 | |
605 | 603 |
def restore(self): |
606 | 604 |
json_page = self.serialization |
... | ... | |
612 | 610 |
json_page['fields']['exclude_from_navigation'] = self.page.exclude_from_navigation |
613 | 611 |
# restore snapshot |
614 | 612 |
with transaction.atomic(): |
615 |
page = Page.load_serialized_page(json_page) |
|
613 |
return self.load_page(json_page) |
|
614 | ||
615 |
def load_page(self, json_page, snapshot=None): |
|
616 |
try: |
|
617 |
post_save.disconnect(cell_maintain_page_cell_cache) |
|
618 |
page = Page.load_serialized_page(json_page, snapshot=snapshot) |
|
616 | 619 |
page.load_serialized_cells(json_page['cells']) |
620 |
finally: |
|
621 |
post_save.connect(cell_maintain_page_cell_cache) |
|
622 |
page.build_cell_cache() |
|
617 | 623 |
return page |
618 | 624 | |
619 | 625 | |
... | ... | |
1364 | 1370 |
return [] |
1365 | 1371 | |
1366 | 1372 |
def check_validity(self): |
1367 |
if self.link_page: |
|
1373 |
if self.link_page_id:
|
|
1368 | 1374 |
self.mark_as_valid() |
1369 | 1375 |
return |
1370 | 1376 |
if not self.url: |
tests/test_manager.py | ||
---|---|---|
832 | 832 |
resp.form['site_file'] = Upload('site-export.json', site_export, 'application/json') |
833 | 833 |
with CaptureQueriesContext(connection) as ctx: |
834 | 834 |
resp = resp.form.submit() |
835 |
assert len(ctx.captured_queries) in [1142, 1143]
|
|
835 |
assert len(ctx.captured_queries) in [1140, 1141]
|
|
836 | 836 | |
837 | 837 |
Page.objects.all().delete() |
838 | 838 |
assert LinkCell.objects.count() == 0 |
... | ... | |
841 | 841 |
resp.form['site_file'] = Upload('site-export.json', site_export, 'application/json') |
842 | 842 |
with CaptureQueriesContext(connection) as ctx: |
843 | 843 |
resp = resp.form.submit() |
844 |
assert len(ctx.captured_queries) == 667
|
|
844 |
assert len(ctx.captured_queries) == 665
|
|
845 | 845 |
assert set(Page.objects.get(slug='one').related_cells['cell_types']) == set( |
846 | 846 |
['data_textcell', 'data_linkcell'] |
847 | 847 |
) |
... | ... | |
2092 | 2092 |
cell3 = TextCell(page=page, placeholder='content', text='Foobar3', order=2) |
2093 | 2093 |
cell3.save() |
2094 | 2094 | |
2095 |
anonymous_app = app |
|
2096 | ||
2097 | 2095 |
app = login(app) |
2098 | 2096 |
resp = app.get('/manage/pages/%s/' % page.id, status=200) |
2099 | 2097 | |
... | ... | |
2128 | 2126 | |
2129 | 2127 |
with CaptureQueriesContext(connection) as ctx: |
2130 | 2128 |
resp2 = resp.click('view', index=1) |
2131 |
assert len(ctx.captured_queries) == 319
|
|
2129 |
assert len(ctx.captured_queries) == 71
|
|
2132 | 2130 |
assert Page.snapshots.latest('pk').related_cells == {'cell_types': ['data_textcell']} |
2133 | 2131 |
assert resp2.text.index('Hello world') < resp2.text.index('Foobar3') |
2134 | 2132 | |
... | ... | |
2189 | 2187 |
resp = resp.click('restore', index=6) |
2190 | 2188 |
with CaptureQueriesContext(connection) as ctx: |
2191 | 2189 |
resp = resp.form.submit().follow() |
2192 |
assert len(ctx.captured_queries) == 575
|
|
2190 |
assert len(ctx.captured_queries) == 327
|
|
2193 | 2191 | |
2194 | 2192 |
resp2 = resp.click('See online') |
2195 | 2193 |
assert resp2.text.index('Foobar1') < resp2.text.index('Foobar2') < resp2.text.index('Foobar3') |
2196 |
- |