<commit_before># -*- coding: utf-8 -*-
import datetime
from django.http import HttpResponseRedirect, Http404
from django.shortcuts import render
from django.template.context_processors import csrf
from django.contrib.admin.widgets import *
from django.forms import NumberInput
from django.contrib.auth.decorators import login_required
from koalixcrm.djangoUserExtension.models import UserExtension
from koalixcrm.crm.reporting.task import Task
from koalixcrm.crm.reporting.project import Project
from koalixcrm.crm.reporting.reporting_period import ReportingPeriod
from koalixcrm.crm.exceptions import ReportingPeriodNotFound
from koalixcrm.djangoUserExtension.exceptions import UserExtensionMissing, TooManyUserExtensionsAvailable
from koalixcrm.globalSupportFunctions import limit_string_length


class RangeSelectionForm(forms.Form):
    from_date = forms.DateField(widget=AdminDateWidget)
    to_date = forms.DateField(widget=AdminDateWidget)
    original_from_date = forms.DateField(widget=forms.HiddenInput(), required=False)
    original_to_date = forms.DateField(widget=forms.HiddenInput(), required=False)


class BaseWorkEntryFormset(forms.models.BaseFormSet):
    def __init__(self,*args, **kwargs):
        super(BaseWorkEntryFormset, self).__init__(*args, **kwargs)


class WorkEntry(forms.Form):
    project = forms.ModelChoiceField(queryset=Project.objects.filter(reportingperiod__status__is_done=False),
                                     required=True)
    task = forms.ModelChoiceField(queryset=Task.objects.filter(status__is_done=False),
                                  required=True)
    date = forms.DateField(widget=AdminDateWidget, required=True)
    start_time = forms.TimeField(widget=AdminTimeWidget)
    stop_time = forms.TimeField(widget=AdminTimeWidget)
    description = forms.CharField(widget=AdminTextareaWidget, required=True)
    work_id = forms.IntegerField(widget=forms.HiddenInput(), required=False)

    def __init__(self, *args, **kwargs):
        self.from_date = kwargs.pop('from_date')
        self.to_date = kwargs.pop('to_date')
        self.original_from_date = self.from_date
        self.original_to_date = self.to_date<commit_msg>[Issue #162, 163] started to work on these two issue, defined the field for the worked hours<commit_after># -*- coding: utf-8 -*-
import datetime
from django.http import HttpResponseRedirect, Http404
from django.shortcuts import render
from django.template.context_processors import csrf
from django.contrib.admin.widgets import *
from django.forms import NumberInput
from django.contrib.auth.decorators import login_required
from koalixcrm.djangoUserExtension.models import UserExtension
from koalixcrm.crm.reporting.task import Task
from koalixcrm.crm.reporting.project import Project
from koalixcrm.crm.reporting.reporting_period import ReportingPeriod
from koalixcrm.crm.exceptions import ReportingPeriodNotFound
from koalixcrm.djangoUserExtension.exceptions import UserExtensionMissing, TooManyUserExtensionsAvailable
from koalixcrm.globalSupportFunctions import limit_string_length


class RangeSelectionForm(forms.Form):
    from_date = forms.DateField(widget=AdminDateWidget)
    to_date = forms.DateField(widget=AdminDateWidget)
    original_from_date = forms.DateField(widget=forms.HiddenInput(), required=False)
    original_to_date = forms.DateField(widget=forms.HiddenInput(), required=False)


class BaseWorkEntryFormset(forms.models.BaseFormSet):
    def __init__(self,*args, **kwargs):
        super(BaseWorkEntryFormset, self).__init__(*args, **kwargs)


class WorkEntry(forms.Form):
    project = forms.ModelChoiceField(queryset=Project.objects.filter(reportingperiod__status__is_done=False),
                                     required=True)
    task = forms.ModelChoiceField(queryset=Task.objects.filter(status__is_done=False),
                                  required=True)
    date = forms.DateField(widget=AdminDateWidget, required=True)
    start_time = forms.TimeField(widget=AdminTimeWidget)
    stop_time = forms.TimeField(widget=AdminTimeWidget)
    description = forms.CharField(widget=AdminTextareaWidget, required=True)
    work_id = forms.IntegerField(widget=forms.HiddenInput(), required=False)
    '''    worked_hours = forms.DecimalField(widget=NumberInput(attrs={'step': 0.1,
                                                                'min': 0,
                                                                'max': 24}),
                                             required=False)'''

    def __init__(self, *args, **kwargs):
        self.from_date = kwargs.pop('from_date')
        self.to_date = kwargs.pop('to_date')
        self.original_from_date = self.from_date
        self.original_to_date = self.to_date
{'fraction_non_alphanumeric': 0.08709405314213411, 'fraction_numerical': 0.004006748207507381, 'mean_word_length': 4.0945220193340495, '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': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3501770', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1283, 'n_words': 245}