예제 #1
0
 def find_unclaimed(cls, email):
     
     P = cls
     DP = data.DataPoint
     
     handler = data.get_handler('email', email)
     profile = Session.query(P).join(DP).filter(P.user==None).filter(DP.key==u'email').filter(DP.value==handler.normalized).first()
     return profile
예제 #2
0
def get(real_user, user, profile=None, email=None):
    
    if profile: return profile
    
    P = profiles.Profile
    DP = data.DataPoint
    
    #fetch all
    if not profile and not email:
        return user.profile.fetch_teathers()
    
    # for email
    handler = data.get_handler('email', email)
    profile = Session.query(P).join(DP).filter(DP.key==u'email').filter(DP.value==handler.normalized).first()
    return profile
예제 #3
0
파일: user.py 프로젝트: Nullicopter/tethr
 def _to_python(self, value, state):
     # we don't support multiple values, so we run a quick check here (we got a webapp where this was a problem)
     if type(value) != type(u""):
         raise fv.Invalid('You must supply a valid email.', value, state)
     
     handler = data.get_handler('email', value)
     
     P = profiles.Profile
     DP = data.DataPoint
     user = Session.query(users.User).filter(sa.func.lower(users.User.email)==handler.normalized).first()
     profile = Session.query(P).join(DP).filter(P.user!=None).filter(DP.key==u'email').filter(DP.value==handler.normalized).first()
     
     # if this user is the same as the logged in one then don't throw the error -
     # allows keeping old email address when editing contact info
     if (user and user != self.user) or (profile and profile.user != self.user):
         raise fv.Invalid('That user already exists. Please choose another.', value, state)
     return value
예제 #4
0
 def add_data(self, user, key, value, type=u''):
     """
     Blindly adds data to a profile
     """
     if not user:
         raise exceptions.AppException('Gimmie a user', field=u'user', code=exceptions.INVALID)
     
     #we overwrite any keys that were created by this user. 
     q = Session.query(data.DataPoint).filter(data.DataPoint.profile==self)
     q = q.filter(data.DataPoint.key==key)
     q = q.filter(data.DataPoint.owner==user)
     
     d = q.first()
     handler = data.get_handler(key, value)
     
     if d:
         d.value = handler.normalized
     else:
         d = data.DataPoint(profile=self, owner=user, key=key, value=handler.normalized, type=type)
         Session.add(d)
     return d