0001-wcs-fix-use-of-custom-view-in-card-cell-with-related.patch
combo/apps/wcs/models.py | ||
---|---|---|
1024 | 1024 |
def get_repeat_template(self, context): |
1025 | 1025 |
return len(context.get(self.global_context_key) or []) |
1026 | 1026 | |
1027 |
def get_card_data(self, card_slug, card_id, context, synchronous=False): |
|
1027 |
def get_card_data(self, card_slug, card_custom_view, card_id, context, synchronous=False):
|
|
1028 | 1028 |
api_url = '/api/cards/%s/%s/?include-files-content=off' % (card_slug, card_id) |
1029 |
if self.card_custom_view:
|
|
1029 |
if card_custom_view: |
|
1030 | 1030 |
api_url = '/api/cards/%s/%s/%s/?include-files-content=off' % ( |
1031 | 1031 |
card_slug, |
1032 |
self.card_custom_view,
|
|
1032 |
card_custom_view, |
|
1033 | 1033 |
card_id, |
1034 | 1034 |
) |
1035 | 1035 |
user = self.get_concerned_user(context) |
... | ... | |
1211 | 1211 |
return [] |
1212 | 1212 |
# and data |
1213 | 1213 |
next_card_data = self.get_card_data( |
1214 |
card_slug, card_data['fields']['%s_raw' % varname], context, synchronous=True |
|
1214 |
card_slug, None, card_data['fields']['%s_raw' % varname], context, synchronous=True
|
|
1215 | 1215 |
) |
1216 | 1216 |
if not next_card_data: |
1217 | 1217 |
# card data not found |
... | ... | |
1240 | 1240 |
if not card_id: |
1241 | 1241 |
# no card id found |
1242 | 1242 |
return [] |
1243 |
card_data = self.get_card_data(first_cell.card_slug, card_id, context, synchronous=True) |
|
1243 |
card_data = self.get_card_data( |
|
1244 |
first_cell.card_slug, first_cell.card_custom_view, card_id, context, synchronous=True |
|
1245 |
) |
|
1244 | 1246 |
if not card_data: |
1245 | 1247 |
# card data not found |
1246 | 1248 |
return [] |
... | ... | |
1318 | 1320 |
extra_context['card_not_found'] = True |
1319 | 1321 |
return extra_context |
1320 | 1322 | |
1321 |
card_data = self.get_card_data(self.card_slug, card_id, context) |
|
1323 |
card_data = self.get_card_data(self.card_slug, self.card_custom_view, card_id, context)
|
|
1322 | 1324 |
if not card_data: |
1323 | 1325 |
return extra_context |
1324 | 1326 |
tests/test_wcs.py | ||
---|---|---|
122 | 122 |
{'title': 'Card Model 2', 'slug': 'card_model_2'}, |
123 | 123 |
{'title': 'Card Model 3', 'slug': 'card_model_3'}, |
124 | 124 |
{'title': 'Card A', 'slug': 'card_a'}, |
125 |
{'title': 'Card B', 'slug': 'card_b'}, |
|
125 |
{'title': 'Card B', 'slug': 'card_b', 'custom_views': [{'id': 'a-custom-view', 'text': 'foo bar'}]},
|
|
126 | 126 |
{'title': 'Card C', 'slug': 'card_c'}, |
127 | 127 |
{'title': 'Card D', 'slug': 'card_d'}, |
128 | 128 |
{'title': 'Card E', 'slug': 'card_e'}, |
... | ... | |
1695 | 1695 |
('default:card_model_3', 'test : Card Model 3'), |
1696 | 1696 |
('default:card_a', 'test : Card A'), |
1697 | 1697 |
('default:card_b', 'test : Card B'), |
1698 |
('default:card_b:a-custom-view', 'test : Card B - foo bar'), |
|
1698 | 1699 |
('default:card_c', 'test : Card C'), |
1699 | 1700 |
('default:card_d', 'test : Card D'), |
1700 | 1701 |
('default:card_e', 'test : Card E'), |
... | ... | |
1704 | 1705 |
('other:card_model_3', 'test2 : Card Model 3'), |
1705 | 1706 |
('other:card_a', 'test2 : Card A'), |
1706 | 1707 |
('other:card_b', 'test2 : Card B'), |
1708 |
('other:card_b:a-custom-view', 'test2 : Card B - foo bar'), |
|
1707 | 1709 |
('other:card_c', 'test2 : Card C'), |
1708 | 1710 |
('other:card_d', 'test2 : Card D'), |
1709 | 1711 |
('other:card_e', 'test2 : Card E'), |
... | ... | |
1998 | 2000 |
('default:card_model_3', 'test : Card Model 3'), |
1999 | 2001 |
('default:card_a', 'test : Card A'), |
2000 | 2002 |
('default:card_b', 'test : Card B'), |
2003 |
('default:card_b:a-custom-view', 'test : Card B - foo bar'), |
|
2001 | 2004 |
('default:card_c', 'test : Card C'), |
2002 | 2005 |
('default:card_d', 'test : Card D'), |
2003 | 2006 |
('default:card_e', 'test : Card E'), |
... | ... | |
2007 | 2010 |
('other:card_model_3', 'test2 : Card Model 3'), |
2008 | 2011 |
('other:card_a', 'test2 : Card A'), |
2009 | 2012 |
('other:card_b', 'test2 : Card B'), |
2013 |
('other:card_b:a-custom-view', 'test2 : Card B - foo bar'), |
|
2010 | 2014 |
('other:card_c', 'test2 : Card C'), |
2011 | 2015 |
('other:card_d', 'test2 : Card D'), |
2012 | 2016 |
('other:card_e', 'test2 : Card E'), |
... | ... | |
3477 | 3481 |
for j, url in enumerate(urls): |
3478 | 3482 |
assert url in mock_send.call_args_list[j][0][0].url |
3479 | 3483 | |
3484 |
# reset |
|
3480 | 3485 |
cell.order = 0 # reset |
3481 | 3486 |
cell.save() |
3487 |
cell2.slug = 'slugb' |
|
3488 |
cell2.save() |
|
3489 | ||
3490 |
# test with custom_view |
|
3491 |
cell2.carddef_reference = 'default:card_b:a-custom-view' |
|
3492 |
cell2.save() |
|
3493 |
single( |
|
3494 |
urls=[ |
|
3495 |
# get first cell data |
|
3496 |
'/api/cards/card_a/1/', |
|
3497 |
# get card_c schema |
|
3498 |
'/api/cards/card_c/@schema', |
|
3499 |
# follow cardc relation |
|
3500 |
'/api/cards/card_c/6/', |
|
3501 |
# and follow cardb relation |
|
3502 |
'/api/cards/card_b/a-custom-view/7/', |
|
3503 |
] |
|
3504 |
) |
|
3505 | ||
3482 | 3506 |
# direct and multiple relation (items) |
3483 |
cell2.slug = 'slugb' # reset
|
|
3507 |
cell2.carddef_reference = 'default:card_b' # reset
|
|
3484 | 3508 |
cell2.related_card_path = 'sluga/cardsb' |
3485 | 3509 |
cell2.save() |
3486 | 3510 |
multiple( |
3487 |
- |