<commit_before>from django import forms
from django.db.models import Q
from django.utils.translation import ugettext as _
from django.core.cache import cache
from publications.settings import PUBLICATIONS_CACHE_DURATION

from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool

from arkestra_utilities.generic_models import ArkestraGenericPlugin, ArkestraGenericPluginForm
from arkestra_utilities.admin_mixins import AutocompleteMixin

from contacts_and_people.templatetags.entity_tags import work_out_entity

from models import PublicationsPlugin, BibliographicRecord, PublicationsPlugin
from menu import menu_dict

from datetime import datetime

class PublicationsPluginForm(ArkestraGenericPluginForm, forms.ModelForm):
    pass
    

PUBLICATION_INFORMATION = (
    {
        "type": "journal-article",
        "kind": "articles",
        "name": "Articles", 
        },{
        "type": "book",
        "kind": "books",
        "name": "Books", 
        },{
        "type": "chapter",
        "kind": "chapters",
        "name": "Chapters", 
        },{
        "type": "conference-proceeding",
        "kind": "conference-proceedings",
        "name": "Conference proceedings", 
        },{
        "type": "monograph",
        "kind": "monographs",
        "name": "Monographs", 
        },{
        "type": "report",
        "kind": "reports",
        "name": "Reports", 
    },       
  )

class CMSPublicationsPlugin(ArkestraGenericPlugin, CMSPluginBase):
    name = _("Publications")
    model = PublicationsPlugin
    render_template = "publications/publications.html"
    # grab and use the menu_dict
    menu_cues = menu_dict

    # autocomplete fields
    related_search_fields = ['entity',]

    # render() runs the methods below in order
    
    def set_defaults(self, instance):
        # set defaults
        # ** important ** - these are set only when the render() function is called
        instance.favourites_only = getattr(instance, "favourites_only", False)<commit_msg>autocomplete working for publications plugin<commit_after>from django import forms
from django.db.models import Q
from django.utils.translation import ugettext as _
from django.core.cache import cache
from publications.settings import PUBLICATIONS_CACHE_DURATION

from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool

from arkestra_utilities.generic_models import ArkestraGenericPlugin, ArkestraGenericPluginForm
from arkestra_utilities.admin_mixins import AutocompleteMixin

from contacts_and_people.templatetags.entity_tags import work_out_entity

from models import PublicationsPlugin, BibliographicRecord, PublicationsPlugin
from menu import menu_dict

from datetime import datetime

class PublicationsPluginForm(ArkestraGenericPluginForm, forms.ModelForm):
    pass
    

PUBLICATION_INFORMATION = (
    {
        "type": "journal-article",
        "kind": "articles",
        "name": "Articles", 
        },{
        "type": "book",
        "kind": "books",
        "name": "Books", 
        },{
        "type": "chapter",
        "kind": "chapters",
        "name": "Chapters", 
        },{
        "type": "conference-proceeding",
        "kind": "conference-proceedings",
        "name": "Conference proceedings", 
        },{
        "type": "monograph",
        "kind": "monographs",
        "name": "Monographs", 
        },{
        "type": "report",
        "kind": "reports",
        "name": "Reports", 
    },       
  )

class CMSPublicationsPlugin(ArkestraGenericPlugin, AutocompleteMixin, CMSPluginBase):
    name = _("Publications")
    model = PublicationsPlugin
    render_template = "publications/publications.html"
    # grab and use the menu_dict
    menu_cues = menu_dict

    # autocomplete fields
    related_search_fields = ['entity',]

    # render() runs the methods below in order
    
    def set_defaults(self, instance):
        # set defaults
        # ** important ** - these are set only when the render() function is called
        instance.favourites_only = getattr(instance, "favourites_only", False)
{'fraction_non_alphanumeric': 0.1, 'fraction_numerical': 0.0, 'mean_word_length': 3.2262396694214877, 'pattern_counts': {'":': 36, '<': 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': '4010383', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1131, 'n_words': 294}