Configurable privacy levels (hacky)
Yet another alternative to !2284 (closed). This one is hacky, but finally I got something that actually works:
The trouble with !2284 (closed) was that I needed both an integer value and some additional information to distinguish which label that value should have. In this approach I solved that by turning Subject.privacy_level
into a float. The effective value is math.ceil(x)
. For example, I could now assign a privacy level of 0.5 which effectively behaves the same as 1, but can be have a separate label.
I also added a setting which allows to define custom privacy levels. This is hacky because it changes a model, which in django usually requires a migration. In practice the migration is not necessary, but django will complain anyway. The label is also not translatable.
What I like about this approach is that it does not change anything unless you use the new setting. No data migrations necessary. But it is very hacky.