Exemple #1
0
    def test_save_entity_calendar(self):
        entity_version = EntityVersionFactory()
        entity_version.refresh_from_db()
        entity = entity_version.entity

        form = EntityCalendarEducationalInformationForm(entity_version, {"start_date": "05/03/2018", "end_date": "06/03/2018"})

        self.assertTrue(form.is_valid())
        self.assertFalse(EntityCalendar.objects.all().exists())

        form.save_entity_calendar(entity)

        self.assertTrue(EntityCalendar.objects.get(entity=entity, academic_calendar=self.academic_calendar))
Exemple #2
0
 def test_fields(self):
     entity_version = EntityVersionFactory()
     entity_version.refresh_from_db()
     form = EntityCalendarEducationalInformationForm(entity_version)
     expected_fields = ["start_date", "end_date"]
     actual_fields = list(form.fields.keys())
     self.assertListEqual(expected_fields, actual_fields)
Exemple #3
0
def entity_read(request, entity_version_id):
    entity_version = get_object_or_404(EntityVersion, id=entity_version_id)
    can_user_post = can_user_edit_educational_information_submission_dates_for_entity(request.user,
                                                                                      entity_version.entity)
    if request.method == "POST" and not can_user_post:
        logger.warning("User {} has no sufficient right to modify submission dates of educational information.".
                       format(request.user))
        raise PermissionDenied()

    entity_parent = entity_version.get_parent_version()
    descendants = entity_version.descendants

    form = EntityCalendarEducationalInformationForm(entity_version, request.POST or None)
    if form.is_valid():
        display_success_messages(request, _("Educational information submission dates updated"))
        form.save_entity_calendar(entity_version.entity)

    # TODO Remove locals
    return render(request, "entity/identification.html", locals())