Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-26 08:40:25

0001 from django.db import migrations
0002 
0003 
0004 def fill_background_category_description(apps, schema_editor):
0005     """The Background category (digit 6) was seeded without a description, unlike
0006     categories 1-5. Fill it."""
0007     PhysicsCategory = apps.get_model('pcs', 'PhysicsCategory')
0008     PhysicsCategory.objects.filter(digit=6, description='').update(
0009         description='Background k tags compose with physics tags they overlay'
0010     )
0011 
0012 
0013 def drop_physics_param_defs(apps, schema_editor):
0014     """Drop the cached physics (p) tag param-defs so they re-seed from the
0015     completed schema (new fields: nucleon, helicity, beam_config, state,
0016     mechanism, final_state, channel, mass; new process values). Mirrors
0017     0011's background-param-defs refresh: the defs are seeded once into
0018     PersistentState and otherwise keep the stale field set."""
0019     PersistentState = apps.get_model('monitor_app', 'PersistentState')
0020     ps = PersistentState.objects.filter(id=1).first()
0021     if ps and isinstance(ps.state_data, dict) and 'pcs_param_defs_p' in ps.state_data:
0022         del ps.state_data['pcs_param_defs_p']
0023         ps.save(update_fields=['state_data'])
0024 
0025 
0026 class Migration(migrations.Migration):
0027 
0028     dependencies = [
0029         ('pcs', '0013_fix_seed_created_by'),
0030         ('monitor_app', '0015_persistentstate_and_more'),
0031     ]
0032 
0033     operations = [
0034         migrations.RunPython(fill_background_category_description, migrations.RunPython.noop),
0035         migrations.RunPython(drop_physics_param_defs, migrations.RunPython.noop),
0036     ]