Esempio n. 1
0
    def test_create_with_parent(self, mock_find_authorized_types):
        parent = GroupFactory()
        form = GroupForm(data=self.post_data, parent=parent, user=self.user, education_group_type=self.egt)

        self.assertTrue(form.is_valid(), form.errors)

        education_group_year = form.save()

        self.assertTrue(GroupElementYear.objects.get(child_branch=education_group_year, parent=parent))
Esempio n. 2
0
    def test_create(self):
        form = GroupForm(data=self.post_data, parent=None)

        self.assertTrue(form.is_valid(), form.errors)

        education_group_year = form.save()

        self.assertEqual(education_group_year.education_group.start_year,
                         self.expected_educ_group_year.academic_year.year)
        self.assertIsNone(education_group_year.education_group.end_year)
Esempio n. 3
0
def _update_group(request, education_group_year, root):
    # TODO :: IMPORTANT :: Fix urls patterns to get the GroupElementYear_id and the root_id in the url path !
    # TODO :: IMPORTANT :: Need to update form to filter on list of parents, not only on the first direct parent
    form_education_group_year = GroupForm(request.POST or None,
                                          instance=education_group_year)
    html_page = "education_group/update_groups.html"

    if form_education_group_year.is_valid():
        return _common_success_redirect(request,
                                        form_education_group_year.save(), root)

    return layout.render(
        request, html_page, {
            "education_group_year":
            education_group_year,
            "form_education_group_year":
            form_education_group_year.forms[forms.ModelForm],
        })