author | Pawel Solyga <Pawel.Solyga@gmail.com> |
Thu, 09 Oct 2008 18:11:37 +0000 | |
changeset 292 | 1cece5192e26 |
parent 272 | 00cea07656c0 |
child 294 | 1fdaab4a6ef2 |
permissions | -rw-r--r-- |
186
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
2 |
# |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
4 |
# |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
8 |
# |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
10 |
# |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
16 |
|
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
17 |
"""Developer views for listing User profiles. |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
18 |
""" |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
19 |
|
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
21 |
'"Pawel Solyga" <pawel.solyga@gmail.com>', |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
22 |
] |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
23 |
|
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
24 |
|
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
25 |
from soc.logic.site import id_user |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
26 |
from soc.views import simple |
268
af1d7f48b361
Move helpers/list.py to helper/lists.py to avoid conflict with built-in type
Todd Larsen <tlarsen@google.com>
parents:
266
diff
changeset
|
27 |
from soc.views import helper |
af1d7f48b361
Move helpers/list.py to helper/lists.py to avoid conflict with built-in type
Todd Larsen <tlarsen@google.com>
parents:
266
diff
changeset
|
28 |
import soc.views.helper.lists |
272
00cea07656c0
Move helpers/response_helpers.py to helper/responses.py.
Todd Larsen <tlarsen@google.com>
parents:
268
diff
changeset
|
29 |
import soc.views.helper.responses |
186
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
30 |
|
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
31 |
import soc.models.user |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
32 |
|
263
9b39d93b677f
Make findNearestUsers() code in soc/logic/site/id_user.py more generic and
Todd Larsen <tlarsen@google.com>
parents:
233
diff
changeset
|
33 |
|
186
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
34 |
DEF_SITE_USER_LIST_ALL_TMPL = 'soc/site/user/list/all.html' |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
35 |
|
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
36 |
def all(request, template=DEF_SITE_USER_LIST_ALL_TMPL): |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
37 |
"""Show a list of all Users (limit rows per page). |
233
42733f531ebf
Add missing all() __doc__ string comments: "Args:" and "Returns:" sections.
Todd Larsen <tlarsen@google.com>
parents:
232
diff
changeset
|
38 |
|
42733f531ebf
Add missing all() __doc__ string comments: "Args:" and "Returns:" sections.
Todd Larsen <tlarsen@google.com>
parents:
232
diff
changeset
|
39 |
Args: |
42733f531ebf
Add missing all() __doc__ string comments: "Args:" and "Returns:" sections.
Todd Larsen <tlarsen@google.com>
parents:
232
diff
changeset
|
40 |
request: the standard Django HTTP request object |
42733f531ebf
Add missing all() __doc__ string comments: "Args:" and "Returns:" sections.
Todd Larsen <tlarsen@google.com>
parents:
232
diff
changeset
|
41 |
template: the "sibling" template (or a search list of such templates) |
42733f531ebf
Add missing all() __doc__ string comments: "Args:" and "Returns:" sections.
Todd Larsen <tlarsen@google.com>
parents:
232
diff
changeset
|
42 |
from which to construct an alternate template name (or names) |
42733f531ebf
Add missing all() __doc__ string comments: "Args:" and "Returns:" sections.
Todd Larsen <tlarsen@google.com>
parents:
232
diff
changeset
|
43 |
|
42733f531ebf
Add missing all() __doc__ string comments: "Args:" and "Returns:" sections.
Todd Larsen <tlarsen@google.com>
parents:
232
diff
changeset
|
44 |
Returns: |
42733f531ebf
Add missing all() __doc__ string comments: "Args:" and "Returns:" sections.
Todd Larsen <tlarsen@google.com>
parents:
232
diff
changeset
|
45 |
A subclass of django.http.HttpResponse which either contains the form to |
42733f531ebf
Add missing all() __doc__ string comments: "Args:" and "Returns:" sections.
Todd Larsen <tlarsen@google.com>
parents:
232
diff
changeset
|
46 |
be filled out, or a redirect to the correct view in the interface. |
186
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
47 |
""" |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
48 |
# create default template context for use with any templates |
272
00cea07656c0
Move helpers/response_helpers.py to helper/responses.py.
Todd Larsen <tlarsen@google.com>
parents:
268
diff
changeset
|
49 |
context = helper.responses.getUniversalContext(request) |
186
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
50 |
|
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
51 |
alt_response = simple.getAltResponseIfNotDeveloper(request, |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
52 |
context=context) |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
53 |
if alt_response: |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
54 |
return alt_response |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
55 |
|
268
af1d7f48b361
Move helpers/list.py to helper/lists.py to avoid conflict with built-in type
Todd Larsen <tlarsen@google.com>
parents:
266
diff
changeset
|
56 |
offset, limit = helper.lists.cleanListParameters( |
265
3c2994f3b85f
List views should have a selectable pagination "page" length:
Todd Larsen <tlarsen@google.com>
parents:
263
diff
changeset
|
57 |
offset=request.GET.get('offset'), limit=request.GET.get('limit')) |
263
9b39d93b677f
Make findNearestUsers() code in soc/logic/site/id_user.py more generic and
Todd Larsen <tlarsen@google.com>
parents:
233
diff
changeset
|
58 |
|
9b39d93b677f
Make findNearestUsers() code in soc/logic/site/id_user.py more generic and
Todd Larsen <tlarsen@google.com>
parents:
233
diff
changeset
|
59 |
# Fetch one more to see if there should be a 'next' link |
9b39d93b677f
Make findNearestUsers() code in soc/logic/site/id_user.py more generic and
Todd Larsen <tlarsen@google.com>
parents:
233
diff
changeset
|
60 |
users = id_user.getUsersForLimitAndOffset(limit + 1, offset=offset) |
9b39d93b677f
Make findNearestUsers() code in soc/logic/site/id_user.py more generic and
Todd Larsen <tlarsen@google.com>
parents:
233
diff
changeset
|
61 |
|
268
af1d7f48b361
Move helpers/list.py to helper/lists.py to avoid conflict with built-in type
Todd Larsen <tlarsen@google.com>
parents:
266
diff
changeset
|
62 |
context['pagination_form'] = helper.lists.makePaginationForm(request, limit) |
186
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
63 |
|
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
64 |
list_templates = {'list_main': 'soc/list/list_main.html', |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
65 |
'list_pagination': 'soc/list/list_pagination.html', |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
66 |
'list_row': 'soc/site/user/list/user_row.html', |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
67 |
'list_heading': 'soc/site/user/list/user_heading.html'} |
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
68 |
|
268
af1d7f48b361
Move helpers/list.py to helper/lists.py to avoid conflict with built-in type
Todd Larsen <tlarsen@google.com>
parents:
266
diff
changeset
|
69 |
context = helper.lists.setList( |
232
7741d6b7ce7c
Fix some style guide issues: keyword arguments are supposed to always be
Todd Larsen <tlarsen@google.com>
parents:
186
diff
changeset
|
70 |
request, context, users, |
7741d6b7ce7c
Fix some style guide issues: keyword arguments are supposed to always be
Todd Larsen <tlarsen@google.com>
parents:
186
diff
changeset
|
71 |
offset=offset, limit=limit, list_templates=list_templates) |
186
da76f08b1752
Add Users List Developer view which is available at /site/user/list. Add User list custom templates which are used with list_helpers. Add "Users List" link in base.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
72 |
|
272
00cea07656c0
Move helpers/response_helpers.py to helper/responses.py.
Todd Larsen <tlarsen@google.com>
parents:
268
diff
changeset
|
73 |
return helper.responses.respond(request, template, context) |
263
9b39d93b677f
Make findNearestUsers() code in soc/logic/site/id_user.py more generic and
Todd Larsen <tlarsen@google.com>
parents:
233
diff
changeset
|
74 |