'Keep track of a contribution\'s refund status.'

def enqueue_refund(self, status, user, refund_reason=None, rejection_reason=None):

    from mkt.prices.models import Refund
    (refund, c) = Refund.objects.safer_get_or_create(contribution=self, user=user)
    refund.status = status
    timestamps = []
    if (status in (mkt.REFUND_PENDING, mkt.REFUND_APPROVED_INSTANT, mkt.REFUND_FAILED)):
        timestamps.append('requested')
    if (status in (mkt.REFUND_APPROVED, mkt.REFUND_APPROVED_INSTANT)):
        timestamps.append('approved')
    elif (status == mkt.REFUND_DECLINED):
        timestamps.append('declined')
    for ts in timestamps:
        setattr(refund, ts, datetime.datetime.now())
    if refund_reason:
        refund.refund_reason = refund_reason
    if rejection_reason:
        refund.rejection_reason = rejection_reason
    refund.save()
    return refund
