<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def modify_event_view(request, id=None):
 """Modify event page. You may only modify an event if you were the creator or you are an administrator. id: event id """

    event = get_object_or_404(Event, id=id)
    is_events_admin = request.user.has_admin_permission('events')

    if not is_events_admin:
        raise exceptions.PermissionDenied

    if request.method == "POST":
        if is_events_admin:
            form = AdminEventForm(data=request.POST, instance=event, all_groups=request.user.has_admin_permission('groups'))
        else:
            form = EventForm(data=request.POST, instance=event, all_groups=request.user.has_admin_permission('groups'))
        logger.debug(form)
        if form.is_valid():
            obj = form.save()
            # SAFE HTML
            obj.description = safe_html(obj.description)
            obj.save()
            messages.success(request, "Successfully modified event.")
            # return redirect("events")
        else:
            messages.error(request, "Error modifying event.")
    else:
        if is_events_admin:
            form = AdminEventForm(instance=event, all_groups=request.user.has_admin_permission('groups'))
        else:
            form = EventForm(instance=event, all_groups=request.user.has_admin_permission('groups'))
    context = {"form": form, "action": "modify", "action_title": "Modify", "id": id, "is_events_admin": is_events_admin}
    return render(request, "events/add_modify.html", context)