<commit_before>from math import isnan

from django.forms import ModelForm
from django.contrib.gis.geos import LineString
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _

import floppyforms as forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Field, Submit, Div
from crispy_forms.bootstrap import FormActions

from .models import Path
from .widgets import LineStringWidget


class PathForm(ModelForm):
    geom = forms.gis.LineStringField(widget=LineStringWidget)

    reverse_geom = forms.BooleanField(
           required=False,
           label = _("Reverse geometry"),
           help_text = _("The geometry will be reversed once saved"),
       )

    helper = FormHelper()
    helper.form_class = 'form-horizontal'
    helper.layout = Layout(
        Div('name',
            'structure',
            'stake',
            'trail',
            Field('comments', css_class='input-xlarge'),
            'datasource',
            'networks',
            'usages',
            'valid',
            'reverse_geom',
            css_class="span4",
        ),
        Div('geom',
            css_class="span7",),
        FormActions(
            Submit('cancel', 'Cancel'),
            Submit('save_changes', _('Save changes'), css_class="btn-primary offset1"),
            css_class="form-actions span11",
        )
    )

    def __init__(self, *args, **kwargs):
        super(PathForm, self).__init__(*args, **kwargs)<commit_msg>Move reverse along with geometry<commit_after>from math import isnan

from django.forms import ModelForm
from django.contrib.gis.geos import LineString
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _

import floppyforms as forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Field, Submit, Div
from crispy_forms.bootstrap import FormActions

from .models import Path
from .widgets import LineStringWidget


class PathForm(ModelForm):
    geom = forms.gis.LineStringField(widget=LineStringWidget)

    reverse_geom = forms.BooleanField(
           required=False,
           label = _("Reverse path"),
           help_text = _("The path will be reversed once saved"),
       )

    helper = FormHelper()
    helper.form_class = 'form-horizontal'
    helper.layout = Layout(
        Div('name',
            'structure',
            'stake',
            'trail',
            Field('comments', css_class='input-xlarge'),
            'datasource',
            'networks',
            'usages',
            'valid',
            
            css_class="span4",
        ),
        Div('geom',
            'reverse_geom',
            css_class="span7",),
        FormActions(
            Submit('cancel', 'Cancel'),
            Submit('save_changes', _('Save changes'), css_class="btn-primary offset1"),
            css_class="form-actions span11",
        )
    )

    def __init__(self, *args, **kwargs):
        super(PathForm, self).__init__(*args, **kwargs)
{'fraction_non_alphanumeric': 0.10450685826257348, 'fraction_numerical': 0.0032658393207054214, 'mean_word_length': 2.4965753424657535, 'pattern_counts': {'":': 0, '<': 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': '5177394', 'n_tokens_mistral': 861, 'n_tokens_neox': 833, 'n_words': 209}