Closed sssbox closed 5 years ago
Thanks for your in-depth analysis. It looks right to me. It also seems you are half-way to a patch so it would be easiest for you to do it, if you can find the time.
Thanks Adam.
Do you think it would be worth preventing conflicting conditions or should I just prevent duplicates? Preventing conflicting conditions would require more changes to let users know why the new condition wasn't added. Also, there might be some edge cases where it might be useful to have (at least temporarily) conflicting conditions that I've not considered.
Conflicting would be more useful, but perhaps preventing duplicates would be a good first step.
Fixed in #212
https://github.com/adamchainz/gargoyle/blob/9d699ae94deccedd35b90b0ce93f48fcb503f9dc/gargoyle/models.py#L141
It seems like this line of code is supposed to prevent adding conditions that already exist, however because
self.value[namespace][field_name]
is a list of tuples with the second item as the condition, thecondition not in
will always be True.Seems like there are two solutions, either just prevent duplicates:
or prevent adding conflicting or duplicate conditions (seems like this would probably make more sense, however probably shouldn't just silently fail, should probably let the user know to remove the other condition first):
I might be able to find some time to work on a patch if nobody else wants to quickly throw something together, but would like some feedback first.