Exemplo n.º 1
0
 def create_new_formset(from_date, to_date, request):
     WorkEntryFormSet = forms.formset_factory(
         MonthlyReportView.WorkEntry,
         extra=1,
         max_num=60,
         can_delete=True,
         formset=MonthlyReportView.BaseWorkEntryFormset)
     employee = UserExtension.get_user(request.user)
     initial_formset_data = MonthlyReportView.generate_initial_data(
         from_date, to_date, employee)
     form_kwargs = MonthlyReportView.compose_form_kwargs(from_date, to_date)
     formset = WorkEntryFormSet(initial=initial_formset_data,
                                form_kwargs=form_kwargs)
     return formset
Exemplo n.º 2
0
 def update_work(form, request):
     from koalixcrm.crm.reporting.work import Work
     if form.has_changed():
         if form.cleaned_data['work_id']:
             work = Work.objects.get(id=form.cleaned_data['work_id'])
         else:
             work = Work()
         if form.cleaned_data['DELETE']:
             work.delete()
         else:
             work.task = form.cleaned_data['task']
             work.employee = UserExtension.get_user(request.user)
             work.date = form.cleaned_data['date']
             work.start_time = datetime.datetime.combine(
                 form.cleaned_data['date'], form.cleaned_data['start_time'])
             work.stop_time = datetime.datetime.combine(
                 form.cleaned_data['date'], form.cleaned_data['stop_time'])
             work.short_description = form.cleaned_data['short_description']
             work.save()