Example #1
0
def show_customer_deals(request,
                        user,
                        year,
                        month,
                        day,
                        tmpl='customer_deals.html'):
    prev_date, date, next_date = _nearest_midnights(int(year),
                                                    int(month),
                                                    int(day),
                                                    timezone=utils.get_tzinfo(
                                                        user['time_zone']))

    now = datetime.datetime.now(pytz.utc)

    if date > now - HISTORY_HORIZON:
        # Get user's customer deals for the given period of time.
        deals = db.get_customer_recent_deal_list(user['trader_id'], date,
                                                 next_date)
    else:
        # This day is outside our history horizon.
        deals = None

    # Render everything adding CSRF protection.
    c = {
        'settings': settings,
        'user': user,
        'prev_date': prev_date,
        'date': date,
        'next_date': next_date if next_date <= now else None,
        'deals': deals
    }
    c.update(csrf(request))
    return render_to_response(tmpl, c)
Example #2
0
def dealts(ts, time_zone='UTC'):
    tz = get_tzinfo(time_zone)
    mark = _get_bidi_mark()
    loc_ts = ts.astimezone(tz)
    return ''.join((
        mark, loc_ts.strftime('%Y-%m-%d'), ' ',
        loc_ts.strftime('%H:%M:%S'), mark
        ))
Example #3
0
def show_my_todays_deals(request, user):

    # Get current timestamp in user's time zone.    
    tz = utils.get_tzinfo(user['time_zone'])    
    today = datetime.datetime.now(tz)

    return HttpResponseRedirect(reverse(
        show_my_deals,
        args=[user['trader_id'], today.year, today.month, today.day]))
Example #4
0
def show_my_todays_deals(request, user):

    # Get current timestamp in user's time zone.
    tz = utils.get_tzinfo(user['time_zone'])
    today = datetime.datetime.now(tz)

    return HttpResponseRedirect(
        reverse(show_my_deals,
                args=[user['trader_id'], today.year, today.month, today.day]))
Example #5
0
def show_customer_deals(request, user, year, month, day, tmpl='customer_deals.html'):
    prev_date, date, next_date = _nearest_midnights(
        int(year), int(month), int(day),
        timezone=utils.get_tzinfo(user['time_zone']))

    now = datetime.datetime.now(pytz.utc)
    
    if date > now - HISTORY_HORIZON:
        # Get user's customer deals for the given period of time.
        deals = db.get_customer_recent_deal_list(user['trader_id'], date, next_date)
    else:
        # This day is outside our history horizon.
        deals = None

    # Render everything adding CSRF protection.
    c = { 'settings': settings, 'user': user, 'prev_date': prev_date, 'date': date,
          'next_date': next_date if next_date <= now else None,
          'deals': deals }
    c.update(csrf(request))
    return render_to_response(tmpl, c)
Example #6
0
def dealts(ts, time_zone='UTC'):
    tz = get_tzinfo(time_zone)
    mark = _get_bidi_mark()
    loc_ts = ts.astimezone(tz)
    return ''.join((mark, loc_ts.strftime('%Y-%m-%d'), ' ',
                    loc_ts.strftime('%H:%M:%S'), mark))