|
1 #!/usr/bin/python2.5 |
|
2 # |
|
3 # Copyright 2008 the Melange authors. |
|
4 # |
|
5 # Licensed under the Apache License, Version 2.0 (the "License"); |
|
6 # you may not use this file except in compliance with the License. |
|
7 # You may obtain a copy of the License at |
|
8 # |
|
9 # http://www.apache.org/licenses/LICENSE-2.0 |
|
10 # |
|
11 # Unless required by applicable law or agreed to in writing, software |
|
12 # distributed under the License is distributed on an "AS IS" BASIS, |
|
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 # See the License for the specific language governing permissions and |
|
15 # limitations under the License. |
|
16 |
|
17 """Developer views for listing User profiles. |
|
18 """ |
|
19 |
|
20 __authors__ = [ |
|
21 '"Pawel Solyga" <pawel.solyga@gmail.com>', |
|
22 ] |
|
23 |
|
24 |
|
25 from soc.logic.site import id_user |
|
26 from soc.views import simple |
|
27 from soc.views.helpers import list_helpers |
|
28 from soc.views.helpers import response_helpers |
|
29 |
|
30 import soc.models.user |
|
31 |
|
32 DEF_SITE_USER_LIST_ALL_TMPL = 'soc/site/user/list/all.html' |
|
33 |
|
34 def all(request, template=DEF_SITE_USER_LIST_ALL_TMPL): |
|
35 """Show a list of all Users (limit rows per page). |
|
36 """ |
|
37 # create default template context for use with any templates |
|
38 context = response_helpers.getUniversalContext(request) |
|
39 |
|
40 alt_response = simple.getAltResponseIfNotDeveloper(request, |
|
41 context=context) |
|
42 if alt_response: |
|
43 return alt_response |
|
44 |
|
45 offset = request.GET.get('offset') |
|
46 limit = request.GET.get('limit') |
|
47 |
|
48 offset, limit = list_helpers.getListParemeters(offset, limit) |
|
49 |
|
50 users = id_user.getUsersForOffsetAndLimit(offset, limit) |
|
51 |
|
52 list_templates = {'list_main': 'soc/list/list_main.html', |
|
53 'list_pagination': 'soc/list/list_pagination.html', |
|
54 'list_row': 'soc/site/user/list/user_row.html', |
|
55 'list_heading': 'soc/site/user/list/user_heading.html'} |
|
56 |
|
57 context = list_helpers.setList(request, context, users, |
|
58 offset, limit, list_templates) |
|
59 |
|
60 return response_helpers.respond(request, template, context) |
|
61 |