Exemplo n.º 1
0
def user_count(db, lang, username=None, format=None):
    count = _user_count(db, username)

    if format == 'rss':
        response.content_type = "application/rss+xml"
        return template('byuser/byuser_count.rss',
                        username=username,
                        count=count,
                        website=utils.website)
    else:
        return count
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
def index(db, user, lang):
    if request.query_string:
        redirect("./#" + request.query_string)

    tags = query_meta._tags(db)

    categories = query_meta._items(db, langs=lang)

    item_levels = {'1': set(), '2': set(), '3': set()}
    for categ in categories:
        for item in categ['items']:
            del (item['number'])
            for index, classs in enumerate(item['class']):
                item['class'][index] = {
                    'class': classs['class'],
                    'title': classs['title'],
                }
            for level in item['levels']:
                item_levels[str(level['level'])].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']
    item_levels = {k: list(v) for k, v in item_levels.items()}

    sql = """
SELECT
    timestamp
FROM
    updates_last
ORDER BY
    timestamp
LIMIT
    1
OFFSET
    (SELECT COUNT(*)/2 FROM updates_last)
;
"""
    db.execute(sql)
    timestamp = db.fetchone()
    timestamp = str(timestamp[0]) if timestamp and timestamp[0] else None

    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 dict(categories=categories,
                tags=tags,
                item_levels=item_levels,
                main_project=utils.main_project,
                timestamp=timestamp,
                languages_name=utils.languages_name,
                website=utils.website,
                remote_url_read=utils.remote_url_read,
                user=user,
                user_error_count=user_error_count,
                main_website=utils.main_website)