예제 #1
0
파일: views.py 프로젝트: kolen/ptwatch-old
 def validator(form, value):
     session = DBSession()
     if session.query(RouteMaster).filter_by(ref=value['ref'],
             city=context, type=value['type']).count() != 0:
         t = 'Route with this ref and type already exists'
         exc = colander.Invalid(form, t)
         exc['ref'] = t
         raise exc
예제 #2
0
파일: views.py 프로젝트: kolen/ptwatch-old
def city_view(context, request):
    session = DBSession()
    rms = session.query(RouteMaster).filter_by(city=context).all()

    route_masters_by_transport = [
        (type, [rm for rm in rms if rm.type == type])
        for type in allowed_types
    ]
    return dict(city=context, route_masters_by_transport=route_masters_by_transport)