app/soc/views/helper/redirects.py
author Lennard de Rijk <ljvderijk@gmail.com>
Sun, 25 Jan 2009 16:17:33 +0000
changeset 985 f0b02777f403
parent 981 61a6a8d304dc
child 1003 b13da1ddcd50
permissions -rw-r--r--
Added getListRequestsRedirect to redirects.py. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
611
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     2
#
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     4
#
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     8
#
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    10
#
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    16
639
1f92bd41b914 Some docstring fixes in few modules (soc.views.helper soc.views.models.base).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 620
diff changeset
    17
"""Redirect related methods.
611
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    18
"""
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    19
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    20
__authors__ = [
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    21
  '"Sverre Rabbelier" <sverre@rabbelier.nl>',
985
f0b02777f403 Added getListRequestsRedirect to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 981
diff changeset
    22
  '"Lennard de Rijk" <ljvderijk@gmail.com>',
611
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    23
  ]
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    24
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    25
891
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
    26
from google.appengine.ext import db
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
    27
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
    28
654
68bafa9f719f Fixed the 'New Host' link
Sverre Rabbelier <srabbelier@gmail.com>
parents: 652
diff changeset
    29
def getInviteRedirect(entity, params):
667
f96095df1433 Some more import sorting fixes and docstring typos in program modules and soc.views.helper.redirects module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 654
diff changeset
    30
  """Returns the invitation redirect for the specified entity.
654
68bafa9f719f Fixed the 'New Host' link
Sverre Rabbelier <srabbelier@gmail.com>
parents: 652
diff changeset
    31
  """
68bafa9f719f Fixed the 'New Host' link
Sverre Rabbelier <srabbelier@gmail.com>
parents: 652
diff changeset
    32
68bafa9f719f Fixed the 'New Host' link
Sverre Rabbelier <srabbelier@gmail.com>
parents: 652
diff changeset
    33
  result ='/%s/invite/%s' % (
698
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    34
      params['url_name'], entity.key().name())
654
68bafa9f719f Fixed the 'New Host' link
Sverre Rabbelier <srabbelier@gmail.com>
parents: 652
diff changeset
    35
68bafa9f719f Fixed the 'New Host' link
Sverre Rabbelier <srabbelier@gmail.com>
parents: 652
diff changeset
    36
  return result
68bafa9f719f Fixed the 'New Host' link
Sverre Rabbelier <srabbelier@gmail.com>
parents: 652
diff changeset
    37
667
f96095df1433 Some more import sorting fixes and docstring typos in program modules and soc.views.helper.redirects module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 654
diff changeset
    38
652
02323664d532 Cleanups in preparation of general selector view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 643
diff changeset
    39
def getCreateRedirect(entity, params):
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 639
diff changeset
    40
  """Returns the create program redirect for the specified entity.
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 639
diff changeset
    41
  """
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 639
diff changeset
    42
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 639
diff changeset
    43
  result ='/%s/create/%s' % (
698
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    44
      params['url_name'], entity.key().name())
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 639
diff changeset
    45
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 639
diff changeset
    46
  return result
620
e74e0b74625f Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 611
diff changeset
    47
667
f96095df1433 Some more import sorting fixes and docstring typos in program modules and soc.views.helper.redirects module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 654
diff changeset
    48
611
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    49
def getEditRedirect(entity, params):
620
e74e0b74625f Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 611
diff changeset
    50
  """Returns the edit redirect for the specified entity.
611
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    51
  """
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    52
698
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    53
  return '/%s/edit/%s' % (
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    54
      params['url_name'], entity.key().name())
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    55
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    56
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    57
def getPublicRedirect(entity, params):
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    58
  """Returns the public redirect for the specified entity.
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    59
  """
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    60
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    61
  return '/%s/show/%s' % (
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    62
      params['url_name'], entity.key().name())
885
f46b689e19eb Changed the redirect in club application overview to the correct page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 858
diff changeset
    63
f46b689e19eb Changed the redirect in club application overview to the correct page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 858
diff changeset
    64
858
e79e7a22326f Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents: 797
diff changeset
    65
def getExportRedirect(entity, params):
e79e7a22326f Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents: 797
diff changeset
    66
  """Returns the export redirect for the specified entity.
e79e7a22326f Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents: 797
diff changeset
    67
  """
e79e7a22326f Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents: 797
diff changeset
    68
e79e7a22326f Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents: 797
diff changeset
    69
  return '/%s/export/%s' % (
e79e7a22326f Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents: 797
diff changeset
    70
      params['url_name'], entity.key().name())
e79e7a22326f Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents: 797
diff changeset
    71
885
f46b689e19eb Changed the redirect in club application overview to the correct page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 858
diff changeset
    72
923
5a10f6db154b Hook up the 'home' view for site and program
Sverre Rabbelier <srabbelier@gmail.com>
parents: 920
diff changeset
    73
def getHomeRedirect(entity, params):
946
db4134853d64 Add missing dots in soc.views.helper.redirects module function docstrings.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 940
diff changeset
    74
  """Returns the home redirect for the specified entity.
923
5a10f6db154b Hook up the 'home' view for site and program
Sverre Rabbelier <srabbelier@gmail.com>
parents: 920
diff changeset
    75
  """
5a10f6db154b Hook up the 'home' view for site and program
Sverre Rabbelier <srabbelier@gmail.com>
parents: 920
diff changeset
    76
5a10f6db154b Hook up the 'home' view for site and program
Sverre Rabbelier <srabbelier@gmail.com>
parents: 920
diff changeset
    77
  return '/%s/home/%s' % (
5a10f6db154b Hook up the 'home' view for site and program
Sverre Rabbelier <srabbelier@gmail.com>
parents: 920
diff changeset
    78
      params['url_name'], entity.key().name())
5a10f6db154b Hook up the 'home' view for site and program
Sverre Rabbelier <srabbelier@gmail.com>
parents: 920
diff changeset
    79
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 698
diff changeset
    80
def getReviewRedirect(entity, params):
946
db4134853d64 Add missing dots in soc.views.helper.redirects module function docstrings.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 940
diff changeset
    81
  """Returns the redirect to review the specified entity.
797
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 698
diff changeset
    82
  """
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 698
diff changeset
    83
  
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 698
diff changeset
    84
  return '/%s/review/%s' % (
0bc3f950d7cf Added basic review functionality for club applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 698
diff changeset
    85
      params['url_name'], entity.link_id)
698
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    86
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    87
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    88
def getCreateRequestRedirect(entity, params):
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    89
  """Returns the create request redirect for the specified entity.
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    90
  """
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    91
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    92
  result ='/request/create/%s/%s/%s' % (
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    93
      params['group_scope'], params['url_name'], entity.key().name())
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    94
a953f0676699 Added a public redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents: 676
diff changeset
    95
  return result
620
e74e0b74625f Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 611
diff changeset
    96
e74e0b74625f Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 611
diff changeset
    97
985
f0b02777f403 Added getListRequestsRedirect to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 981
diff changeset
    98
def getListRequestsRedirect(entity, params):
f0b02777f403 Added getListRequestsRedirect to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 981
diff changeset
    99
  """Returns the redirect for the List Requests paged for the given
f0b02777f403 Added getListRequestsRedirect to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 981
diff changeset
   100
  Group entity and Group View params.
f0b02777f403 Added getListRequestsRedirect to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 981
diff changeset
   101
  """
f0b02777f403 Added getListRequestsRedirect to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 981
diff changeset
   102
f0b02777f403 Added getListRequestsRedirect to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 981
diff changeset
   103
  result = '/%s/list_requests/%s' % (
f0b02777f403 Added getListRequestsRedirect to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 981
diff changeset
   104
      params['url_name'], entity.key().name())
f0b02777f403 Added getListRequestsRedirect to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 981
diff changeset
   105
f0b02777f403 Added getListRequestsRedirect to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 981
diff changeset
   106
  return result
f0b02777f403 Added getListRequestsRedirect to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 981
diff changeset
   107
f0b02777f403 Added getListRequestsRedirect to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 981
diff changeset
   108
981
61a6a8d304dc Added getProcessRequestRedirect method to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 946
diff changeset
   109
def getProcessRequestRedirect(entity, _):
61a6a8d304dc Added getProcessRequestRedirect method to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 946
diff changeset
   110
  """Returns the redirect for processing the specified request entity
61a6a8d304dc Added getProcessRequestRedirect method to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 946
diff changeset
   111
  """
61a6a8d304dc Added getProcessRequestRedirect method to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 946
diff changeset
   112
61a6a8d304dc Added getProcessRequestRedirect method to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 946
diff changeset
   113
  result = '/%s/process_request/%s/%s' % (
61a6a8d304dc Added getProcessRequestRedirect method to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 946
diff changeset
   114
      entity.role, entity.scope_path, entity.link_id)
61a6a8d304dc Added getProcessRequestRedirect method to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 946
diff changeset
   115
61a6a8d304dc Added getProcessRequestRedirect method to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 946
diff changeset
   116
  return result
61a6a8d304dc Added getProcessRequestRedirect method to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 946
diff changeset
   117
61a6a8d304dc Added getProcessRequestRedirect method to redirects.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 946
diff changeset
   118
932
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   119
def getSelectRedirect(entity, params):
946
db4134853d64 Add missing dots in soc.views.helper.redirects module function docstrings.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 940
diff changeset
   120
  """Returns the pick redirect for the specified entity.
932
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   121
  """
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   122
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   123
  if entity:
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   124
    result = '/%s/pick?scope_path=%s&field=%s&continue=%s' % (
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   125
        params['url_name'], entity.key().name(),
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   126
        params['field_name'], params['return_url'])
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   127
  else:
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   128
    result = '/%s/pick?field=%s&continue=%s' % (
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   129
        params['url_name'], params['field_name'], params['return_url'])
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   130
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   131
  return result
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   132
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   133
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   134
def getReturnRedirect(return_url, field):
946
db4134853d64 Add missing dots in soc.views.helper.redirects module function docstrings.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 940
diff changeset
   135
  """Returns a function that has return_url and field embedded.
932
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   136
  """
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   137
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   138
  def wrapped(entity, params):
946
db4134853d64 Add missing dots in soc.views.helper.redirects module function docstrings.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 940
diff changeset
   139
    """Returns the return redirect for the specified entity.
932
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   140
    """
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   141
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   142
    result = '%s?field=%s&value=%s' % (
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   143
        return_url, field, entity.link_id)
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   144
    return result
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   145
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   146
  return wrapped
2b72d0315254 Add redirects for the new pick view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 930
diff changeset
   147
940
a40056afef83 Changed the access checks to comply with state in request.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 932
diff changeset
   148
def getInviteAcceptedRedirect(entity, _):
620
e74e0b74625f Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 611
diff changeset
   149
  """Returns the redirect for accepting an invite.
e74e0b74625f Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 611
diff changeset
   150
  """
e74e0b74625f Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 611
diff changeset
   151
920
39badbfb80be Added the new way to process invites for club_admin only.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 891
diff changeset
   152
  return '/%s/accept_invite/%s/%s' % (
620
e74e0b74625f Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 611
diff changeset
   153
      entity.role, entity.scope_path, entity.link_id)
885
f46b689e19eb Changed the redirect in club application overview to the correct page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 858
diff changeset
   154
929
7431d7770197 Renamed redirect methods to comply with the rest of the module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 923
diff changeset
   155
7431d7770197 Renamed redirect methods to comply with the rest of the module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 923
diff changeset
   156
def getInviteProcessRedirect(entity, _):
930
7e88fba647b1 Added missing changes from r1522.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 929
diff changeset
   157
  """Returns the redirect for processing an invite.
920
39badbfb80be Added the new way to process invites for club_admin only.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 891
diff changeset
   158
  """
39badbfb80be Added the new way to process invites for club_admin only.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 891
diff changeset
   159
39badbfb80be Added the new way to process invites for club_admin only.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 891
diff changeset
   160
  return '/request/process_invite/%s/%s/%s' % (
39badbfb80be Added the new way to process invites for club_admin only.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 891
diff changeset
   161
      entity.scope_path, entity.role, entity.link_id)
885
f46b689e19eb Changed the redirect in club application overview to the correct page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 858
diff changeset
   162
929
7431d7770197 Renamed redirect methods to comply with the rest of the module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 923
diff changeset
   163
885
f46b689e19eb Changed the redirect in club application overview to the correct page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 858
diff changeset
   164
def getApplicantRedirect(entity, params):
f46b689e19eb Changed the redirect in club application overview to the correct page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 858
diff changeset
   165
  """Returns the redirect for processing accepted Applications.
f46b689e19eb Changed the redirect in club application overview to the correct page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 858
diff changeset
   166
  """
f46b689e19eb Changed the redirect in club application overview to the correct page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 858
diff changeset
   167
f46b689e19eb Changed the redirect in club application overview to the correct page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 858
diff changeset
   168
  return '/%s/applicant/%s' % (
f46b689e19eb Changed the redirect in club application overview to the correct page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 858
diff changeset
   169
      params['url_name'], entity.link_id)
f46b689e19eb Changed the redirect in club application overview to the correct page.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 858
diff changeset
   170
891
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   171
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   172
def getToSRedirect(presence):
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   173
  """Returns link to 'show' the ToS Document if it exists, None otherwise.
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   174
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   175
  Args:
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   176
    presence: Presence entity that may or may not have a tos property
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   177
  """
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   178
  if not presence:
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   179
    return None
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   180
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   181
  try:
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   182
    tos_doc = presence.tos
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   183
  except db.Error:
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   184
    return None
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   185
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   186
  if not tos_doc:
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   187
    return None
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   188
3d40190f35b6 Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents: 885
diff changeset
   189
  return getPublicRedirect(tos_doc, {'url_name': 'document'})