-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #13299: Improve options for controlling custom field visibility (
#14289) * Add ui_visible and ui_editable fields * Extend migration to map new visible/editable values * Remove ui_visibility field * Update docs
- Loading branch information
1 parent
549b0ea
commit a73ba00
Showing
19 changed files
with
204 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from django.db import migrations, models | ||
|
||
|
||
def update_ui_attrs(apps, schema_editor): | ||
""" | ||
Replicate legacy ui_visibility values to the new ui_visible and ui_editable fields. | ||
""" | ||
CustomField = apps.get_model('extras', 'CustomField') | ||
|
||
CustomField.objects.filter(ui_visibility='read-write').update(ui_visible='always', ui_editable='yes') | ||
CustomField.objects.filter(ui_visibility='read-only').update(ui_visible='always', ui_editable='no') | ||
CustomField.objects.filter(ui_visibility='hidden').update(ui_visible='hidden', ui_editable='hidden') | ||
CustomField.objects.filter(ui_visibility='hidden-ifunset').update(ui_visible='if-set', ui_editable='yes') | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('extras', '0099_cachedvalue_ordering'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='customfield', | ||
name='ui_editable', | ||
field=models.CharField(default='yes', max_length=50), | ||
), | ||
migrations.AddField( | ||
model_name='customfield', | ||
name='ui_visible', | ||
field=models.CharField(default='always', max_length=50), | ||
), | ||
migrations.RunPython( | ||
code=update_ui_attrs, | ||
reverse_code=migrations.RunPython.noop | ||
), | ||
migrations.RemoveField( | ||
model_name='customfield', | ||
name='ui_visibility', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.