app/soc/logic/accounts.py
author Pawel Solyga <Pawel.Solyga@gmail.com>
Sat, 22 Nov 2008 22:44:02 +0000
changeset 568 6713617751b4
parent 543 280a1ac6bcc1
child 592 be98a2f5d8a2
permissions -rw-r--r--
Remove inheritance from PolyModel in Answer and Linkable model. Replace PolyModel inheritance with base.ModelWithFieldAttributes. A little explanation why we are trying to get rid of PolyModel. We decided to use PolyModel in order to get support for model inheritance in App Engine, however as we know this was a hacky workaround which added inheritance_line property to each model. Recent commits which added Linkable model caused our data viewer in admin console to show only one model "Linkable" since all of the classes inherited from it. Basically datastore viewer was useless plus we had a really big mess in datastore since everything was of one kind (Linkable). It's almost like creating one huge table in SQL database. Upcoming commits will eliminate all usage of PolyModel and finally remove PolyModel from our repository. We are still using inheritance however this doesn't modify how models are saved in data store so basically it's like copy and paste of properties from parent models. Patch by: Pawel Solyga, Sverre Rabbelier
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
112
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     2
#
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     4
#
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     8
#
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    10
#
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    15
# limitations under the License.
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    16
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    17
"""Basic Google Account and User (Model) query functions.
112
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    18
"""
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    19
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    20
__authors__ = [
229
a46c238be8db Show link to /site/user/list on /site/user/lookup when User is not found.
Todd Larsen <tlarsen@google.com>
parents: 223
diff changeset
    21
  '"Chen Lunpeng" <forever.clp@gmail.com>',
112
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    22
  '"Todd Larsen" <tlarsen@google.com>',
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    23
  ]
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    24
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    25
390
d12c95ade374 Remove unused imports, fix too long lines and indentions.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 355
diff changeset
    26
from google.appengine.api import users
131
Todd Larsen <tlarsen@google.com>
parents: 112
diff changeset
    27
309
7190b224c701 Made the existing code use the new soc.logic.models
Sverre Rabbelier <srabbelier@gmail.com>
parents: 305
diff changeset
    28
from soc.logic import models
543
280a1ac6bcc1 Merge soc/logic/out_of_band.py into soc/views/out_of_band.py. Merge
Todd Larsen <tlarsen@google.com>
parents: 512
diff changeset
    29
from soc.views import out_of_band
112
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    30
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    31
import soc.models.user
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    32
import soc.logic.models.user
112
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    33
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    34
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    35
def isDeveloper(account=None):
164
afdf502c6cc4 Documentation updates and one typo fix.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 141
diff changeset
    36
  """Returns True if a Google Account is a Developer with special privileges.
131
Todd Larsen <tlarsen@google.com>
parents: 112
diff changeset
    37
  
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    38
  Since it only works on the current logged-in user, if account matches the
138
e1167bdf71a4 Improve the __doc__ string of isIdDeveloper() to explain better how it now
Todd Larsen <tlarsen@google.com>
parents: 137
diff changeset
    39
  current logged-in Google Account, the App Engine Users API function
e1167bdf71a4 Improve the __doc__ string of isIdDeveloper() to explain better how it now
Todd Larsen <tlarsen@google.com>
parents: 137
diff changeset
    40
  user.is_current_user_admin() is checked.  If that returns False, or
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    41
  account is not the currently logged-in user, the is_developer property of
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    42
  the User entity corresponding to the Google Account is checked next.
138
e1167bdf71a4 Improve the __doc__ string of isIdDeveloper() to explain better how it now
Todd Larsen <tlarsen@google.com>
parents: 137
diff changeset
    43
  
e1167bdf71a4 Improve the __doc__ string of isIdDeveloper() to explain better how it now
Todd Larsen <tlarsen@google.com>
parents: 137
diff changeset
    44
  This solves the "chicken-and-egg" problem of no User entity having its
e1167bdf71a4 Improve the __doc__ string of isIdDeveloper() to explain better how it now
Todd Larsen <tlarsen@google.com>
parents: 137
diff changeset
    45
  is_developer property set, but no one being able to set it.
137
0f572149449d Make isIdDeveloper() also able to check an is_developer Boolean property in
Todd Larsen <tlarsen@google.com>
parents: 136
diff changeset
    46
  
131
Todd Larsen <tlarsen@google.com>
parents: 112
diff changeset
    47
  Args:
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    48
    account: a Google Account (users.User) object; if not supplied,
137
0f572149449d Make isIdDeveloper() also able to check an is_developer Boolean property in
Todd Larsen <tlarsen@google.com>
parents: 136
diff changeset
    49
      the current logged-in user is checked
131
Todd Larsen <tlarsen@google.com>
parents: 112
diff changeset
    50
  """
299
a1cc853a56e5 Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents: 263
diff changeset
    51
a1cc853a56e5 Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents: 263
diff changeset
    52
  # Get the currently logged in user
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    53
  current = users.get_current_user()
299
a1cc853a56e5 Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents: 263
diff changeset
    54
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    55
  if not (account or current):
137
0f572149449d Make isIdDeveloper() also able to check an is_developer Boolean property in
Todd Larsen <tlarsen@google.com>
parents: 136
diff changeset
    56
    # no Google Account was supplied or is logged in, so an unspecified
0f572149449d Make isIdDeveloper() also able to check an is_developer Boolean property in
Todd Larsen <tlarsen@google.com>
parents: 136
diff changeset
    57
    # User is definitely *not* a Developer
0f572149449d Make isIdDeveloper() also able to check an is_developer Boolean property in
Todd Larsen <tlarsen@google.com>
parents: 136
diff changeset
    58
    return False
131
Todd Larsen <tlarsen@google.com>
parents: 112
diff changeset
    59
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    60
  if (((not account) or (account == current))
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    61
      and users.is_current_user_admin()):
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    62
    # no account supplied, or current logged-in user, and that user is in the
299
a1cc853a56e5 Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents: 263
diff changeset
    63
    # Administration->Developers list in the App Engine console
a1cc853a56e5 Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents: 263
diff changeset
    64
    return True
a1cc853a56e5 Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents: 263
diff changeset
    65
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    66
  if not account:
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    67
    account = current
299
a1cc853a56e5 Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents: 263
diff changeset
    68
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    69
  user = models.user.logic.getForFields({'account': account}, unique=True)
137
0f572149449d Make isIdDeveloper() also able to check an is_developer Boolean property in
Todd Larsen <tlarsen@google.com>
parents: 136
diff changeset
    70
0f572149449d Make isIdDeveloper() also able to check an is_developer Boolean property in
Todd Larsen <tlarsen@google.com>
parents: 136
diff changeset
    71
  if not user:
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    72
    # no User entity for this Google Account, and account is not the
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    73
    # currently logged-in user, so there is no conclusive way to check the
137
0f572149449d Make isIdDeveloper() also able to check an is_developer Boolean property in
Todd Larsen <tlarsen@google.com>
parents: 136
diff changeset
    74
    # Administration->Developers list in the App Engine console
0f572149449d Make isIdDeveloper() also able to check an is_developer Boolean property in
Todd Larsen <tlarsen@google.com>
parents: 136
diff changeset
    75
    return False
0f572149449d Make isIdDeveloper() also able to check an is_developer Boolean property in
Todd Larsen <tlarsen@google.com>
parents: 136
diff changeset
    76
  
0f572149449d Make isIdDeveloper() also able to check an is_developer Boolean property in
Todd Larsen <tlarsen@google.com>
parents: 136
diff changeset
    77
  return user.is_developer
131
Todd Larsen <tlarsen@google.com>
parents: 112
diff changeset
    78
Todd Larsen <tlarsen@google.com>
parents: 112
diff changeset
    79
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    80
def isAccountAvailable(new_account,
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    81
                       existing_user=None, existing_key_name=None):
262
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
    82
  """Returns True if Google Account is available for use by existing User.
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
    83
  
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
    84
  Args:
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    85
    new_account: a Google Account (users.User) object with a (possibly)
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    86
      new email
262
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
    87
    existing_user: an existing User entity; default is None, in which case
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
    88
      existing_key_name is used to look up the User entity
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
    89
    existing_key_name: the key_name of an existing User entity, used
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
    90
      when existing_user is not supplied; default is None
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
    91
  """
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
    92
  if not existing_user:
309
7190b224c701 Made the existing code use the new soc.logic.models
Sverre Rabbelier <srabbelier@gmail.com>
parents: 305
diff changeset
    93
    existing_user = models.user.logic.getFromKeyName(existing_key_name)
262
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
    94
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
    95
  if existing_user:
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
    96
    old_email = existing_user.account.email()
262
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
    97
  else:
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
    98
    old_email = None
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
    99
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
   100
  if new_account.email().lower() == old_email.lower():
262
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
   101
    # "new" email is same as existing User wanting it, so it is "available"
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
   102
    return True
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
   103
  # else: "new" email truly is new to the existing User, so keep checking
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
   104
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
   105
  if not models.user.logic.getForFields({'account': new_account},
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
   106
                                        unique=True):
262
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
   107
    # new email address also does not belong to any other User,
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
   108
    # so it is available
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
   109
    return True
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
   110
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
   111
  # email does not already belong to this User, but to some other User
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
   112
  return False
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
   113
52a42831d9d6 Factor out an isIdAvailable() function from EditForm.clean_id() in
Todd Larsen <tlarsen@google.com>
parents: 245
diff changeset
   114
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
   115
# TODO(tlarsen): make this generic for any Linkable and move elsewhere
512
aae25d2b4464 Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents: 499
diff changeset
   116
def getUserFromLinkIdOr404(link_id):
aae25d2b4464 Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents: 499
diff changeset
   117
  """Like getUserFromLinkId but expects to find a user.
112
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   118
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   119
  Raises:
543
280a1ac6bcc1 Merge soc/logic/out_of_band.py into soc/views/out_of_band.py. Merge
Todd Larsen <tlarsen@google.com>
parents: 512
diff changeset
   120
    out_of_band.Error if no User entity is found
112
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   121
  """
512
aae25d2b4464 Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents: 499
diff changeset
   122
  user = models.user.logic.getForFields({'link_id': link_id},
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 457
diff changeset
   123
                                        unique=True)
112
4d9895fb15bc Consolidate functions dealing with Google Accounts and look-up of User entities
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   124
299
a1cc853a56e5 Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents: 263
diff changeset
   125
  if user:
a1cc853a56e5 Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents: 263
diff changeset
   126
    return user
a1cc853a56e5 Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents: 263
diff changeset
   127
543
280a1ac6bcc1 Merge soc/logic/out_of_band.py into soc/views/out_of_band.py. Merge
Todd Larsen <tlarsen@google.com>
parents: 512
diff changeset
   128
  raise out_of_band.Error(
512
aae25d2b4464 Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents: 499
diff changeset
   129
      'There is no user with a "link ID" of "%s".' % link_id, status=404)