Example #1
0
    def test_post_volume_edition_formset_container(self):
        self.data_forms.update({
            **get_valid_formset_data(self.learning_unit_year_partim.acronym,
                                     is_partim=True), 'postponement':
            1
        })

        volume_edition_formset_container = VolumeEditionFormsetContainer(
            self.request_factory.post(None, data=self.data_forms),
            self.learning_units_with_context, self.central_manager)

        self.assertTrue(volume_edition_formset_container.is_valid())

        volume_edition_formset_container.save()
Example #2
0
    def test_post_volume_edition_formset_container(self):
        request_factory = RequestFactory()

        data_forms = get_valid_formset_data(
            self.learning_unit_year_full.acronym)
        data_forms.update(
            get_valid_formset_data(self.learning_unit_year_partim.acronym,
                                   is_partim=True))

        volume_edition_formset_container = VolumeEditionFormsetContainer(
            request_factory.post(None, data=data_forms),
            self.learning_units_with_context, self.central_manager)

        self.assertTrue(volume_edition_formset_container.is_valid())

        volume_edition_formset_container.save(1)
Example #3
0
def learning_unit_volumes_management(request, learning_unit_year_id):
    person = get_object_or_404(Person, user=request.user)
    context = get_common_context_learning_unit_year(learning_unit_year_id,
                                                    person)

    context[
        'learning_units'] = learning_unit_year_with_context.get_with_context(
            learning_container_year_id=context['learning_unit_year'].
            learning_container_year_id)

    volume_edition_formset_container = VolumeEditionFormsetContainer(
        request, context['learning_units'], person)

    if volume_edition_formset_container.is_valid() and not request.is_ajax():
        try:
            postponement = int(request.POST.get('postponement', 1))
            volume_edition_formset_container.save(postponement)
            display_success_messages(request,
                                     _('success_modification_learning_unit'))
            return HttpResponseRedirect(
                reverse(learning_unit_components,
                        args=[learning_unit_year_id]))

        except IntegrityError:
            display_error_messages(request,
                                   _("error_modification_learning_unit"))

    context['formsets'] = volume_edition_formset_container.formsets
    context['tab_active'] = 'components'
    context['experimental_phase'] = True

    if request.is_ajax():
        return JsonResponse(
            {'errors': volume_edition_formset_container.errors})

    return layout.render(request, "learning_unit/volumes_management.html",
                         context)