<commit_before>from copy import deepcopy
from portality.lib.formulaic import Formulaic, WTFormsBuilder

from wtforms import StringField, TextAreaField, IntegerField, BooleanField, RadioField, SelectMultipleField, SelectField, \
    FormField, FieldList, HiddenField
from wtforms import widgets, validators
from wtforms.widgets.core import html_params, HTMLString

from portality import regex
from portality.formcontext.fields import TagListField
from portality.crosswalks.application_form import ApplicationFormXWalk
from portality.crosswalks.journal_form import JournalFormXWalk
from portality.forms import application_processors
from portality.forms.validate import (
    HTTPURL,
    OptionalIf,
    ExclusiveCheckbox,
    ExtraFieldRequiredIf,
    MaxLen,
    RegexpOnTagList,
    ReservedUsernames,
    StopWords,
    ISSNInPublicDOAJ,
    JournalURLInPublicDOAJ,
    DifferentTo,
    RequiredIfOtherValue,
    OnlyIf,
    NotIf,
    GroupMember,
    RequiredValue,
    BigEndDate,
    ReservedUsernames,
    CustomRequired
)

from portality.datasets import language_options, country_options, currency_options
from portality.core import app
from portality.regex import ISSN, ISSN_COMPILED
from portality import constants
from portality.models import EditorGroup

# Stop words used in the keywords field
STOP_WORDS = [
    "open access",
    "high quality",
    "peer-reviewed",
    "peer-review",
    "peer review",
    "quality",
    "multidisciplinary",
    "interdisciplinary",
    "journal",
    "scholarly journal",
    "open science",
    "impact factor",
    "scholarly",
    "research journal"
]

########################################################
# Define all our individual fields
########################################################

class FieldDefinitions:
    BOAI = {
        "name": "boai",
        "label": "Does the journal adhere to this definition of open access?",
        "input": "radio",
        "options": [
            {"display": "Yes", "value": "y"},
            {"display": "No", "value": "n"}
        ],
        "help": {
            "long_help": ['This definition follows the definition of Libre Open Access formulated by <NAME> <br>'
                          "<a href='http://nrs.harvard.edu/urn-3:HUL.InstRepos:4322580' target='_blank' >http://nrs.harvard.edu/urn-3:HUL.InstRepos:4322580</a>"],
            "doaj_criteria": "You must answer 'Yes'"
        },
        "validate": [
            {"required": {"message": "You must answer YES to continue"}},
            {"required_value" : {"value" : "y"}}
        ],
        "contexts": {
            "editor": {
                "disabled": True
            },
            "associate_editor": {
                "disabled": True
            }
        },
        "asynchronous_warnings": [
            {"value_must_be": {"value": "y"}}
        ]
    }

    OA_STATEMENT_URL = {
        "name": "oa_statement_url",
        "label": "The journal website must display its open access statement. Where can we find this information?",
        "input": "text",
        "help": {
            "long_help": ["Here is an example of a suitable Open Access statement that meets our criteria:<blockquote>"
                          "This is an open access journal which means that all content is freely available without charge"
                          "to the user or his/her institution. Users are allowed to read, download, copy, distribute,"
                          "print, search, or link to the full texts of the articles, or use them for any other lawful"
                          "purpose, without asking prior permission from the publisher or the author. This is in accordance"
                          "with the BOAI definition of open access.</blockquote>"],
            "short_help": "Link to the journal’s open access statement",
            "placeholder": "https://www.my-journal.com/open-access"
        },
        "validate": [
            "required",<commit_msg>make boai question optional for editorial use cases<commit_after>from copy import deepcopy
from portality.lib.formulaic import Formulaic, WTFormsBuilder

from wtforms import StringField, TextAreaField, IntegerField, BooleanField, RadioField, SelectMultipleField, SelectField, \
    FormField, FieldList, HiddenField
from wtforms import widgets, validators
from wtforms.widgets.core import html_params, HTMLString

from portality import regex
from portality.formcontext.fields import TagListField
from portality.crosswalks.application_form import ApplicationFormXWalk
from portality.crosswalks.journal_form import JournalFormXWalk
from portality.forms import application_processors
from portality.forms.validate import (
    HTTPURL,
    OptionalIf,
    ExclusiveCheckbox,
    ExtraFieldRequiredIf,
    MaxLen,
    RegexpOnTagList,
    ReservedUsernames,
    StopWords,
    ISSNInPublicDOAJ,
    JournalURLInPublicDOAJ,
    DifferentTo,
    RequiredIfOtherValue,
    OnlyIf,
    NotIf,
    GroupMember,
    RequiredValue,
    BigEndDate,
    ReservedUsernames,
    CustomRequired
)

from portality.datasets import language_options, country_options, currency_options
from portality.core import app
from portality.regex import ISSN, ISSN_COMPILED
from portality import constants
from portality.models import EditorGroup

# Stop words used in the keywords field
STOP_WORDS = [
    "open access",
    "high quality",
    "peer-reviewed",
    "peer-review",
    "peer review",
    "quality",
    "multidisciplinary",
    "interdisciplinary",
    "journal",
    "scholarly journal",
    "open science",
    "impact factor",
    "scholarly",
    "research journal"
]

########################################################
# Define all our individual fields
########################################################

class FieldDefinitions:
    BOAI = {
        "name": "boai",
        "label": "Does the journal adhere to this definition of open access?",
        "input": "radio",
        "options": [
            {"display": "Yes", "value": "y"},
            {"display": "No", "value": "n"}
        ],
        "help": {
            "long_help": ['This definition follows the definition of Libre Open Access formulated by <NAME> <br>'
                          "<a href='http://nrs.harvard.edu/urn-3:HUL.InstRepos:4322580' target='_blank' >http://nrs.harvard.edu/urn-3:HUL.InstRepos:4322580</a>"],
            "doaj_criteria": "You must answer 'Yes'"
        },
        "validate": [
            {"required": {"message": "You must answer YES to continue"}},
            {"required_value" : {"value" : "y"}}
        ],
        "contexts": {
            "admin" : {
                "validate" : []
            },
            "editor": {
                "validate" : [],
                "disabled": True
            },
            "associate_editor": {
                "validate" : [],
                "disabled": True
            }
        },
        "asynchronous_warnings": [
            {"value_must_be": {"value": "y"}}
        ]
    }

    OA_STATEMENT_URL = {
        "name": "oa_statement_url",
        "label": "The journal website must display its open access statement. Where can we find this information?",
        "input": "text",
        "help": {
            "long_help": ["Here is an example of a suitable Open Access statement that meets our criteria:<blockquote>"
                          "This is an open access journal which means that all content is freely available without charge"
                          "to the user or his/her institution. Users are allowed to read, download, copy, distribute,"
                          "print, search, or link to the full texts of the articles, or use them for any other lawful"
                          "purpose, without asking prior permission from the publisher or the author. This is in accordance"
                          "with the BOAI definition of open access.</blockquote>"],
            "short_help": "Link to the journal’s open access statement",
            "placeholder": "https://www.my-journal.com/open-access"
        },
        "validate": [
            "required",
{'fraction_non_alphanumeric': 0.12421364253114592, 'fraction_numerical': 0.003947206118169483, 'mean_word_length': 2.598757212605415, 'pattern_counts': {'":': 60, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1992705', 'n_tokens_mistral': 2195, 'n_tokens_neox': 2113, 'n_words': 658}