<commit_before>from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver

from wagtail.wagtailadmin.edit_handlers import (
    FieldPanel,
    MultiFieldPanel,
    PageChooserPanel,
)
from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
from wagtail.wagtailsearch import index
from wagtail.wagtailsnippets.models import register_snippet

from productions.models import ProductionPageRelatedPerson


@register_snippet
class Person(models.Model, index.Indexed):
    first_name = models.CharField(max_length=255)
    last_name = models.CharField(max_length=255)
    role = models.CharField(max_length=255, blank=True)

    photo = models.ForeignKey(
        'localore_admin.LocaloreImage',
        null=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    production = models.ForeignKey(
        'productions.ProductionPage',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
        verbose_name="associated production",
        help_text="Leave blank for AIR/Localore staff."
    )

    biography = RichTextField(blank=True)

    email = models.EmailField(blank=True)
    twitter_url = models.URLField("Twitter URL", blank=True)
    instagram_url = models.URLField("Instagram URL", blank=True)

    # Wagtail search
    search_fields = (
        index.SearchField('first_name'),
        index.SearchField('last_name'),
        index.SearchField('role', partial_match=True),
        index.RelatedFields('production', [
            index.SearchField('title', partial_match=True),
        ]),
    )

    # Wagtail admin
    panels = [
        MultiFieldPanel([
            FieldPanel('first_name'),
            FieldPanel('last_name'),
            ImageChooserPanel('photo'),
        ], "Name and Photo"),
        MultiFieldPanel([
            PageChooserPanel('production', 'productions.ProductionPage'),
            FieldPanel('role'),
        ], "Production"),<commit_msg>Search team members by name only for now.<commit_after>from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver

from wagtail.wagtailadmin.edit_handlers import (
    FieldPanel,
    MultiFieldPanel,
    PageChooserPanel,
)
from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
from wagtail.wagtailsearch import index
from wagtail.wagtailsnippets.models import register_snippet

from productions.models import ProductionPageRelatedPerson


@register_snippet
class Person(models.Model, index.Indexed):
    first_name = models.CharField(max_length=255)
    last_name = models.CharField(max_length=255)
    role = models.CharField(max_length=255, blank=True)

    photo = models.ForeignKey(
        'localore_admin.LocaloreImage',
        null=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    production = models.ForeignKey(
        'productions.ProductionPage',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
        verbose_name="associated production",
        help_text="Leave blank for AIR/Localore staff."
    )

    biography = RichTextField(blank=True)

    email = models.EmailField(blank=True)
    twitter_url = models.URLField("Twitter URL", blank=True)
    instagram_url = models.URLField("Instagram URL", blank=True)

    # Wagtail search
    search_fields = (
        index.SearchField('first_name'),
        index.SearchField('last_name'),
    )

    # Wagtail admin
    panels = [
        MultiFieldPanel([
            FieldPanel('first_name'),
            FieldPanel('last_name'),
            ImageChooserPanel('photo'),
        ], "Name and Photo"),
        MultiFieldPanel([
            PageChooserPanel('production', 'productions.ProductionPage'),
            FieldPanel('role'),
        ], "Production"),
{'fraction_non_alphanumeric': 0.09776886437703686, 'fraction_numerical': 0.004512409125094008, 'mean_word_length': 3.2857142857142856, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1276661', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1130, 'n_words': 213}