-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change vocabulary around text answer review #1776
Conversation
changes look straight forward so far. Regarding "deleted" / "published": To me, the past tense implies this already happened, but I think the meaning is: "On result publishing, the text answers are deleted", so maybe we want "delete" and "publish" instead? ("undecided" is fine). |
”Protect“ doesn't really convey the meaning by itself. While not as nice from the one-word-perspective, I would prefer something like ”make private“. What do you say? |
ba3a8ba
to
9cefdd4
Compare
We forgot to update the "HI" values in evap/results/fixtures/minimal_test_data_results.json -- which is a bit embarrassing because the PR touched the lines, it just didn't update the values 😅 |
Hmm, why didn't anything break? Did we just never find these rows when filtering for specific states, or did Django automatically ignore them? |
I would have expected django to error out on model validation while running I was thinking earlier today of adding a CheckConstraint to all models that have fields with choices. We currently have 15 of those. Might be worth it, a few more lines, one migration, I wouldn't expect it to have any noticable performance impact... |
I guess that would work, but it also sounds a bit unsatisfying and we would have to remember to update constraints when updating models in the future. Maybe we can ask Django people for a fix / new feature? |
I agree, if django doesn't want to automatically add database constraints, I'd at least like to have a There have been multiple issues on the django bugtracker about choices not being enforced, usually closed as wontfix or invalid with a note that you can always add checks manually if you want. See their tickets 26131 and 32726. Maybe we should make a new one that proposes the additional parameter for fields. Anyway, it doesn't seem like we would get this in the near future. |
Okay, maybe class MyModel(Model):
field = ...
@add_choices_constraints
class Meta:
...
# gets transformed into something like
class MyModel(Model):
field = ...
class Meta:
@classmethod
@property
def constraints(cls):
return [
CheckConstraint(...)
for field in get_all_django_fields(MyModel)
if field.has_choices()
] or maybe the Or maybe, this is overkill and we want to track this manually. What do you think? |
In #1705, we started by changing the names in the frontend, this renames things in the code and database.
Note: Let's not forget that we must think about logging when doing these kinds of changes. As
TextAnswer
is not aLoggedModel
, we don't need to do anything in this case.