@require_POST
def cron_preview(request):
    schedule = request.POST.get('schedule', '')
    tz = request.POST.get('tz')
    ctx = {'tz': tz, 'dates': []}
    try:
        zone = pytz.timezone(tz)
        now_local = timezone.localtime(timezone.now(), zone)
        if (len(schedule.split()) != 5):
            raise ValueError()
        it = croniter(schedule, now_local)
        for i in range(0, 6):
            ctx['dates'].append(it.get_next(datetime))
        ctx['desc'] = str(ExpressionDescriptor(schedule, use_24hour_time_format=True))
    except UnknownTimeZoneError:
        ctx['bad_tz'] = True
    except:
        ctx['bad_schedule'] = True
    return render(request, 'front/cron_preview.html', ctx)
@require_POST
def cron_preview(request):
    schedule = request.POST.get('schedule', )
    tz = request.POST.get('tz')
    ctx = {'tz': tz, 'dates': []}
    try:
        zone = pytz.timezone(tz)
        now_local = timezone.localtime(timezone.now(), zone)
        if (len(schedule.split()) != 5):
            raise ValueError()
        it = croniter(schedule, now_local)
        for i in range(0, 6):
            ctx['dates'].append(it.get_next(datetime))
        ctx['desc'] = str(ExpressionDescriptor(schedule, use_24hour_time_format=True))
    except UnknownTimeZoneError:
        ctx['bad_tz'] = True
    except:
        ctx['bad_schedule'] = True
    return render(request, 'front/cron_preview.html', ctx)