Scope presets to active profiles and support cloning.

This keeps data isolated per profile while letting users duplicate setups quickly.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-02-08 13:51:02 +13:00
parent 00514f0525
commit 6c6ed22dbe
8 changed files with 406 additions and 45 deletions

View File

@@ -1,10 +1,26 @@
from models.model import Model
from models.profile import Profile
class Preset(Model):
def __init__(self):
super().__init__()
# Backfill profile ownership for existing presets.
try:
profiles = Profile()
profile_list = profiles.list()
default_profile_id = profile_list[0] if profile_list else None
changed = False
for preset_id, preset_data in list(self.items()):
if isinstance(preset_data, dict) and "profile_id" not in preset_data:
if default_profile_id is not None:
preset_data["profile_id"] = str(default_profile_id)
changed = True
if changed:
self.save()
except Exception:
pass
def create(self):
def create(self, profile_id=None):
next_id = self.get_next_id()
self[next_id] = {
"name": "",
@@ -20,6 +36,7 @@ class Preset(Model):
"n6": 0,
"n7": 0,
"n8": 0,
"profile_id": str(profile_id) if profile_id is not None else None,
}
self.save()
return next_id