Run migrations. Changed HelpEntry 'view' locks to use 'read' instead, leaving 'view' to control what is seen in index.
This commit is contained in:
parent
b050656319
commit
201e567e34
1 changed files with 34 additions and 0 deletions
34
evennia/help/migrations/0005_auto_20210530_1818.py
Normal file
34
evennia/help/migrations/0005_auto_20210530_1818.py
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Generated by Django 3.2.3 on 2021-05-30 18:18
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
def update_help_entries(apps, schema_editor):
|
||||||
|
"""
|
||||||
|
Change all help-entry files that use view: locks to read: locks
|
||||||
|
(read: was not used before and view: was previously what read is now).
|
||||||
|
|
||||||
|
"""
|
||||||
|
HelpEntry = apps.get_model("help", "HelpEntry")
|
||||||
|
for help_entry in HelpEntry.objects.all():
|
||||||
|
lock_storage = help_entry.db_lock_storage
|
||||||
|
lock_storage = dict(lstring.split(":", 1) if ":" in lstring else (lstring, "")
|
||||||
|
for lstring in str(lock_storage).split(";"))
|
||||||
|
if "read" in lock_storage:
|
||||||
|
# already in place - skip
|
||||||
|
continue
|
||||||
|
if "view" in lock_storage:
|
||||||
|
lock_storage["read"] = lock_storage.pop("view")
|
||||||
|
lock_storage = ";".join(f"{typ}:{lock}" for typ, lock in lock_storage.items())
|
||||||
|
help_entry.db_lock_storage = lock_storage
|
||||||
|
help_entry.save(update_fields=["db_lock_storage"])
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('help', '0004_auto_20210520_2137'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(update_help_entries)
|
||||||
|
]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue