How to use the otree.management.commands.update_my_code.Rule function in otree

To help you get started, we’ve selected a few otree examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oTree-org / otree-core / otree / management / commands / update_my_code.py View on Github external
# if they're using Django models, this won't work.
    Rule(
        '= models.CharField',
        '= models.StringField',
    ), # what about initial=None and default=None? maybe do a simple lookahead
    # if they're using Django models, this won't work.
    Rule(
        '= models.TextField',
        '= models.LongStringField',
    ), # what about initial=None and default=None?
    Rule(
        'form_model = models.Group',
        "form_model = 'group'",
        "change  to "
    ),
    Rule(
        'before_session_starts',
        'creating_session',
    ),
    # if they are using Django models, or if there are migrations, this won't work.
    # Rule(
    #     'verbose_name',
    #    'label',
    # ),
    Rule(
        'SliderInput',
        'Slider',
    )
]

TESTS_RULES = [
    Rule(
github oTree-org / otree-core / otree / management / commands / update_my_code.py View on Github external
self.print_rule_header()
        if os.path.isfile('.gitignore'):
            temp_wildcard = '__temp*'
            with open('.gitignore', 'r') as file:
                temp_wildcard_found = temp_wildcard in file.read()
            if not temp_wildcard_found:
                if dry_run:
                    self.print_change('ADD "__temp*" to .gitignore\n')
                else:
                    with open('.gitignore', 'a') as file:
                        file.write('\n' + temp_wildcard)

        self.print_rule_header()
        for fn in ['_templates/global/Base.html', '_templates/global/Page.html']:
            rule = Rule(
                '{% extends "otree/FormPage.html" %}',
                '{% extends "otree/Page.html" %}',
            )
            if os.path.isfile(fn):
                self.apply_rule_to_file(fn, rule)
github oTree-org / otree-core / otree / management / commands / update_my_code.py View on Github external
),
    Rule(
        'otree_tags',
        'otree',
    ),
    # someone might have created their own next button;
    # we don't want to break the selector for that.
    #Rule(
    #    '.next-button',
    #    '.otree-btn-next'
    #),
    Rule(
        '.otree-next-button',
        '.otree-btn-next'
    ),
    Rule(
        '#otree-body',
        '.otree-body'
    ),
    Rule(
        '#otree-title',
        '.otree-title'
    ),
    Rule(
        '#otree-timeout',
        '.otree-timer'
    ),
    Rule(
        '#otree-form-errors',
        '.otree-form-errors'
    ),
    # rarely used rules...will just slow things down
github oTree-org / otree-core / otree / management / commands / update_my_code.py View on Github external
'.otree-next-button',
        '.otree-btn-next'
    ),
    Rule(
        '#otree-body',
        '.otree-body'
    ),
    Rule(
        '#otree-title',
        '.otree-title'
    ),
    Rule(
        '#otree-timeout',
        '.otree-timer'
    ),
    Rule(
        '#otree-form-errors',
        '.otree-form-errors'
    ),
    # rarely used rules...will just slow things down
    #Rule(
    #    '#otree-wait-page-body',
    #    '.otree-wait-page'
    #),
    #Rule(
    #    '#otree-wait-page-title-text',
    #    '.otree-wait-page__title'
    #),
    #Rule(
    #    '#otree-wait-page-body-text',
    #    '.otree-wait-page__body'
    #),
github oTree-org / otree-core / otree / management / commands / update_my_code.py View on Github external
return line.replace(self.old_token, self.new_token)


PYTHON_RULES = [
    Rule(
        'form_model = models.Player',
        "form_model = 'player'",
        "change  to "
    ),
    # if they're using Django models, this won't work.
    Rule(
        '= models.CharField',
        '= models.StringField',
    ), # what about initial=None and default=None? maybe do a simple lookahead
    # if they're using Django models, this won't work.
    Rule(
        '= models.TextField',
        '= models.LongStringField',
    ), # what about initial=None and default=None?
    Rule(
        'form_model = models.Group',
        "form_model = 'group'",
        "change  to "
    ),
    Rule(
        'before_session_starts',
        'creating_session',
    ),
    # if they are using Django models, or if there are migrations, this won't work.
    # Rule(
    #     'verbose_name',
    #    'label',
github oTree-org / otree-core / otree / management / commands / update_my_code.py View on Github external
),
    # someone might have created their own next button;
    # we don't want to break the selector for that.
    #Rule(
    #    '.next-button',
    #    '.otree-btn-next'
    #),
    Rule(
        '.otree-next-button',
        '.otree-btn-next'
    ),
    Rule(
        '#otree-body',
        '.otree-body'
    ),
    Rule(
        '#otree-title',
        '.otree-title'
    ),
    Rule(
        '#otree-timeout',
        '.otree-timer'
    ),
    Rule(
        '#otree-form-errors',
        '.otree-form-errors'
    ),
    # rarely used rules...will just slow things down
    #Rule(
    #    '#otree-wait-page-body',
    #    '.otree-wait-page'
    #),
github oTree-org / otree-core / otree / management / commands / update_my_code.py View on Github external
#    '#otree-wait-page-title-text',
    #    '.otree-wait-page__title'
    #),
    #Rule(
    #    '#otree-wait-page-body-text',
    #    '.otree-wait-page__body'
    #),
]


PROCFILE_RULES = [
    Rule(
        'web: otree webandworkers',
        'web: otree runprodserver1of2',
    ),
    Rule(
        'timeoutworker: otree timeoutworker',
        'worker: otree runprodserver2of2',
    )
github oTree-org / otree-core / otree / management / commands / update_my_code.py View on Github external
#    '.next-button',
    #    '.otree-btn-next'
    #),
    Rule(
        '.otree-next-button',
        '.otree-btn-next'
    ),
    Rule(
        '#otree-body',
        '.otree-body'
    ),
    Rule(
        '#otree-title',
        '.otree-title'
    ),
    Rule(
        '#otree-timeout',
        '.otree-timer'
    ),
    Rule(
        '#otree-form-errors',
        '.otree-form-errors'
    ),
    # rarely used rules...will just slow things down
    #Rule(
    #    '#otree-wait-page-body',
    #    '.otree-wait-page'
    #),
    #Rule(
    #    '#otree-wait-page-title-text',
    #    '.otree-wait-page__title'
    #),
github oTree-org / otree-core / otree / management / commands / update_my_code.py View on Github external
Rule(
        'form_model = models.Player',
        "form_model = 'player'",
        "change  to "
    ),
    # if they're using Django models, this won't work.
    Rule(
        '= models.CharField',
        '= models.StringField',
    ), # what about initial=None and default=None? maybe do a simple lookahead
    # if they're using Django models, this won't work.
    Rule(
        '= models.TextField',
        '= models.LongStringField',
    ), # what about initial=None and default=None?
    Rule(
        'form_model = models.Group',
        "form_model = 'group'",
        "change  to "
    ),
    Rule(
        'before_session_starts',
        'creating_session',
    ),
    # if they are using Django models, or if there are migrations, this won't work.
    # Rule(
    #     'verbose_name',
    #    'label',
    # ),
    Rule(
        'SliderInput',
        'Slider',
github oTree-org / otree-core / otree / management / commands / update_my_code.py View on Github external
'pages',
        'fix references to views.py'
    ),
]

HTML_RULES = [
    Rule(
        '{% load otreechat %}',
        ''
    ),
    Rule(
        'with label=',
        'label=',
        'remove unnecessary "with" in formfield tag'
    ),
    Rule(
        'otree_tags',
        'otree',
    ),
    # someone might have created their own next button;
    # we don't want to break the selector for that.
    #Rule(
    #    '.next-button',
    #    '.otree-btn-next'
    #),
    Rule(
        '.otree-next-button',
        '.otree-btn-next'
    ),
    Rule(
        '#otree-body',
        '.otree-body'