Revision d492d8ae

b/snf-astakos-app/astakos/im/api/admin.py
71 71
    """Decorator function for views that implement an API method."""
72 72
    if not perms:
73 73
        perms = []
74
    
74

  
75 75
    def decorator(func):
76 76
        @wraps(func)
77 77
        def wrapper(request, *args, **kwargs):
......
111 111
    #                       unauthorised (401)
112 112
    if not user:
113 113
        raise BadRequest('No user')
114
    
114

  
115 115
    # Check if the is active.
116 116
    if not user.is_active:
117 117
        raise Unauthorized('User inactive')
......
119 119
    # Check if the token has expired.
120 120
    if (time() - mktime(user.auth_token_expires.timetuple())) > 0:
121 121
        raise Unauthorized('Authentication expired')
122
    
122

  
123 123
    if not user.signed_terms():
124 124
        raise Unauthorized('Pending approval terms')
125
    
125

  
126 126
    response = HttpResponse()
127 127
    response.status=204
128 128
    user_info = {'username':user.username,
......
146 146
    #                       unauthorised (401)
147 147
    if not user:
148 148
        raise BadRequest('No user')
149
    
149

  
150 150
    # Check if the is active.
151 151
    if not user.is_active:
152 152
        raise Unauthorized('User inactive')
......
154 154
    # Check if the token has expired.
155 155
    if (time() - mktime(user.auth_token_expires.timetuple())) > 0:
156 156
        raise Unauthorized('Authentication expired')
157
    
157

  
158 158
    if not user.signed_terms():
159 159
        raise Unauthorized('Pending approval terms')
160
    
160

  
161 161
    response = HttpResponse()
162 162
    response.status=204
163 163
    user_info = {'userid':user.username,
......
178 178
def get_services(request):
179 179
    callback = request.GET.get('callback', None)
180 180
    services = Service.objects.all()
181
    data = tuple({'name':s.name, 'url':s.url, 'icon':s.icon} for s in services)
181
    data = tuple({'id':s.pk, 'name':s.name, 'url':s.url, 'icon':s.icon} for s in services)
182 182
    data = json.dumps(data)
183 183
    mimetype = 'application/json'
184 184

  
......
220 220
        if with_signout:
221 221
            l.append({ 'url': absolute(reverse('astakos.im.views.logout')),
222 222
                      'name': "Sign out"})
223
    
223

  
224 224
    callback = request.GET.get('callback', None)
225 225
    data = json.dumps(tuple(l))
226 226
    mimetype = 'application/json'

Also available in: Unified diff