|
22 | 22 | from api.utils.require_auth import admin_only |
23 | 23 | from api.utils.request_utils import get_profile_model, imgur_client |
24 | 24 | from api.utils.constants import Account |
| 25 | +from api.utils.email_sync import update_email_across_models |
25 | 26 | import csv |
26 | 27 | import io |
27 | 28 | from api.views.auth import create_firebase_user |
@@ -433,60 +434,6 @@ def editEmailPassword(): |
433 | 434 | email=email, |
434 | 435 | ) |
435 | 436 | if email != ex_email: |
436 | | - ex_data = MenteeApplication.objects.filter(email=ex_email) |
437 | | - if len(ex_data) > 0: |
438 | | - for ex_item in ex_data: |
439 | | - ex_item.email = email |
440 | | - ex_item.save() |
441 | | - ex_data = MentorApplication.objects.filter(email=ex_email) |
442 | | - if len(ex_data) > 0: |
443 | | - for ex_item in ex_data: |
444 | | - ex_item.email = email |
445 | | - ex_item.save() |
446 | | - ex_data = MenteeProfile.objects.filter(email=ex_email) |
447 | | - if len(ex_data) > 0: |
448 | | - for ex_item in ex_data: |
449 | | - ex_item.email = email |
450 | | - ex_item.save() |
451 | | - ex_data = MentorProfile.objects.filter(email=ex_email) |
452 | | - if len(ex_data) > 0: |
453 | | - for ex_item in ex_data: |
454 | | - ex_item.email = email |
455 | | - ex_item.save() |
456 | | - ex_data = NewMentorApplication.objects.filter(email=ex_email) |
457 | | - if len(ex_data) > 0: |
458 | | - for ex_item in ex_data: |
459 | | - ex_item.email = email |
460 | | - ex_item.save() |
461 | | - ex_data = PartnerProfile.objects.filter(email=ex_email) |
462 | | - if len(ex_data) > 0: |
463 | | - for ex_item in ex_data: |
464 | | - ex_item.email = email |
465 | | - ex_item.save() |
466 | | - ex_data = Users.objects.filter(email=ex_email) |
467 | | - if len(ex_data) > 0: |
468 | | - for ex_item in ex_data: |
469 | | - ex_item.email = email |
470 | | - ex_item.save() |
471 | | - ex_data = VerifiedEmail.objects.filter(email=ex_email) |
472 | | - if len(ex_data) > 0: |
473 | | - for ex_item in ex_data: |
474 | | - ex_item.email = email |
475 | | - ex_item.save() |
476 | | - ex_data = Guest.objects.filter(email=ex_email) |
477 | | - if len(ex_data) > 0: |
478 | | - for ex_item in ex_data: |
479 | | - ex_item.email = email |
480 | | - ex_item.save() |
481 | | - ex_data = Support.objects.filter(email=ex_email) |
482 | | - if len(ex_data) > 0: |
483 | | - for ex_item in ex_data: |
484 | | - ex_item.email = email |
485 | | - ex_item.save() |
486 | | - ex_data = Moderator.objects.filter(email=ex_email) |
487 | | - if len(ex_data) > 0: |
488 | | - for ex_item in ex_data: |
489 | | - ex_item.email = email |
490 | | - ex_item.save() |
| 437 | + update_email_across_models(ex_email, email) |
491 | 438 |
|
492 | 439 | return create_response(status=200, message="successful edited") |
0 commit comments