Exemplo n.º 1
0
def get_month_request(request):
    params = request.GET
#    print params
    if 'calendar_id' not in params or \
        'year' not in params or \
        'month' not in params:
        return HttpResponse("")
    
    calendar_id = params['calendar_id']
    year = params['year']
    month = params['month']

    if 'user' in request.session:
        username = request.session['user']
    else:
        username = None

    (year, month, c, user) = append_data(year, month, calendar_id, username)

    month_table = create_month_table(year, month, c, user)
    this_date = datetime.date(year,month,1)
    month_seen = MonthSeen.get_month_seen(this_date, c, user)

    simple_data = { 'month' : month_table, 'month_seen' : month_seen }
    return HttpResponse(simplejson.dumps(simple_data), mimetype="application/json")
Exemplo n.º 2
0
def monthly_view_request(request, calendar_id, year=None, month=None):
    
    if 'user' in request.session:
        username = request.session['user']
    else:
        username = None

    (year, month, c, user) = append_data(year, month, calendar_id, username)
    
    month_table = create_month_table(year, month, c, user)
    
    if month_table == None:
        return HttpResponse("")
    
    if month == 12:
        next_month = str(year+1) + "/1/"
    else:
        next_month = str(year) + "/" + str(month+1) + "/"

    if month == 1:
        prev_month = str(year-1) + "/12/"
    else:
        prev_month = str(year) + "/" + str(month-1) + "/"
    
    this_date = datetime.date(year,month,1)
    month_seen = MonthSeen.get_month_seen(this_date, c, user)
        
    month_seen_by = create_month_seen_by(this_date, c)

    if username == None:
        username = ""

    context = { 'calendar_id' : calendar_id, 'month_table' : month_table,
               'next_month': next_month, 'prev_month' : prev_month,
               'year': year, 'month': month, 'user': username,
               'month_seen': month_seen, 'month_seen_by': month_seen_by,
               'descstring': c.descstring }
    
    return render(request, 'bandschedule/monthly.html', context)