datatracker/ietf/community/migrations/0005_user_to_person.py
Robert Sparks d9cc26be96
feat: replace references to User with references to Person (#6024)
* refactor: change references from User to Person (#5821)

* refactor: Change CommunityList reference from User to Person

* refactor: Convert more user references to person

* refactor: Change augment_docs_and_user_with_user_info to person

* refactor: Change Nomination and Feedback references from User to Person

* refactor: Change a few test case function signatures to be more pythonic

* refactor: Harmonize how profile and photo views look up email_or_name

* refactor: Rework community views to operate on Person instead of User (#5859)

* test: Update tests to try all of the person's emails and aliases

* fix: Recode a test case to avoid an exception if there's Unicode in the URL

This only happens using the form-filling and submission feature of
WebTest, which is only used in this one test case, so just it rip out.

* test: Add duplicate-person tests

* fix: If there are multiple matching users, prefer the logged-in one.

* chore: We no longer use WebTest, so don't include it.

* fix: Address review comments

* fix: case-insensitive person name or email matching (#6096)

* chore: Renumber migrations

* fix: Update merged code so tests pass (#6887)

* fix: Use refactored method

* fix: Don't assume user has person

* fix: Use new view param name

* chore: Drop community lists w/o person; cleanup (#6896)

* fix: Don't assume user has person

* fix: user->person in update_community_list_index.py

* feat: Remove CommunityLists without Person

* refactor: Speed up nomcom migrations

---------

Co-authored-by: Paul Selkirk <paul@painless-security.com>
Co-authored-by: Jennifer Richards <jennifer@staff.ietf.org>
2024-01-24 11:00:19 -06:00

55 lines
1.6 KiB
Python

# Generated by Django 4.2.2 on 2023-06-12 19:35
from django.conf import settings
from django.db import migrations
import django.db.models.deletion
import ietf.utils.models
def forward(apps, schema_editor):
CommunityList = apps.get_model('community', 'CommunityList')
for clist in CommunityList.objects.all():
try:
clist.person = clist.user.person
except:
clist.person = None
clist.save()
def reverse(apps, schema_editor):
CommunityList = apps.get_model('community', 'CommunityList')
for clist in CommunityList.objects.all():
try:
clist.user = clist.person.user
except:
clist.user = None
clist.save()
class Migration(migrations.Migration):
dependencies = [
("community", "0004_delete_useless_community_lists"),
("person", "0001_initial"),
]
operations = [
migrations.AddField(
model_name="communitylist",
name="person",
field=ietf.utils.models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="person.Person",
),
),
migrations.RunPython(forward, reverse),
migrations.RemoveField(
model_name="communitylist",
name="user",
field=ietf.utils.models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL),
),
]