Exemple #1
0
def cron_s_unsent_list(request, template):
    all_scheduler_unsent = get_scheduler().get_jobs()
    all_scheduler_unsent.sort(key=lambda x: x.trigger.run_date)
    obj = get_paginator(request, all_scheduler_unsent, 10)
    return render_to_response(template, {
        'obj': obj,
    }, context_instance=RequestContext(request))
Exemple #2
0
def cron_delete(request, wbcnt_id):
    wb_cnt = WeiboContent.get_by_id(wbcnt_id)
    if not wb_cnt or wb_cnt.user_id != request.user.id:
        messages.success(request, u'错误的操作!')
        return HttpResponseRedirect(reverse('cron_unsent_list'))
    if request.method == 'POST':
        # FIXME: not good, get all jobs and iterate them
        scheduler = get_scheduler()
        jobs = scheduler.get_jobs()
        for job in jobs:
            if job.name == wbcnt_id:
                scheduler.unschedule_job(job)
        wb_cnt.delete()
    return HttpResponseRedirect(reverse('cron_unsent_list'))
Exemple #3
0
def _add_scehduler(callback, user, wb_cnt):
    scheduler = get_scheduler()
    scheduler.add_date_job(default_callback, date=wb_cnt.push_date, name=str(wb_cnt.id), args=[user, wb_cnt, ])