-
Notifications
You must be signed in to change notification settings - Fork 127
Description
Describe the solution you'd like
Instead of having a "one of" selection for status filter (see image), it would be nice to be able to select multiple (something list checkboxes per status or something)
In my case, I would like to be able to see "In Progress" and "Planning" items.
Additional context
Step 1 (Proof of concept)
For testing purposes I have made the following changes as a proof of concept:
diff --git src/app/models.py src/app/models.py
index 8a3e3aac..8c48b15a 100644
--- src/app/models.py
+++ src/app/models.py
@@ -238,6 +238,11 @@ class MediaManager(models.Manager):
if status_filter != users.models.MediaStatusChoices.ALL:
queryset = queryset.filter(status=status_filter)
+ else:
+ queryset = queryset.filter(
+ Q(status=users.models.MediaStatusChoices.IN_PROGRESS) |
+ Q(status=users.models.MediaStatusChoices.PLANNING)
+ )
if search:
queryset = queryset.filter(item__title__icontains=search)So when I select "All", it only shows "In Progress" and "Planning" items.
This is the easy part, multi-selection is possible quite easily.
Step 2 (Passing multiple statuses)
Then I tried to pass multiple statuses via querystring:
/medialist/tv?sort=end_date&status=Planning,In Progress&search=&layout=grid
Doing so leads to the users model (src/users/models.py) update_preference being called and it performs some validity checks.
Here it fails silently because it is a list of statuses and not a single status. So it falls back to the previous user preference.
No big deal, I thought, I could tweak this function to allow list of statuses by checking validity with split and a loop. Easy peasy.
But! There is a bunch of limitation regarding those fields. For instance, tv_status model (src/users/models.py) has a limit of 20 characters:
tv_status = models.CharField(
max_length=20,
default=MediaStatusChoices.ALL,
choices=MediaStatusChoices.choices,
)And even more (char length + value constraint) on the DB models as far as I understand making it impossible to store/save (see migrations):
migrations.AlterField(
model_name='user',
name='tv_status',
field=models.CharField(choices=[('All', 'All'), ('Completed', 'Completed'), ('In progress', 'In Progress'), ('Planning', 'Planning'), ('Paused', 'Paused'), ('Dropped', 'Dropped')], default='All', max_length=20),
),
migrations.AddConstraint(
model_name='user',
constraint=models.CheckConstraint(condition=models.Q(('tv_status__in', ['All', 'Completed', 'In progress', 'Planning', 'Paused', 'Dropped'])), name='tv_status_valid'),
),
Step 3 (User Interface)
Haven't tried yet :D
Conclusion
It seems doable but I am not very familiar with the codebase yet so I don't want to mess up, I am open to suggestion/help on how to do that properly :)