author | Lennard de Rijk <ljvderijk@gmail.com> |
Wed, 21 Jan 2009 15:35:10 +0000 | |
changeset 871 | 0ec74865eb5e |
parent 865 | 4f96580e1871 |
child 988 | e35b3d98d469 |
permissions | -rw-r--r-- |
308
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
2 |
# |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
# |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
# |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
# |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
|
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
17 |
"""User (Model) query functions. |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
""" |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
|
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
429
e50e18936f06
Fixed typo in e-mail address
Sverre Rabbelier <srabbelier@gmail.com>
parents:
316
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
308
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
22 |
] |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
23 |
|
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
|
722
a59eaa177562
Added getForCurrentAccount to user.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
25 |
from google.appengine.api import users |
865
4f96580e1871
Fix missing import identified by pylint.
Todd Larsen <tlarsen@google.com>
parents:
862
diff
changeset
|
26 |
from google.appengine.ext import db |
722
a59eaa177562
Added getForCurrentAccount to user.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
27 |
|
640
a62a78fe4e43
Added User welcome message.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
533
diff
changeset
|
28 |
from soc.logic.helper import notifications |
308
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
29 |
from soc.logic.models import base |
862
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
30 |
from soc.logic.models.site import logic as site_logic |
316
9efdc7bc3565
Add missing blank lines between imports and sort all of the imports.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
308
diff
changeset
|
31 |
|
308
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
32 |
import soc.models.user |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
33 |
|
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
34 |
|
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
35 |
class Logic(base.Logic): |
499
d22e4fe8e64b
Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
496
diff
changeset
|
36 |
"""Logic methods for the User model. |
308
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
37 |
""" |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
38 |
|
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
39 |
def __init__(self): |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
40 |
"""Defines the name, key_name and model for this entity. |
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
41 |
""" |
655
9635cbaa2dcd
Cleanups to the logic module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
640
diff
changeset
|
42 |
|
9635cbaa2dcd
Cleanups to the logic module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
640
diff
changeset
|
43 |
super(Logic, self).__init__(soc.models.user.User, |
481
94834a1e6c01
Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents:
459
diff
changeset
|
44 |
skip_properties=['former_accounts']) |
308
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
45 |
|
481
94834a1e6c01
Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents:
459
diff
changeset
|
46 |
def isFormerAccount(self, account): |
94834a1e6c01
Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents:
459
diff
changeset
|
47 |
"""Returns true if account is a former account of some User. |
94834a1e6c01
Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents:
459
diff
changeset
|
48 |
""" |
655
9635cbaa2dcd
Cleanups to the logic module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
640
diff
changeset
|
49 |
|
533
ba3309b2fd30
Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents:
512
diff
changeset
|
50 |
# TODO(pawel.solyga): replace 1000 with solution that works for any |
ba3309b2fd30
Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents:
512
diff
changeset
|
51 |
# number of queries |
481
94834a1e6c01
Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents:
459
diff
changeset
|
52 |
users_with_former_accounts = soc.models.user.User.gql( |
94834a1e6c01
Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents:
459
diff
changeset
|
53 |
'WHERE former_accounts != :1', None).fetch(1000) |
655
9635cbaa2dcd
Cleanups to the logic module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
640
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:
459
diff
changeset
|
55 |
for former_account_user in users_with_former_accounts: |
94834a1e6c01
Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents:
459
diff
changeset
|
56 |
if account in former_account_user.former_accounts: |
448
075360be6743
Fix not working former_ids. Add support for "Invalid accounts". Now when id from former_ids tries to create a profile "This account is invalid." error message is displayed. Compare emails in lower cases to prevent changing User email to the same email with different character casing (needs some more testing).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
434
diff
changeset
|
57 |
return True |
655
9635cbaa2dcd
Cleanups to the logic module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
640
diff
changeset
|
58 |
|
448
075360be6743
Fix not working former_ids. Add support for "Invalid accounts". Now when id from former_ids tries to create a profile "This account is invalid." error message is displayed. Compare emails in lower cases to prevent changing User email to the same email with different character casing (needs some more testing).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
434
diff
changeset
|
59 |
return False |
075360be6743
Fix not working former_ids. Add support for "Invalid accounts". Now when id from former_ids tries to create a profile "This account is invalid." error message is displayed. Compare emails in lower cases to prevent changing User email to the same email with different character casing (needs some more testing).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
434
diff
changeset
|
60 |
|
722
a59eaa177562
Added getForCurrentAccount to user.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
61 |
def getForCurrentAccount(self): |
744
cd9bf163473c
Add missing dots, fix imports sorting and too long lines in different modules. Add TODO in soc.views.models.host module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
722
diff
changeset
|
62 |
"""Retrieves the user entity for the currently logged in account. |
722
a59eaa177562
Added getForCurrentAccount to user.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
63 |
|
a59eaa177562
Added getForCurrentAccount to user.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
64 |
If there is no user logged in, or they have no associated User |
a59eaa177562
Added getForCurrentAccount to user.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
65 |
entity, None is returend. |
a59eaa177562
Added getForCurrentAccount to user.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
66 |
""" |
a59eaa177562
Added getForCurrentAccount to user.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
67 |
|
a59eaa177562
Added getForCurrentAccount to user.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
68 |
account = users.get_current_user() |
a59eaa177562
Added getForCurrentAccount to user.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
69 |
|
a59eaa177562
Added getForCurrentAccount to user.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
70 |
if not account: |
a59eaa177562
Added getForCurrentAccount to user.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
71 |
return None |
a59eaa177562
Added getForCurrentAccount to user.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
72 |
|
a59eaa177562
Added getForCurrentAccount to user.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
73 |
user = self.getForFields({'account': account}, unique=True) |
a59eaa177562
Added getForCurrentAccount to user.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
74 |
|
a59eaa177562
Added getForCurrentAccount to user.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
75 |
return user |
a59eaa177562
Added getForCurrentAccount to user.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
655
diff
changeset
|
76 |
|
862
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
77 |
def agreesToSiteToS(self, entity): |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
78 |
"""Returns indication of User's answer to the site-wide Terms of Service. |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
79 |
|
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
80 |
Args: |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
81 |
entity: User entity to check for agreement to site-wide ToS |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
82 |
|
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
83 |
Returns: |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
84 |
True: no site-wide ToS is currently in effect on the site |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
85 |
True: site-wide ToS is in effect *and* User agrees to it |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
86 |
(User explicitly answered "Yes") |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
87 |
False: site-wide ToS is in effect but User does not agree to it |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
88 |
(User explicitly answered "No") |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
89 |
None: site-wide ToS in effect, but User has not answered "Yes" or "No" |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
90 |
(this answer still evaluates to False, denying access to the site, |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
91 |
but can be used to detect non-answer to ask the User to provide the |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
92 |
missing answer) |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
93 |
""" |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
94 |
if not site_logic.getToS(site_logic.getSingleton()): |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
95 |
# no site-wide ToS in effect, so let the User slide for now |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
96 |
return True |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
97 |
|
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
98 |
try: |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
99 |
agrees = entity.agrees_to_tos |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
100 |
except db.Error: |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
101 |
# return still-False "third answer" indicating that answer is missing |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
102 |
return None |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
103 |
|
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
104 |
# make sure the stored value is really a Boolean only |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
105 |
if not agrees: |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
106 |
return False |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
107 |
|
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
108 |
return True |
fac7cb803aaf
Add agreesToSiteToS() logic method to indicate if User accepts site-wide ToS.
Todd Larsen <tlarsen@google.com>
parents:
744
diff
changeset
|
109 |
|
434
a4fc430fefac
Added key field definitions to the User logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
432
diff
changeset
|
110 |
def getKeyValues(self, entity): |
448
075360be6743
Fix not working former_ids. Add support for "Invalid accounts". Now when id from former_ids tries to create a profile "This account is invalid." error message is displayed. Compare emails in lower cases to prevent changing User email to the same email with different character casing (needs some more testing).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
434
diff
changeset
|
111 |
"""See base.Logic.getKeyValues. |
434
a4fc430fefac
Added key field definitions to the User logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
432
diff
changeset
|
112 |
""" |
459
2cfcedaf7c16
Preparation for generic user views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
448
diff
changeset
|
113 |
|
512
aae25d2b4464
Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents:
505
diff
changeset
|
114 |
return [entity.link_id] |
434
a4fc430fefac
Added key field definitions to the User logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
432
diff
changeset
|
115 |
|
459
2cfcedaf7c16
Preparation for generic user views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
448
diff
changeset
|
116 |
def getSuffixValues(self, entity): |
499
d22e4fe8e64b
Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
496
diff
changeset
|
117 |
"""See base.Logic.getSuffixValues. |
459
2cfcedaf7c16
Preparation for generic user views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
448
diff
changeset
|
118 |
""" |
2cfcedaf7c16
Preparation for generic user views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
448
diff
changeset
|
119 |
|
512
aae25d2b4464
Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents:
505
diff
changeset
|
120 |
return [entity.link_id] |
459
2cfcedaf7c16
Preparation for generic user views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
448
diff
changeset
|
121 |
|
434
a4fc430fefac
Added key field definitions to the User logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
432
diff
changeset
|
122 |
def getKeyValuesFromFields(self, fields): |
a4fc430fefac
Added key field definitions to the User logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
432
diff
changeset
|
123 |
"""See base.Logic.getKeyValuesFromFields. |
a4fc430fefac
Added key field definitions to the User logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
432
diff
changeset
|
124 |
""" |
a4fc430fefac
Added key field definitions to the User logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
432
diff
changeset
|
125 |
|
512
aae25d2b4464
Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents:
505
diff
changeset
|
126 |
return [fields['link_id']] |
434
a4fc430fefac
Added key field definitions to the User logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
432
diff
changeset
|
127 |
|
a4fc430fefac
Added key field definitions to the User logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
432
diff
changeset
|
128 |
def getKeyFieldNames(self): |
499
d22e4fe8e64b
Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
496
diff
changeset
|
129 |
"""See base.Logic.getKeyFieldNames. |
434
a4fc430fefac
Added key field definitions to the User logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
432
diff
changeset
|
130 |
""" |
a4fc430fefac
Added key field definitions to the User logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
432
diff
changeset
|
131 |
|
512
aae25d2b4464
Rename link_name to link_id everywhere, regardless of case (so LINK_NAME
Todd Larsen <tlarsen@google.com>
parents:
505
diff
changeset
|
132 |
return ['link_id'] |
434
a4fc430fefac
Added key field definitions to the User logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
432
diff
changeset
|
133 |
|
308
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
134 |
def _updateField(self, model, name, value): |
481
94834a1e6c01
Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents:
459
diff
changeset
|
135 |
"""Special case logic for account. |
308
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
136 |
|
481
94834a1e6c01
Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents:
459
diff
changeset
|
137 |
When the account is changed, the former_accounts field should be appended |
94834a1e6c01
Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents:
459
diff
changeset
|
138 |
with the old account. |
308
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
139 |
""" |
533
ba3309b2fd30
Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents:
512
diff
changeset
|
140 |
if (name == 'account') and (model.account != value): |
481
94834a1e6c01
Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents:
459
diff
changeset
|
141 |
model.former_accounts.append(model.account) |
308
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
142 |
|
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
143 |
return True |
640
a62a78fe4e43
Added User welcome message.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
533
diff
changeset
|
144 |
|
a62a78fe4e43
Added User welcome message.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
533
diff
changeset
|
145 |
def _onCreate(self, entity): |
a62a78fe4e43
Added User welcome message.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
533
diff
changeset
|
146 |
"""Send out a message to welcome the new user. |
a62a78fe4e43
Added User welcome message.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
533
diff
changeset
|
147 |
""" |
a62a78fe4e43
Added User welcome message.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
533
diff
changeset
|
148 |
notifications.sendWelcomeMessage(entity) |
308
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
149 |
|
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
150 |
|
740090cd17c9
Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
151 |
logic = Logic() |