views.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:django-nanoCRM 作者: Mrsserj 项目源码 文件源码
def calendar(request, year=None, month=None):
    customer = None
    if request.GET.has_key('customer_id'):
        customer = Customer.objects.get(pk=request.GET['customer_id'])
    if year is None or month is None:
        start_date = dt.datetime.strptime('%s.%s' %(dt.datetime.now().month, dt.datetime.now().year), '%m.%Y')
    else:
        start_date = dt.datetime.strptime('%s.%s' %(month, year), '%m.%Y')
    offset = start_date.weekday()+cl.monthrange(start_date.year, start_date.month)[1]
    if offset == 28:
        weeks = [0,1,2,3]
    elif offset > 28 and offset < 36:
        weeks = [0,1,2,3,4]
    else:
        weeks = [0,1,2,3,4,5]
    return render(request, 'calendar.html', { 'offset':offset, 'customer':customer, 'prev':(start_date+dt.timedelta(days=-1)), 'next':(start_date+dt.timedelta(days=32)), 
        'cal_date':start_date, 'start_date':start_date.strftime('%m.%Y'), 'weeks':weeks, 'days':[0,1,2,3,4,5,6] })
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号