# Path: td_biblio/models.py
# class Author(AbstractHuman):
#     """Entry author"""
# 
#     class Meta:
#         ordering = ("last_name", "first_name")
#         verbose_name = _("Author")
#         verbose_name_plural = _("Authors")


from operator import methodcaller
from django import forms
from django.core.validators import RegexValidator
from django.utils.translation import ugettext_lazy as _
from td_biblio.models import Author
    )

    def clean_pmids(self):
        """Transform raw data in a PMID list"""
        pmids = text_to_list(self.cleaned_data["pmids"])
        for pmid in pmids:
            pmid_validator(pmid)
        return pmids

    def clean_dois(self):
        """Transform raw data in a DOI list"""
        dois = text_to_list(self.cleaned_data["dois"])
        for doi in dois:
            doi_validator(doi)
        return dois

    def clean(self):
        super(EntryBatchImportForm, self).clean()

        dois = self.cleaned_data.get("dois", [])
        pmids = self.cleaned_data.get("pmids", [])

        if not len(dois) and not len(pmids):
            raise forms.ValidationError(
                _("You need to submit at least one valid DOI or PMID")
            )


class AuthorDuplicatesForm(forms.Form):
    def get_authors_choices():

# Path: td_biblio/models.py
# class Author(AbstractHuman):
#     """Entry author"""
# 
#     class Meta:
#         ordering = ("last_name", "first_name")
#         verbose_name = _("Author")
#         verbose_name_plural = _("Authors")


# Path: td_biblio/forms.py
from operator import methodcaller
from django import forms
from django.core.validators import RegexValidator
from django.utils.translation import ugettext_lazy as _
from td_biblio.models import Author

    )

    def clean_pmids(self):
        """Transform raw data in a PMID list"""
        pmids = text_to_list(self.cleaned_data["pmids"])
        for pmid in pmids:
            pmid_validator(pmid)
        return pmids

    def clean_dois(self):
        """Transform raw data in a DOI list"""
        dois = text_to_list(self.cleaned_data["dois"])
        for doi in dois:
            doi_validator(doi)
        return dois

    def clean(self):
        super(EntryBatchImportForm, self).clean()

        dois = self.cleaned_data.get("dois", [])
        pmids = self.cleaned_data.get("pmids", [])

        if not len(dois) and not len(pmids):
            raise forms.ValidationError(
                _("You need to submit at least one valid DOI or PMID")
            )


class AuthorDuplicatesForm(forms.Form):
    def get_authors_choices():

        return Author.objects.values_list("id", "last_name")