Exemplo n.º 1
0
def _set_values_in_offer_year_calendar(oyc, value):
    if isinstance(value, tuple) and len(value) == 2:
        oyc.start_date = convert_date_to_datetime(value[0])
        oyc.end_date = convert_date_to_datetime(value[1])
    else:
        oyc.start_date = convert_date_to_datetime(value)
        oyc.end_date = convert_date_to_datetime(value)
def _set_values_in_offer_year_calendar(oyc, value):
    if oyc:
        if isinstance(value, tuple) and len(value) == 2:
            oyc.start_date = convert_date_to_datetime(value[0])
            oyc.end_date = convert_date_to_datetime(value[1])
        else:
            oyc.start_date = convert_date_to_datetime(value)
            oyc.end_date = convert_date_to_datetime(value)
    return oyc
Exemplo n.º 3
0
def _is_calendar_opened_to_edit_educational_information(*, learning_unit_year_id, **kwargs):
    submission_dates = find_educational_information_submission_dates_of_learning_unit_year(learning_unit_year_id)
    if not submission_dates:
        raise PermissionDenied(_("Not in period to edit educational information."))

    now = datetime.datetime.now(tz=get_tzinfo())
    value = convert_date_to_datetime(submission_dates["start_date"]) <= now <= \
        convert_date_to_datetime(submission_dates["end_date"])
    if not value:
        raise PermissionDenied(_("Not in period to edit educational information."))
Exemplo n.º 4
0
def _is_calendar_opened_to_edit_educational_information(*, learning_unit_year_id, **kwargs):
    submission_dates = find_educational_information_submission_dates_of_learning_unit_year(learning_unit_year_id)
    permission_denied_msg = _("Not in period to edit description fiche.")
    if not submission_dates:
        raise PermissionDenied(permission_denied_msg)

    now = datetime.datetime.now(tz=get_tzinfo())
    value = convert_date_to_datetime(submission_dates["start_date"]) <= now <= \
        convert_date_to_datetime(submission_dates["end_date"])
    if not value:
        raise PermissionDenied(permission_denied_msg)
Exemplo n.º 5
0
def can_user_edit_educational_information(user, learning_unit_year_id):
    if not can_user_view_educational_information(user, learning_unit_year_id):
        return False

    submission_dates = find_educational_information_submission_dates_of_learning_unit_year(
        learning_unit_year_id)
    if not submission_dates:
        return False

    now = datetime.datetime.now(tz=get_tzinfo())
    return convert_date_to_datetime(submission_dates["start_date"]) <= now <= \
        convert_date_to_datetime(submission_dates["end_date"])
Exemplo n.º 6
0
def _changed_in_period(start_date, changed_date):
    return convert_date_to_datetime(start_date) <= changed_date
Exemplo n.º 7
0
 def test_convert_date_to_datetime(self):
     today = datetime.datetime.today()
     today_date = today.date()
     today_datetime = convert_date_to_datetime(today_date)
     self.assertEqual(type(today_datetime), datetime.datetime)
Exemplo n.º 8
0
def _changed_in_period(start_date, changed_date):
    return convert_date_to_datetime(start_date) <= changed_date
Exemplo n.º 9
0
 def test_convert_date_to_datetime(self):
     today = datetime.datetime.today()
     today_date = today.date()
     today_datetime = convert_date_to_datetime(today_date)
     self.assertEqual(type(today_datetime), datetime.datetime)