<commit_before># -*- coding: utf-8 -*-
from crispy_forms.bootstrap import FormActions
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Submit
from django import forms
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _

from clock.contracts.models import Contract


class ContractForm(forms.ModelForm):
    class Meta:
        model = Contract
        fields = (
            'department',
            'department_short',
            'hours', )

    def __init__(self, *args, **kwargs):
        super(ContractForm, self).__init__(*args, **kwargs)

        # Retrieve current user, supplied by the view
        self.requested_user = self.initial['user']

        delete_html_inject = ""

        # Determine if we're creating a new shift or updating an existing one
        if self.initial['view'] == 'contract_create':
            add_input_text = _('Create new contract')
        elif self.initial['view'] == 'contract_update':
            add_input_text = _('Update contract')
            delete_html_inject = '<a href="{}" class="{}">{}</a>'.format(
                reverse_lazy(
                    'contract:delete', kwargs={'pk': self.instance.pk}),
                'btn btn-danger pull-right second-button', _('Delete'))

        cancel_html_inject = '<a href="{}" class="{}">{}</a>'.format(
            reverse_lazy('contract:list'), 'btn btn-default', _('Cancel'))

        self.helper = FormHelper(self)
        self.helper.form_action = '.'
        self.helper.form_method = 'post'
        self.helper.layout.append(
            FormActions(
                HTML(cancel_html_inject),
                Submit(
                    'submit',
                    add_input_text,
                    css_class='btn btn-primary pull-right'),
                HTML(delete_html_inject), ))<commit_msg>Start working on the contract<commit_after># -*- coding: utf-8 -*-
from crispy_forms.bootstrap import FormActions
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Field, Layout, Submit
from django import forms
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _

from clock.contracts.models import Contract


class ContractForm(forms.ModelForm):
    class Meta:
        model = Contract
        fields = (
            'department',
            'start_date',
            'end_date',
            'hours',
        )

    def __init__(self, *args, **kwargs):
        super(ContractForm, self).__init__(*args, **kwargs)

        # Retrieve current user, supplied by the view
        self.requested_user = self.initial['user']

        delete_html_inject = ""

        # Determine if we're creating a new shift or updating an existing one
        if self.initial['view'] == 'contract_create':
            add_input_text = _('Create new contract')
        elif self.initial['view'] == 'contract_update':
            add_input_text = _('Update contract')
            delete_html_inject = '<a href="{}" class="{}">{}</a>'.format(
                reverse_lazy(
                    'contract:delete', kwargs={'pk': self.instance.pk}
                ), 'btn btn-danger pull-right second-button', _('Delete')
            )

        cancel_html_inject = '<a href="{}" class="{}">{}</a>'.format(
            reverse_lazy('contract:list'), 'btn btn-default', _('Cancel')
        )

        self.helper = FormHelper(self)
        self.helper.form_action = '.'
        self.helper.form_method = 'post'
        self.helper.layout = Layout(
            Field('department'),
            Field(
                'start_date',
                template='shift/fields/datetimepicker_field.html'
            ), Field('end_date'), Field('hours')
        )
        self.helper.layout.append(
            FormActions(
                HTML(cancel_html_inject),
                Submit(
                    'submit',
                    add_input_text,
                    css_class='btn btn-primary pull-right'
                ),
                HTML(delete_html_inject),
            )
        )
{'fraction_non_alphanumeric': 0.11873479318734793, 'fraction_numerical': 0.00048661800486618007, 'mean_word_length': 2.1026415094339623, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '6780479', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1088, 'n_words': 257}