# Path: osf/models/admin_log_entry.py
# def update_admin_log(user_id, object_id, object_repr, message, action_flag=UNKNOWN):
#     AdminLogEntry.objects.log_action(
#         user_id=user_id,
#         content_type_id=None,
#         object_id=object_id,
#         object_repr=object_repr,
#         change_message=message,
#         action_flag=action_flag
#     )
# 
# EMBARGO_UPDATED = 34


from osf.models import Subject, NodeLicense, Brand
from django.core.exceptions import ValidationError, PermissionDenied
from django.urls import reverse
from django.core.validators import RegexValidator, _lazy_re_compile
from django.utils.http import urlencode
from django.utils.translation import ugettext_lazy as _
from django.utils import timezone
from osf.models.admin_log_entry import (
    update_admin_log,
    EMBARGO_UPDATED
)
from website import settings
    if end_date - registration.registered_date >= settings.EMBARGO_END_DATE_MAX:
        raise ValidationError('Registrations can only be embargoed for up to four years.')
    elif end_date < timezone.now():
        raise ValidationError('Embargo end date must be in the future.')


def change_embargo_date(registration, user, end_date):
    """Update the embargo period of a registration
    :param registration: Registration that is being updated
    :param user: osf_admin that is updating a registration
    :param end_date: Date when the registration should be made public
    """

    validate_embargo_date(registration, user, end_date)

    if registration.embargo:
        registration.embargo.end_date = end_date
    else:
        registration._initiate_embargo(
            user,
            end_date,
            for_existing_registration=True,
            notify_initiator_on_complete=False
        )

    registration.is_public = False

    registration.embargo.save()
    registration.save()


# Path: osf/models/admin_log_entry.py
# def update_admin_log(user_id, object_id, object_repr, message, action_flag=UNKNOWN):
#     AdminLogEntry.objects.log_action(
#         user_id=user_id,
#         content_type_id=None,
#         object_id=object_id,
#         object_repr=object_repr,
#         change_message=message,
#         action_flag=action_flag
#     )
# 
# EMBARGO_UPDATED = 34


# Path: admin/base/utils.py
from osf.models import Subject, NodeLicense, Brand
from django.core.exceptions import ValidationError, PermissionDenied
from django.urls import reverse
from django.core.validators import RegexValidator, _lazy_re_compile
from django.utils.http import urlencode
from django.utils.translation import ugettext_lazy as _
from django.utils import timezone
from osf.models.admin_log_entry import (
    update_admin_log,
    EMBARGO_UPDATED
)
from website import settings

    if end_date - registration.registered_date >= settings.EMBARGO_END_DATE_MAX:
        raise ValidationError('Registrations can only be embargoed for up to four years.')
    elif end_date < timezone.now():
        raise ValidationError('Embargo end date must be in the future.')


def change_embargo_date(registration, user, end_date):
    """Update the embargo period of a registration
    :param registration: Registration that is being updated
    :param user: osf_admin that is updating a registration
    :param end_date: Date when the registration should be made public
    """

    validate_embargo_date(registration, user, end_date)

    if registration.embargo:
        registration.embargo.end_date = end_date
    else:
        registration._initiate_embargo(
            user,
            end_date,
            for_existing_registration=True,
            notify_initiator_on_complete=False
        )

    registration.is_public = False

    registration.embargo.save()
    registration.save()


    update_admin_log(