0001-wcs-update-card-cell-model-68037.patch
combo/apps/wcs/migrations/0048_card_pagination.py | ||
---|---|---|
1 |
from django.db import migrations, models |
|
2 | ||
3 | ||
4 |
class Migration(migrations.Migration): |
|
5 | ||
6 |
dependencies = [ |
|
7 |
('wcs', '0047_careforms_title'), |
|
8 |
] |
|
9 | ||
10 |
operations = [ |
|
11 |
migrations.AddField( |
|
12 |
model_name='wcscardinfoscell', |
|
13 |
name='limit', |
|
14 |
field=models.PositiveSmallIntegerField( |
|
15 |
blank=True, null=True, verbose_name='Number of cards per page (default 10)' |
|
16 |
), |
|
17 |
), |
|
18 |
migrations.AddField( |
|
19 |
model_name='wcscardinfoscell', |
|
20 |
name='only_for_user', |
|
21 |
field=models.BooleanField( |
|
22 |
default=False, verbose_name='Limit to cards linked to the logged-in user' |
|
23 |
), |
|
24 |
), |
|
25 |
] |
combo/apps/wcs/migrations/0049_card_pagination.py | ||
---|---|---|
1 |
from django.db import migrations |
|
2 | ||
3 | ||
4 |
def update_only_for_user(apps, schema_editor): |
|
5 |
WcsCardInfosCell = apps.get_model('wcs', 'WcsCardInfosCell') |
|
6 |
for cell in WcsCardInfosCell.objects.all(): |
|
7 |
if not cell.carddef_reference: |
|
8 |
continue |
|
9 |
parts = cell.carddef_reference.split(':') |
|
10 |
if len(parts) <= 2: |
|
11 |
continue |
|
12 |
cell.only_for_user = True |
|
13 |
cell.save() |
|
14 | ||
15 | ||
16 |
class Migration(migrations.Migration): |
|
17 | ||
18 |
dependencies = [ |
|
19 |
('wcs', '0048_card_pagination'), |
|
20 |
] |
|
21 | ||
22 |
operations = [ |
|
23 |
migrations.RunPython(update_only_for_user, migrations.RunPython.noop), |
|
24 |
] |
combo/apps/wcs/models.py | ||
---|---|---|
940 | 940 |
carddef_reference = models.CharField(_('Card Model'), max_length=150) |
941 | 941 |
related_card_path = models.CharField(_('Card Identifier'), max_length=1000, blank=True) |
942 | 942 |
card_ids = models.CharField(_('Other Card Identifiers'), max_length=1000, blank=True) |
943 |
only_for_user = models.BooleanField(_('Limit to cards linked to the logged-in user'), default=False) |
|
943 | 944 |
without_user = models.BooleanField(_('Ignore the logged-in user'), default=False) |
945 |
limit = models.PositiveSmallIntegerField( |
|
946 |
_('Number of cards per page (default 10)'), null=True, blank=True |
|
947 |
) |
|
944 | 948 |
custom_schema = JSONField(blank=True, default=dict) |
945 | 949 | |
946 | 950 |
title_type = models.CharField( |
947 |
- |