Ejemplo n.º 1
0
    def __preRegister(self, userEmail):
        from dao.user import User
        from main import userclient

        if User.isRegistered(userEmail):
            User.fromEmail(userEmail).setStudy(self.clientName)
        else:
            pendingDoc = {
                'user_email': userEmail,
                'study': self.clientName,
                'last_update': datetime.now()
            }
            # Should I do insert or upsert here? If a user has pre-registered for one
            # study and then pre-registers for another study before registering, do we
            # want to throw an error or just update silently?
            # Update silently for now
            writeResult = get_pending_signup_db().update(
                {'user_email': userEmail}, pendingDoc, upsert=True)
            print 'in __preRegister, writeResult = %s' % writeResult
            if 'err' in writeResult and writeResult['err'] is not None:
                e = Exception()
                e.code = writeResult['err'][0]["code"]
                e.msg = writeResult['err'][0]["errmsg"]
                raise e
        return (get_pending_signup_db().find({
            'study': self.clientName
        }).count(), userclient.countForStudy(self.clientName))
Ejemplo n.º 2
0
 def setUp(self):
     from get_database import get_profile_db, get_uuid_db, get_client_db, get_pending_signup_db
     # Make sure we start with a clean slate every time
     get_client_db().remove()
     get_profile_db().remove()
     get_pending_signup_db().remove()
     get_uuid_db().remove()
Ejemplo n.º 3
0
 def setUp(self):
   from get_database import get_profile_db, get_uuid_db, get_client_db, get_pending_signup_db
   # Make sure we start with a clean slate every time
   get_client_db().remove()
   get_profile_db().remove()
   get_pending_signup_db().remove()
   get_uuid_db().remove()
Ejemplo n.º 4
0
 def getPendingClientRegs(userName):
     studyList = []
     userEmailQuery = {'user_email': userName}
     pendingReg = get_pending_signup_db().find_one(userEmailQuery)
     if pendingReg != None:
         studyList = [pendingReg['study']]
     return studyList
Ejemplo n.º 5
0
 def getPendingClientRegs(userName):
   studyList = []
   userEmailQuery = {'user_email': userName}
   pendingReg = get_pending_signup_db().find_one(userEmailQuery)
   if pendingReg != None:
     studyList = [pendingReg['study']]
   return studyList
Ejemplo n.º 6
0
  def __preRegister(self, userEmail):
    from dao.user import User
    from main import userclient

    if User.isRegistered(userEmail):
      User.fromEmail(userEmail).setStudy(self.clientName)
    else:
      pendingDoc = {
        'user_email': userEmail,
        'study': self.clientName,
        'last_update': datetime.now()}
      # Should I do insert or upsert here? If a user has pre-registered for one
      # study and then pre-registers for another study before registering, do we
      # want to throw an error or just update silently?
      # Update silently for now
      writeResult = get_pending_signup_db().update({'user_email': userEmail}, pendingDoc, upsert=True)
      print 'in __preRegister, writeResult = %s' % writeResult
      if 'err' in writeResult and writeResult['err'] is not None:
        e = Exception()
        e.code = writeResult['err'][0]["code"]
        e.msg = writeResult['err'][0]["errmsg"]
        raise e
    return (get_pending_signup_db().find({'study': self.clientName}).count(),
            userclient.countForStudy(self.clientName))
Ejemplo n.º 7
0
 def deletePendingClientRegs(userName):
     userEmailQuery = {'user_email': userName}
     get_pending_signup_db().remove(userEmailQuery)
Ejemplo n.º 8
0
 def deletePendingClientRegs(userName):
   userEmailQuery = {'user_email': userName}
   get_pending_signup_db().remove(userEmailQuery)