Exemplo n.º 1
0
def list_week_midnights(year, month, day):
    requested = python_date(year, month, day)
    week_start = week_of(requested)
    midnights = Midnight.query.filter(
        and_(Midnight.date >= week_start, Midnight.date <= week_start + timedelta(days=7))) \
        .all()
    responses = [midnight.to_dict() for midnight in midnights]
    response = {'midnights': responses}
    return jsonify(response), 200, CORS_HEADER
Exemplo n.º 2
0
def date(value):
  match = DATE_RE.match(value)

  if not match:
    raise ValueError('Se requiere una fecha valida, por ejemplo \'1993-11-18\'')

  year = int(match.group(1))
  month = int(match.group(2))
  day = int(match.group(3))

  return python_date(year, month, day)
Exemplo n.º 3
0
def date(value):
    match = DATE_RE.match(value)

    if not match:
        raise ValueError(
            'A valid date is required, for instance \'1993-11-18\'.')

    year = int(match.group(1))
    month = int(match.group(2))
    day = int(match.group(3))

    return python_date(year, month, day)
Exemplo n.º 4
0
def list_user_week_status(year, month, day):
    requested = python_date(year, month, day)
    week_start = week_of(requested)
    midnights = Midnight.query.filter(
        and_(Midnight.date >= week_start, Midnight.date <= week_start + timedelta(days=7))) \
        .filter(Midnight.zebe == kerberos).all()
    account = MidnightAccount.query.filter(MidnightAccount.zebe == kerberos).filter(
        MidnightAccount.semester == CURRENT_SEMESTER).first()
    reviewed = Midnight.query.filter(Midnight.reviewed).filter(
        Midnight.date >= python_date.today() + timedelta(days=-7)) \
        .filter(Midnight.zebe == kerberos)
    return jsonify({'account': account.to_dict(), 'goal': MIDNIGHT_REQUIREMENT,
                    'midnights': [midnight.to_dict() for midnight in midnights],
                    'reviewed': [midnight.to_dict() for midnight in reviewed]}), 200, CORS_HEADER
Exemplo n.º 5
0
def test_0_1992_02_02():
    assert date('1992-02-02') == python_date(1992, 2, 2)