Example #1
0
def make_solution_formset(envUser, userSolutions, subenvs, singleSubEnv=False):
    SolutionForm = make_special_solution_form(envUser, subenvs, singleSubEnv)
    solutions = userSolutions.filter(subEnvironment__in=subenvs)
    BaseSolutionFormSet = make_base_custom_formset(solutions)
    return modelformset_factory(Solution,
                                form=SolutionForm,
                                formset=BaseSolutionFormSet)
Example #2
0
def make_single_solution_formset(SolutionForm, solution, **kwargs):
    solutions = Solution.objects.filter(pk=solution.pk)
    BaseSolutionFormSet = make_base_custom_formset(solutions)
    return modelformset_factory(Solution,
                                form=SolutionForm,
                                formset=BaseSolutionFormSet,
                                **kwargs)
Example #3
0
def make_base_schedule_formset(queryset):
    BaseCustomFormset = make_base_custom_formset(queryset)

    class BaseScheduleFormSet(BaseCustomFormset):
        def clean(self):
            if any(self.errors):
                return
            schedule = defaultdict(lambda: [ ])
            for form in self.forms:
                cleaned_data = form.cleaned_data
                if cleaned_data and not cleaned_data.get('DELETE', False):
                    step = cleaned_data['step']
                    schedule[step].append(cleaned_data)
            for step, entries in schedule.iteritems():
                print [ entry['solution'] for entry in entries ]
            #print schedule
            super(BaseScheduleFormSet, self).clean()

    return BaseScheduleFormSet
Example #4
0
def make_base_schedule_formset(queryset):
    BaseCustomFormset = make_base_custom_formset(queryset)

    class BaseScheduleFormSet(BaseCustomFormset):
        def clean(self):
            if any(self.errors):
                return
            schedule = defaultdict(lambda: [])
            for form in self.forms:
                cleaned_data = form.cleaned_data
                if cleaned_data and not cleaned_data.get('DELETE', False):
                    step = cleaned_data['step']
                    schedule[step].append(cleaned_data)
            for step, entries in schedule.iteritems():
                print[entry['solution'] for entry in entries]
            #print schedule
            super(BaseScheduleFormSet, self).clean()

    return BaseScheduleFormSet