app/soc/views/site/sponsor/list.py
author Sverre Rabbelier <srabbelier@gmail.com>
Sun, 12 Oct 2008 15:52:19 +0000
changeset 305 972d28056d9d
parent 303 4f1bb54ddae5
child 309 7190b224c701
permissions -rw-r--r--
Minor style and import fixes Incorperated changes as suggested by Todd and Pawel. Patch by: Sverre Rabbelier Reviewed by: to-be-reviewed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
259
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     2
#
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     4
#
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     8
#
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    10
#
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    16
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    17
"""Developer views for listing Sponsors profiles.
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    18
"""
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    19
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    20
__authors__ = [
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    21
  '"Pawel Solyga" <pawel.solyga@gmail.com>',
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    22
  ]
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    23
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    24
305
972d28056d9d Minor style and import fixes
Sverre Rabbelier <srabbelier@gmail.com>
parents: 303
diff changeset
    25
import soc.logic
259
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
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: 267
diff changeset
    27
from soc.views import helper
303
4f1bb54ddae5 Moved soc/logic/helper/access to soc/views/helper/access
Sverre Rabbelier <srabbelier@gmail.com>
parents: 299
diff changeset
    28
from soc.views.helper import access
268
af1d7f48b361 Move helpers/list.py to helper/lists.py to avoid conflict with built-in type
Todd Larsen <tlarsen@google.com>
parents: 267
diff changeset
    29
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
    30
import soc.views.helper.responses
303
4f1bb54ddae5 Moved soc/logic/helper/access to soc/views/helper/access
Sverre Rabbelier <srabbelier@gmail.com>
parents: 299
diff changeset
    31
import soc.views.out_of_band
259
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    32
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    33
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    34
DEF_SITE_SPONSOR_LIST_ALL_TMPL = 'soc/group/list/all.html'
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    35
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    36
def all(request, template=DEF_SITE_SPONSOR_LIST_ALL_TMPL):
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    37
  """Show a list of all Sponsors (limit rows per page).
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    38
  """
294
1fdaab4a6ef2 Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 272
diff changeset
    39
1fdaab4a6ef2 Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 272
diff changeset
    40
  try:
1fdaab4a6ef2 Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 272
diff changeset
    41
    access.checkIsDeveloper(request)
303
4f1bb54ddae5 Moved soc/logic/helper/access to soc/views/helper/access
Sverre Rabbelier <srabbelier@gmail.com>
parents: 299
diff changeset
    42
  except  soc.views.out_of_band.AccessViolationResponse, alt_response:
294
1fdaab4a6ef2 Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 272
diff changeset
    43
    return alt_response.response()
1fdaab4a6ef2 Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 272
diff changeset
    44
259
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    45
  # 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
    46
  context = helper.responses.getUniversalContext(request)
259
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    47
268
af1d7f48b361 Move helpers/list.py to helper/lists.py to avoid conflict with built-in type
Todd Larsen <tlarsen@google.com>
parents: 267
diff changeset
    48
  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
    49
      offset=request.GET.get('offset'), limit=request.GET.get('limit'))
259
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    50
  
263
9b39d93b677f Make findNearestUsers() code in soc/logic/site/id_user.py more generic and
Todd Larsen <tlarsen@google.com>
parents: 259
diff changeset
    51
  # Fetch one more to see if there should be a 'next' link
299
a1cc853a56e5 Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents: 294
diff changeset
    52
  sponsors = soc.logic.sponsor_logic.getForLimitAndOffset(limit + 1, offset=offset)
263
9b39d93b677f Make findNearestUsers() code in soc/logic/site/id_user.py more generic and
Todd Larsen <tlarsen@google.com>
parents: 259
diff changeset
    53
268
af1d7f48b361 Move helpers/list.py to helper/lists.py to avoid conflict with built-in type
Todd Larsen <tlarsen@google.com>
parents: 267
diff changeset
    54
  context['pagination_form'] = helper.lists.makePaginationForm(request, limit)
259
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    55
  
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    56
  list_templates = {'list_main': 'soc/list/list_main.html',
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    57
                    'list_pagination': 'soc/list/list_pagination.html',
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    58
                    'list_row': 'soc/group/list/group_row.html',
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    59
                    'list_heading': 'soc/group/list/group_heading.html'}
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    60
                      
268
af1d7f48b361 Move helpers/list.py to helper/lists.py to avoid conflict with built-in type
Todd Larsen <tlarsen@google.com>
parents: 267
diff changeset
    61
  context = helper.lists.setList(request, context, sponsors, 
259
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    62
                                 offset, limit, list_templates)
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    63
                                 
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    64
  context['group_type'] = 'Sponsor'
74eb6b01c82c Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    65
272
00cea07656c0 Move helpers/response_helpers.py to helper/responses.py.
Todd Larsen <tlarsen@google.com>
parents: 268
diff changeset
    66
  return helper.responses.respond(request, template, context)