Changeset 6f1633e in osmose-frontend


Ignore:
Timestamp:
Mar 18, 2014 10:08:56 PM (6 years ago)
Author:
Frédéric Rodrigo <fred.rodrigo@…>
Branches:
master
Children:
80caae6
Parents:
d2d7241
git-author:
Frédéric Rodrigo <fred.rodrigo@…> (28/02/2014 13:06:32)
git-committer:
Frédéric Rodrigo <fred.rodrigo@…> (18/03/2014 22:08:56)
Message:

Display errors number of logger user

Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • byuser.py

    r34ea91d r6f1633e  
    6666 
    6767 
     68def _user_count(db, username=None): 
     69    params = query._params() 
     70    if username: 
     71        params.users = utils.pg_escape(username.decode("utf-8")).split(",") 
     72 
     73    if not params.users: 
     74        return 
     75 
     76    res = query._count(db, params, ['dynpoi_class.level'], ['dynpoi_class.level']) 
     77    ret = {1:0, 2:0, 3:0} 
     78    for (l, c) in res: 
     79        ret[l] = c 
     80 
     81    return ret 
     82 
     83 
     84@route('/byuser_count/<username>') 
     85@route('/byuser_count/<username>.<format:ext>') 
     86@route('/api/0.2/user_count/<username>') 
     87def user_count(db, lang, username=None, format=None): 
     88    count = _user_count(db, username) 
     89    if request.path.startswith("/api") or format == "json": 
     90        return count 
     91 
     92    elif format == 'rss': 
     93        response.content_type = "application/rss+xml" 
     94        return template('byuser/byuser_count.rss', username=username, count=count, translate=utils.translator(lang), website=utils.website) 
     95 
     96    else: 
     97        return count 
     98 
     99 
    68100def _users(db): 
    69101    params = query._params() 
  • map.py

    rd2d7241 r6f1633e  
    2525from tools import query 
    2626from tools import query_meta 
     27import byuser 
    2728import errors 
    2829import datetime 
     
    168169    try: 
    169170        user = request.session['user']['osm']['user']['@display_name'] 
    170         user_error_count = '' 
     171        user_error_count = byuser._user_count(db, user) 
    171172    except KeyError: 
    172173        user = None 
  • views/map/index.tpl

    rd2d7241 r6f1633e  
    172172<li id="menu-user"> 
    173173%if user: 
    174   <a href="../byuser/{{user}}">{{user}} ({{user_error_count}})</a> 
     174  <a href="../byuser/{{user}}">{{user}} ({{user_error_count[1]+user_error_count[2]+user_error_count[3]}}) ▼</a> 
     175  <ul class="submenu"> 
     176    <li><a href="../byuser/{{user}}?level=1">{{_("Level %s errors (%s)") % (1, user_error_count[1])}}</a></li> 
     177    <li><a href="../byuser/{{user}}?level=2">{{_("Level %s errors (%s)") % (2, user_error_count[2])}}</a></li> 
     178    <li><a href="../byuser/{{user}}?level=3">{{_("Level %s errors (%s)") % (3, user_error_count[3])}}</a></li> 
     179  </ul> 
    175180%else: 
    176181  <a href="../login">{{_("Login")}}</a> 
Note: See TracChangeset for help on using the changeset viewer.