Exemplo n.º 1
0
def make_date_time_from_now(days=0, hours=0):
    """a function that returns a string 
    representing a time that is 'days' days 
    and 'hours' hours away from now"""
    now = tz_utils.get_now_in(tz='UTC')
    date_time = now + datetime.timedelta(days=days, hours=hours)
    return date_time
Exemplo n.º 2
0
def show_schedule():
    # update_schedule.
    update_schedule(g.user)
    # show all shifts from today or later
    shifts = Schedule.get_future_shifts(g.user.id)
    now = tz_utils.get_now_in('US/Pacific')
    return render_template('schedule_page.html', shifts=shifts, today=now)
Exemplo n.º 3
0
def keep_api_token_up_to_date():
    #assumed token expiration is in UTC
    token_expiration = g.user.token_expiration
    if not token_expiration:
        return update_token()
    token_expiration = pytz.utc.localize(token_expiration)

    if (token_expiration - tz_utils.get_now_in(tz='UTC')) < RENEWAL_TIMEFRAME:
        return update_token
Exemplo n.º 4
0
def make_date_time_from_now(years=0, months=0, days=0, hours=0):
    """a function that returns a string 
    representing a time that is 'days' days 
    and 'hours' hours away from now"""
    months = (years * 12) + months
    days = (months * 30) + days

    now = tz_utils.get_now_in()
    date_time = now + datetime.timedelta(days=days, hours=hours)
    return date_time
Exemplo n.º 5
0
def keep_api_token_up_to_date():
    token_expiration = g.user.token_expiration
    #if there is no expiration, update the token
    if not token_expiration:
        return update_token()

    #assumed token expiration is in UTC
    token_expiration = tz_utils.get_time_as_utc(token_expiration, 'UTC')

    if (token_expiration - tz_utils.get_now_in(tz='UTC')) < RENEWAL_TIMEFRAME:
        return update_token()
Exemplo n.º 6
0
def keep_user_accessor_up_to_date(response):
    if g.user:
        curr_expiration = g.user.accessor_expiration
        curr_expiration = pytz.utc.localize(curr_expiration)
        # seeing if the accessor has less than RENEWAL_TIMEFRAME TTL
        if (curr_expiration - tz_utils.get_now_in(tz='UTC')) < RENEWAL_TIMEFRAME:
            #accessor is expired!
            g.user.update_accessor()
            user_jwt = g.user.make_jwt()
            # put the auth in the cookies
            response.set_cookie(JWT_AUTH_KEY, user_jwt,
                                expires=g.user.accessor_expiration)
    return response