Skip to content

Commit 5b43de2

Browse files
committed
remove junky fields from partner_program_data
1 parent 4cbc396 commit 5b43de2

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Generated by Django 4.2.3 on 2023-12-29 21:02
2+
3+
from django.db import migrations
4+
5+
from partner_programs.models import PartnerProgramUserProfile
6+
7+
FIELDS_TO_DELETE = [
8+
'password',
9+
'formid',
10+
'tranid',
11+
'COOKIES',
12+
'utm_term',
13+
'utm_medium',
14+
'utm_source',
15+
'utm_content',
16+
'utm_campaign',
17+
]
18+
19+
20+
def normalize_profiles_data(apps, schema_editor):
21+
for profile in PartnerProgramUserProfile.objects.all():
22+
program_data = profile.partner_program_data
23+
if any(field in program_data for field in FIELDS_TO_DELETE):
24+
program_data['tilda'] = True
25+
26+
for field in FIELDS_TO_DELETE:
27+
if field in program_data:
28+
program_data.pop(field)
29+
profile.partner_program_data = program_data
30+
profile.save()
31+
32+
33+
def do_nothing(apps, schema_editor):
34+
pass
35+
36+
37+
class Migration(migrations.Migration):
38+
dependencies = [
39+
("partner_programs", "0003_partnerprogramuserprofile_project_and_more"),
40+
]
41+
42+
operations = [
43+
migrations.RunPython(normalize_profiles_data, reverse_code=do_nothing),
44+
]

0 commit comments

Comments
 (0)