<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def mark(request):
 """ Handles marking of individual notifications as read or unread. Takes ``notification id`` and mark ``action`` as POST data. :param request: HTTP request context. :returns: Response to mark action of supplied notification ID. """

    notification_id = request.POST.get('id', None)
    action = request.POST.get('action', None)
    success = True

    if notification_id:
        try:
            notification = Notification.objects.get(pk=notification_id,
                                                    recipient=request.user)
            if action == 'read':
                notification.mark_as_read()
                msg = _("Marked as read")
            elif action == 'unread':
                notification.mark_as_unread()
                msg = _("Marked as unread")
            else:
                success = False
                msg = _("Invalid mark action.")
        except Notification.DoesNotExist:
            success = False
            msg = _("Notification does not exists.")
    else:
        success = False
        msg = _("Invalid Notification ID")

    ctx = {'msg': msg, 'success': success, 'action': action}

    return notification_redirect(request, ctx)