from haystack import indexes
from .models import Person, Project, WorkingGroup, NetworkGroup


class PersonIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    twitter = indexes.CharField(model_attr='twitter')
    url = indexes.CharField(model_attr='url')

    def get_model(self):
        return Person


class ProjectIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    twitter = indexes.CharField(model_attr='twitter')
    homepage_url = indexes.CharField(model_attr='homepage_url')
    mailinglist_url = indexes.CharField(model_attr='mailinglist_url')
    sourcecode_url = indexes.CharField(model_attr='sourcecode_url')

    def get_model(self):
        return Project


class WorkingGroupIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    incubation = indexes.BooleanField(model_attr='incubation')

    def get_model(self):
        return WorkingGroup


class NetworkGroupIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    mailinglist = indexes.CharField(model_attr='mailinglist')
    homepage = indexes.CharField(model_attr='homepage')
    twitter = indexes.CharField(model_attr='twitter')

    def get_model(self):
        return NetworkGroup

from haystack import indexes
from .models import Person, Project, WorkingGroup, NetworkGroup


class PersonIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    twitter = indexes.CharField(model_attr='twitter')
    url = indexes.CharField(model_attr='url')

    def get_model(self):
        return Person


class ProjectIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    twitter = indexes.CharField(model_attr='twitter')
    homepage_url = indexes.CharField(model_attr='homepage_url')
    mailinglist_url = indexes.CharField(model_attr='mailinglist_url')
    sourcecode_url = indexes.CharField(model_attr='sourcecode_url')

    def get_model(self):
        return Project


class WorkingGroupIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    incubation = indexes.BooleanField(model_attr='incubation')

    def get_model(self):
        return WorkingGroup


class NetworkGroupIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    twitter = indexes.CharField(model_attr='twitter')
    homepage_url = indexes.CharField(model_attr='homepage_url')
    mailinglist_url = indexes.CharField(model_attr='mailinglist_url')

    def get_model(self):
        return NetworkGroup

Fix references to old model fields
organisation: Fix references to old model fields

  from haystack import indexes
  from .models import Person, Project, WorkingGroup, NetworkGroup
  
  
  class PersonIndex(indexes.SearchIndex, indexes.Indexable):
      text = indexes.CharField(document=True, use_template=True)
      twitter = indexes.CharField(model_attr='twitter')
      url = indexes.CharField(model_attr='url')
  
      def get_model(self):
          return Person
  
  
  class ProjectIndex(indexes.SearchIndex, indexes.Indexable):
      text = indexes.CharField(document=True, use_template=True)
      twitter = indexes.CharField(model_attr='twitter')
      homepage_url = indexes.CharField(model_attr='homepage_url')
      mailinglist_url = indexes.CharField(model_attr='mailinglist_url')
      sourcecode_url = indexes.CharField(model_attr='sourcecode_url')
  
      def get_model(self):
          return Project
  
  
  class WorkingGroupIndex(indexes.SearchIndex, indexes.Indexable):
      text = indexes.CharField(document=True, use_template=True)
      incubation = indexes.BooleanField(model_attr='incubation')
  
      def get_model(self):
          return WorkingGroup
  
  
  class NetworkGroupIndex(indexes.SearchIndex, indexes.Indexable):
      text = indexes.CharField(document=True, use_template=True)
-     mailinglist = indexes.CharField(model_attr='mailinglist')
-     homepage = indexes.CharField(model_attr='homepage')
      twitter = indexes.CharField(model_attr='twitter')
+     homepage_url = indexes.CharField(model_attr='homepage_url')
+     mailinglist_url = indexes.CharField(model_attr='mailinglist_url')
  
      def get_model(self):
          return NetworkGroup
  
Fix references to old model fields
## Code Before:
from haystack import indexes
from .models import Person, Project, WorkingGroup, NetworkGroup


class PersonIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    twitter = indexes.CharField(model_attr='twitter')
    url = indexes.CharField(model_attr='url')

    def get_model(self):
        return Person


class ProjectIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    twitter = indexes.CharField(model_attr='twitter')
    homepage_url = indexes.CharField(model_attr='homepage_url')
    mailinglist_url = indexes.CharField(model_attr='mailinglist_url')
    sourcecode_url = indexes.CharField(model_attr='sourcecode_url')

    def get_model(self):
        return Project


class WorkingGroupIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    incubation = indexes.BooleanField(model_attr='incubation')

    def get_model(self):
        return WorkingGroup


class NetworkGroupIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    mailinglist = indexes.CharField(model_attr='mailinglist')
    homepage = indexes.CharField(model_attr='homepage')
    twitter = indexes.CharField(model_attr='twitter')

    def get_model(self):
        return NetworkGroup

## Instruction:
Fix references to old model fields
## Code After:
from haystack import indexes
from .models import Person, Project, WorkingGroup, NetworkGroup


class PersonIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    twitter = indexes.CharField(model_attr='twitter')
    url = indexes.CharField(model_attr='url')

    def get_model(self):
        return Person


class ProjectIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    twitter = indexes.CharField(model_attr='twitter')
    homepage_url = indexes.CharField(model_attr='homepage_url')
    mailinglist_url = indexes.CharField(model_attr='mailinglist_url')
    sourcecode_url = indexes.CharField(model_attr='sourcecode_url')

    def get_model(self):
        return Project


class WorkingGroupIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    incubation = indexes.BooleanField(model_attr='incubation')

    def get_model(self):
        return WorkingGroup


class NetworkGroupIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    twitter = indexes.CharField(model_attr='twitter')
    homepage_url = indexes.CharField(model_attr='homepage_url')
    mailinglist_url = indexes.CharField(model_attr='mailinglist_url')

    def get_model(self):
        return NetworkGroup
