wcs: update card cell model (#68037)

add fields only_for_user & limit
This commit is contained in:
Lauréline Guérin 2022-08-09 09:46:23 +02:00
parent 652a6dff32
commit d23bb074b6
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
3 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,25 @@
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('wcs', '0047_careforms_title'),
]
operations = [
migrations.AddField(
model_name='wcscardinfoscell',
name='limit',
field=models.PositiveSmallIntegerField(
blank=True, null=True, verbose_name='Number of cards per page (default 10)'
),
),
migrations.AddField(
model_name='wcscardinfoscell',
name='only_for_user',
field=models.BooleanField(
default=False, verbose_name='Limit to cards linked to the logged-in user'
),
),
]

View File

@ -0,0 +1,24 @@
from django.db import migrations
def update_only_for_user(apps, schema_editor):
WcsCardInfosCell = apps.get_model('wcs', 'WcsCardInfosCell')
for cell in WcsCardInfosCell.objects.all():
if not cell.carddef_reference:
continue
parts = cell.carddef_reference.split(':')
if len(parts) <= 2:
continue
cell.only_for_user = True
cell.save()
class Migration(migrations.Migration):
dependencies = [
('wcs', '0048_card_pagination'),
]
operations = [
migrations.RunPython(update_only_for_user, migrations.RunPython.noop),
]

View File

@ -945,7 +945,11 @@ class WcsCardInfosCell(CardMixin, CellBase):
carddef_reference = models.CharField(_('Card Model'), max_length=150)
related_card_path = models.CharField(_('Card Identifier'), max_length=1000, blank=True)
card_ids = models.CharField(_('Other Card Identifiers'), max_length=1000, blank=True)
only_for_user = models.BooleanField(_('Limit to cards linked to the logged-in user'), default=False)
without_user = models.BooleanField(_('Ignore the logged-in user'), default=False)
limit = models.PositiveSmallIntegerField(
_('Number of cards per page (default 10)'), null=True, blank=True
)
custom_schema = JSONField(blank=True, default=dict)
title_type = models.CharField(