Exemplo n.º 1
0
    def test_build_calendar_by_entity_have_entity_calendars_on_parent_structure(
            self):
        sst_date = {
            'start_date': timezone.now() - timezone.timedelta(days=5),
            'end_date': timezone.now() + timezone.timedelta(days=20)
        }
        EntityCalendarFactory(academic_calendar=self.ac_calendar,
                              entity=self.entity_sst.entity,
                              **sst_date)

        entity_calendar_computed = entity_calendar.build_calendar_by_entities(
            self.academic_year, SUMMARY_COURSE_SUBMISSION)
        default_date = {
            'start_date': self.ac_calendar.start_date,
            'end_date': self.ac_calendar.end_date
        }
        # Check on SSH node
        self.assertDictEqual(
            entity_calendar_computed[self.entity_ssh.entity.id], default_date)
        self.assertDictEqual(
            entity_calendar_computed[self.entity_lsm.entity.id], default_date)
        self.assertDictEqual(
            entity_calendar_computed[self.entity_clsm.entity.id], default_date)
        # Check on SST node
        self.assertDictEqual(
            entity_calendar_computed[self.entity_sst.entity.id],
            _convert_datetime_to_date(sst_date))
        self.assertDictEqual(
            entity_calendar_computed[self.entity_drt.entity.id],
            _convert_datetime_to_date(sst_date))
        self.assertDictEqual(
            entity_calendar_computed[self.entity_agro.entity.id],
            _convert_datetime_to_date(sst_date))
Exemplo n.º 2
0
    def _compute_summary_status(self, queryset):
        """
        This function will compute the summary status. First, we will take the entity calendar
        (or entity calendar parent and so one) of the requirement entity. If not found, the summary status is
        computed with the general Academic Calendar Object
        """
        entity_calendars_computed = entity_calendar.build_calendar_by_entities(
            self.form.cleaned_data['academic_year'].past(),
            SUMMARY_COURSE_SUBMISSION,
        )
        requirement_entities_ids = queryset.values_list(
            'learning_container_year__requirement_entity', flat=True)

        summary_status_case_statment = [
            When(last_translated_text_changed__isnull=True, then=False)
        ]
        for requirement_entity_id in set(requirement_entities_ids):
            start_summary_course_submission = entity_calendars_computed.get(
                requirement_entity_id, {}).get('start_date')
            if start_summary_course_submission is None:
                continue

            summary_status_case_statment.append(
                When(learning_container_year__requirement_entity=
                     requirement_entity_id,
                     last_translated_text_changed__gte=
                     start_summary_course_submission,
                     then=True))

        queryset = queryset.annotate(
            summary_status=Case(*summary_status_case_statment,
                                default=Value(False),
                                output_field=BooleanField()))
        return queryset
Exemplo n.º 3
0
 def test_build_calendar_by_entity_no_entity_calendars(self):
     entity_calendar_computed = entity_calendar.build_calendar_by_entities(self.academic_year,
                                                                           SUMMARY_COURSE_SUBMISSION)
     default_date = {'start_date': self.ac_calendar.start_date, 'end_date': self.ac_calendar.end_date}
     # Check on SSH node
     self.assertDictEqual(entity_calendar_computed[self.entity_ssh.entity.id], default_date)
     self.assertDictEqual(entity_calendar_computed[self.entity_lsm.entity.id], default_date)
     self.assertDictEqual(entity_calendar_computed[self.entity_clsm.entity.id], default_date)
     # Check on SST node
     self.assertDictEqual(entity_calendar_computed[self.entity_sst.entity.id], default_date)
     self.assertDictEqual(entity_calendar_computed[self.entity_drt.entity.id], default_date)
     self.assertDictEqual(entity_calendar_computed[self.entity_agro.entity.id], default_date)
Exemplo n.º 4
0
def list_my_attributions_summary_editable(request):
    tutor = get_object_or_404(Tutor, person__user=request.user)
    event_perm = event_perms.EventPermSummaryCourseSubmission()

    if event_perm.is_open():
        data_year = event_perm.get_academic_years().get()
    else:
        previous_opened_calendar = event_perm.get_previous_opened_calendar()
        data_year = previous_opened_calendar.data_year
        messages.add_message(
            request,
            messages.INFO,
            _('For the academic year %(data_year)s, the summary edition period is ended since %(end_date)s.') % {
                "data_year": data_year,
                "end_date": previous_opened_calendar.end_date.strftime('%d-%m-%Y'),
            }
        )
        next_opened_calendar = event_perm.get_next_opened_calendar()
        if next_opened_calendar:
            messages.add_message(
                request,
                messages.INFO,
                _('For the academic year %(data_year)s, the summary edition period will open on %(start_date)s.') % {
                    "data_year": next_opened_calendar.data_year,
                    "start_date": next_opened_calendar.start_date.strftime('%d-%m-%Y'),
                }
            )

    learning_unit_years = find_learning_unit_years_by_academic_year_tutor_attributions(
        academic_year=data_year,
        tutor=tutor
    )

    entity_calendars = entity_calendar.build_calendar_by_entities(
        ac_year=data_year,
        reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION
    )
    errors = (can_user_edit_educational_information(user=tutor.person.user, learning_unit_year_id=luy.id)
              for luy in learning_unit_years)
    context = {
        'learning_unit_years_with_errors': list(zip(learning_unit_years, errors)),
        'entity_calendars': entity_calendars,
    }
    return render(request, 'manage_my_courses/list_my_courses_summary_editable.html', context)
Exemplo n.º 5
0
def list_my_attributions_summary_editable(request):
    tutor = get_object_or_404(Tutor, person__user=request.user)
    current_ac = academic_year.current_academic_year()
    learning_unit_years = find_learning_unit_years_by_academic_year_tutor_attributions(
        academic_year=current_ac.next(),
        tutor=tutor
    )

    entity_calendars = entity_calendar.build_calendar_by_entities(
        ac_year=current_ac,
        reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION
    )
    errors = (can_user_edit_educational_information(user=tutor.person.user, learning_unit_year_id=luy.id)
              for luy in learning_unit_years)
    context = {
        'learning_unit_years_with_errors': zip(learning_unit_years, errors),
        'entity_calendars': entity_calendars,
    }
    return render(request, 'manage_my_courses/list_my_courses_summary_editable.html', context)
Exemplo n.º 6
0
def list_my_attributions_summary_editable(request):
    tutor = get_object_or_404(Tutor, person__user=request.user)
    current_ac = academic_year.current_academic_year()
    learning_unit_years = find_learning_unit_years_by_academic_year_tutor_attributions(
        academic_year=current_ac.next(), tutor=tutor)

    entity_calendars = entity_calendar.build_calendar_by_entities(
        ac_year=current_ac,
        reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION)
    errors = (can_user_edit_educational_information(
        user=tutor.person.user, learning_unit_year_id=luy.id)
              for luy in learning_unit_years)
    context = {
        'learning_unit_years_with_errors': zip(learning_unit_years, errors),
        'entity_calendars': entity_calendars,
    }
    return render(request,
                  'manage_my_courses/list_my_courses_summary_editable.html',
                  context)