from typing import List, Set, Tuple import re import decimal import logging import operator import inspect from urllib.parse import unquote, urlsplit from html.parser import HTMLParser import otree.constants from django.urls import resolve from django.conf import settings from otree.currency import Currency from otree.models import Participant, Session from otree import common from otree.common import ( get_dotted_name, get_bots_module, get_admin_secret_code, get_models_module, ) from otree.db import idmap ADMIN_SECRET_CODE = get_admin_secret_code() logger = logging.getLogger('otree.bots') INTERNAL_FORM_FIELDS = { 'csrfmiddlewaretoken', 'must_fail', 'timeout_happened', 'admin_secret_code', 'error_fields', } DISABLE_CHECK_HTML_INSTRUCTIONS = ''' Checking the HTML may not find all form fields and buttons (e.g. those added with JavaScript), so you can disable this check by yielding a Submission with check_html=False, e.g.: yield Submission(views.PageName, {{...}}, check_html=False) ''' HTML_MISSING_BUTTON_WARNING = ( ( ''' Bot is trying to submit page {page_name}, but no button was found in the HTML of the page. (searched for with type='submit' or