from django.core.urlresolvers import reverse
from django.http import HttpResponsePermanentRedirect


MONTH_DICT = { '01': 'jan',
               '02': 'feb',
               '03': 'mar',
               '04': 'apr',
               '05': 'may',
               '06': 'jun',
               '07': 'jul',
               '08': 'aug',
               '09': 'sep',
               '10': 'oct',
               '11': 'nov',
               '12': 'dec' }


def redirect_detail(request, year, month, day, slug, object_type):
    return HttpResponsePermanentRedirect(reverse('coltrane_%s_detail' % object_type,
                                                 kwargs={ 'year': year,
                                                          'month': MONTH_DICT[month],
                                                          'day': day,
                                                          'slug': slug }))


def redirect_archive_day(request, year, month, day, object_type):
    return HttpResponsePermanentRedirect(reverse('coltrane_%s_archive_day' % object_type,
                                                 kwargs={ 'year': year,
                                                          'month': MONTH_DICT[month],
                                                          'day': day }))


def redirect_archive_month(request, year, month, object_type):
    return HttpResponsePermanentRedirect(reverse('coltrane_%s_archive_month' % object_type,
                                                 kwargs={ 'year': year,
                                                          'month': MONTH_DICT[month] }))