def atom_feed(): if 'MUNICIPALITY_NAME' in os.environ.keys(): title = u'תב"ע פתוחה - %s' % os.environ['MUNICIPALITY_NAME'].decode('utf-8') else: title = u'תב"ע פתוחה' return helpers._create_response_atom_feed(request, helpers._get_plans(count=20), feed_title=title).get_response()
def find_plan(plan_name): """ Find plans that contain the search query and return a json array of their plan and gush ids """ return helpers._create_response_json( helpers._get_plans(count=3, query={'number': { '$regex': '.*%s.*' % plan_name }}))
def atom_feed(): if 'MUNICIPALITY_NAME' in os.environ.keys(): title = u'תב"ע פתוחה - %s' % os.environ['MUNICIPALITY_NAME'].decode( 'utf-8') else: title = u'תב"ע פתוחה' return helpers._create_response_atom_feed(request, helpers._get_plans(count=20), feed_title=title).get_response()
def get_plans(gushim): """ Get JSON plan data for one or more gush IDs. The URL format for multiple gushim is something like /gush/12340,12350,12360/plans.json """ gushim = gushim.split(',') if len(gushim) > 1: gushim_query = {'gushim': {'$in': gushim}, 'year': {'$gt': datetime.datetime.now().year - 10}} else: gushim_query = {'gushim': gushim[0]} return helpers._create_response_json(helpers._get_plans(query=gushim_query))
def atom_feed_gush(gushim): """ Create a feed for one or more gush IDs. The URL format for multiple gushim is something like /gush/12340,12350,12360/plans.atom """ gushim = gushim.split(',') if len(gushim) > 1: gushim_query = {'gushim': {'$in': gushim}} else: gushim_query = {'gushim': gushim[0]} return helpers._create_response_atom_feed(request, helpers._get_plans(query=gushim_query), feed_title=u'תב״ע פתוחה - גוש %s' % ', '.join(gushim)).get_response()
def atom_feed_gush(gushim): """ Create a feed for one or more gush IDs. The URL format for multiple gushim is something like /gush/12340,12350,12360/plans.atom """ gushim = gushim.split(',') if len(gushim) > 1: gushim_query = {'gushim': {'$in': gushim}} else: gushim_query = {'gushim': gushim[0]} muni_name = os.environ.get('MUNICIPALITY_NAME', '').decode('utf-8') title = u'תב"ע פתוחה - %s - גוש %s' % (muni_name, ', '.join(gushim)) if muni_name else u'תב"ע פתוחה - גוש %s' % ', '.join(gushim) return helpers._create_response_atom_feed(request, helpers._get_plans(query=gushim_query), feed_title=title).get_response()
def atom_feed_gush(gushim): """ Create a feed for one or more gush IDs. The URL format for multiple gushim is something like /gush/12340,12350,12360/plans.atom """ gushim = gushim.split(',') if len(gushim) > 1: gushim_query = {'gushim': {'$in': gushim}} else: gushim_query = {'gushim': gushim[0]} return helpers._create_response_atom_feed( request, helpers._get_plans(query=gushim_query), feed_title=u'תב״ע פתוחה - גוש %s' % ', '.join(gushim)).get_response()
def atom_feed_gush(gushim): """ Create a feed for one or more gush IDs. The URL format for multiple gushim is something like /gush/12340,12350,12360/plans.atom """ gushim = gushim.split(',') if len(gushim) > 1: gushim_query = {'gushim': {'$in': gushim}} else: gushim_query = {'gushim': gushim[0]} muni_name = os.environ.get('MUNICIPALITY_NAME', '').decode('utf-8') title = u'תב"ע פתוחה - %s - גוש %s' % (muni_name, ', '.join( gushim)) if muni_name else u'תב"ע פתוחה - גוש %s' % ', '.join(gushim) return helpers._create_response_atom_feed( request, helpers._get_plans(query=gushim_query), feed_title=title).get_response()
def atom_feed_gush(gushim): """ Create a feed for one or more gush IDs. The URL format for multiple gushim is something like /gush/12340,12350,12360/plans.atom """ gushim = gushim.split(',') if len(gushim) > 1: gushim_query = {'gushim': {'$in': gushim}} else: gushim_query = {'gushim': gushim[0]} # set the feed title to include municaplity name if 'MUNICIPALITY_NAME' in os.environ.keys(): municaplity_name = os.environ['MUNICIPALITY_NAME'].decode('utf-8') title = u'תב"ע פתוחה (%s) - גוש %s' % (municaplity_name,', '.join(gushim)) else: title = u'תב"ע פתוחה - גוש %s' % (','.join(gushim)) return helpers._create_response_atom_feed(request, helpers._get_plans(query=gushim_query), feed_title=title).get_response()
def redirect_to_mavat(plan_id): """ If we have a mavat code for the given plan redirect the client to the plan's page on the mavat website using an auto-sending form """ try: plans = helpers._get_plans(count=1, query={'plan_id': int(plan_id)}) except ValueError: # plan_id is not an int abort(400) except: # DB error abort(500) if plans is None or len(plans) == 0 or plans[0]['mavat_code'] == '': abort(404) return make_response('<html><body>' '<form action="http://mavat.moin.gov.il/MavatPS/Forms/SV4.aspx?tid=4" method="post" name="redirect_form">' '<input type="hidden" name="PL_ID" value="' + plans[0]['mavat_code'] + '">' '</form><script language="javascript">document.redirect_form.submit();</script></body></html>')
def get_plans(gushim): """ Get JSON plan data for one or more gush IDs. The URL format for multiple gushim is something like /gush/12340,12350,12360/plans.json """ gushim = gushim.split(',') if len(gushim) > 1: gushim_query = { 'gushim': { '$in': gushim }, 'year': { '$gt': datetime.datetime.now().year - 10 } } else: gushim_query = {'gushim': gushim[0]} return helpers._create_response_json( helpers._get_plans(query=gushim_query))
def redirect_to_mavat(plan_id): """ If we have a mavat code for the given plan redirect the client to the plan's page on the mavat website using an auto-sending form """ try: plans = helpers._get_plans(count=1, query={'plan_id': int(plan_id)}) except ValueError: # plan_id is not an int abort(400) except: # DB error abort(500) if plans is None or len(plans) == 0 or plans[0]['mavat_code'] == '': abort(404) return make_response( '<html><body>' '<form action="http://mavat.moin.gov.il/MavatPS/Forms/SV4.aspx?tid=4" method="post" name="redirect_form">' '<input type="hidden" name="PL_ID" value="' + plans[0]['mavat_code'] + '">' '</form><script language="javascript">document.redirect_form.submit();</script></body></html>' )
def get_recent_plans(): """ Get the 10 most recent plans to show on the site's home page """ return helpers._create_response_json(helpers._get_plans(count=10))
def find_plan(plan_name): """ Find plans that contain the search query and return a json array of their plan and gush ids """ return helpers._create_response_json(helpers._get_plans(count=3, query={'number': {'$regex': '.*%s.*' % plan_name}}))
def atom_feed(): muni_name = os.environ.get('MUNICIPALITY_NAME', '').decode('utf-8') title = u'תב"ע פתוחה - %s' % muni_name if muni_name else u'תב"ע פתוחה' return helpers._create_response_atom_feed(request, helpers._get_plans(count=20), feed_title=title).get_response()
if options.min_date: # make sure the min_date parses fine try: min_date = datetime.datetime.strptime(options.min_date, '%d/%m/%Y') except: print 'Invalid minimum date. Format is 1/1/2015' exit(1) # build min_date query plans_query = {'$or': [ {'year': {'$gt': min_date.year}}, {'year': min_date.year, 'month': {'$gt': min_date.month}}, {'year': min_date.year, 'month': min_date.month, 'day': {'$gte': min_date.day}} ]} else: # no query plans_query = {} # get valid plans plans = helpers._get_plans(query=plans_query) # if not quiet, make sure the user is ok with this if not options.quiet: while 1: if not options.min_date: sys.stdout.write('No minimum date was supplied.\nAre you sure you want ALL %s plans to be synced? [y/N] ' % len(plans)) else: sys.stdout.write('Are you sure you want %s plans to be synced? [y/N] ' % len(plans)) choice = raw_input().lower() if choice == 'n' or choice == 'no': exit() elif choice == 'y' or choice == 'yes': break
'$gt': min_date.month } }, { 'year': min_date.year, 'month': min_date.month, 'day': { '$gte': min_date.day } }] } else: # no query plans_query = {} # get valid plans plans = helpers._get_plans(query=plans_query) # if not quiet, make sure the user is ok with this if not options.quiet: while 1: if not options.min_date: sys.stdout.write( 'No minimum date was supplied.\nAre you sure you want ALL %s plans to be synced? [y/N] ' % len(plans)) else: sys.stdout.write( 'Are you sure you want %s plans to be synced? [y/N] ' % len(plans)) choice = raw_input().lower() if choice == 'n' or choice == 'no':