|
| 1 | +from django.db import migrations, models |
| 2 | +from api.utils import id_generator |
| 3 | + |
| 4 | +def create_codecorgi_profile(apps, schema_editor): |
| 5 | + User = apps.get_model('accounts', 'User') |
| 6 | + Profile = apps.get_model('profile', 'Profile') |
| 7 | + |
| 8 | + corgiUser = User.objects.create( |
| 9 | + password=id_generator(), |
| 10 | + |
| 11 | + is_verified=True, |
| 12 | + is_admin=True, |
| 13 | + username='codecorgi', |
| 14 | + ) |
| 15 | + |
| 16 | + Profile.objects.create( |
| 17 | + tagline = 'Woof Woof', |
| 18 | + bio = 'Coder\'s best friend', |
| 19 | + ___location = 'Brooklyn, NY', |
| 20 | + linkedin_url = 'https://www.linkedin.com/company/codecorgi', |
| 21 | + twitter_url = 'https://twitter.com/codecorgi', |
| 22 | + github_url = 'https://github.com/corgicode', |
| 23 | + company = 'codecorgi', |
| 24 | + blog = 'https://medium.com/@codecorgi', |
| 25 | + public_repos = 'https://github.com/code-corgi', |
| 26 | + hireable = False, |
| 27 | + user = corgiUser, |
| 28 | + name = 'Corginson', |
| 29 | + avatar_url = 'https://raw.githubusercontent.com/corgicode/frontend-react/dev/src/assets/images/logo-square-hover.png', |
| 30 | + hero_image_url = 'https://raw.githubusercontent.com/corgicode/frontend-react/dev/src/assets/images/hero-image.jpg', |
| 31 | + ) |
| 32 | + |
| 33 | +def delete_codecorgi_profile(apps, schema_editor): |
| 34 | + User = apps.get_model('accounts', 'User') |
| 35 | + Profile = apps.get_model('profile', 'Profile') |
| 36 | + |
| 37 | + corgiUser = User. objects. filter( email='[email protected]'). first() |
| 38 | + Profile.objects.filter(user_id=corgiUser.id).delete() |
| 39 | + corgiUser.delete() |
| 40 | + |
| 41 | + |
| 42 | +class Migration(migrations.Migration): |
| 43 | + dependencies = [ |
| 44 | + ('profile', '0001_initial') |
| 45 | + ] |
| 46 | + |
| 47 | + operations = [ |
| 48 | + migrations.RunPython(create_codecorgi_profile, delete_codecorgi_profile), |
| 49 | + ] |
0 commit comments