def items(db, langs, item, classs): return { "categories": (query_meta._items_3(db, item=item, classs=classs, langs=langs)) }
def index(db, user, lang): if request.query_string: redirect("./#" + request.query_string) tags = query_meta._tags(db) categories = query_meta._items_3(db) item_tags = defaultdict(set) item_levels = {'1': set(), '2': set(), '3': set()} for categ in categories: for item in categ['items']: for level in item['levels']: item_levels[str(level['level'])].add(item['item']) if item['tags']: for tag in item['tags']: item_tags[tag].add(item['item']) item_levels['1,2'] = item_levels['1'] | item_levels['2'] item_levels['1,2,3'] = item_levels['1,2'] | item_levels['3'] urls = [] # TRANSLATORS: link to help in appropriate language if user: urls.append(("byuser", _("Issues by user"), "../byuser/")) urls.append(("relation_analyser", _("Relation analyser"), "http://analyser.openstreetmap.fr/")) # TRANSLATORS: link to source code urls.append(("statistics", _("Statistics"), "../control/update_matrix")) helps = [] helps.append((_("Contact"), "../contact")) helps.append((_("Help on wiki"), _("http://wiki.openstreetmap.org/wiki/Osmose"))) helps.append((_("Copyright"), "../copyright")) helps.append((_("Sources"), "https://github.com/osm-fr?q=osmose")) helps.append((_("Translation"), "../translation")) sql = """ SELECT EXTRACT(EPOCH FROM ((now())-timestamp)) AS age FROM updates_last ORDER BY timestamp LIMIT 1 OFFSET (SELECT COUNT(*)/2 FROM updates_last) ; """ db.execute(sql) delay = db.fetchone() if delay and delay[0]: delay = delay[0]/60/60/24 else: delay = 0 if user != None: if user: user_error_count = _user_count(db, user) else: # user == False user = '******' user_error_count = {1: 0, 2: 0, 3: 0} else: user_error_count = None return template('map/index', categories=categories, item_tags=item_tags, tags=tags, item_levels=item_levels, main_project=utils.main_project, urls=urls, helps=helps, delay=delay, languages_name=utils.languages_name, translate=translator(lang), website=utils.website, remote_url_read=utils.remote_url_read, request=request, user=user, user_error_count=user_error_count)
def items(db, langs): return {"categories": query_meta._items_3(db, langs=langs)}