Exemple #1
0
 def get(self,key):
     user      = User()
     userInfo = UserInfo()
     avatar =Avatar()
     user.delete(key)
     userInfo.delete(key)
     avatar.delete(key)
Exemple #2
0
 def post(self):            
     user_key =self.get_secure_cookie("user_key")
     r = None
     
     user_data = {}
     info_data = {}
     
     
     userInfo = UserInfo()
     user = User()
     user.key = user_key
     user.data = user.get(user_key)
     user.data['nickname'] = self.get_argument("user_nickname",None)
     
     userInfo.key = user_key
     
     userInfo_data = userInfo.get(user_key)
     if userInfo_data:
         userInfo.data = userInfo_data
         
     userInfo.data['city']        = self.get_argument("user_city","")
     userInfo.data['url']         = self.get_argument("user_url","")
     userInfo.data['desc']        = self.get_argument("user_description","")
     
     userInfo.post()
     user.post()        
     
     self.redirect('/settings/')
Exemple #3
0
 def getInfo(self,key):
     userInfo = UserInfo()
     userInfo_data = userInfo.get(key)
     userDetail = self.getDetail(key)
     
     if userInfo_data:            
         userDetail['city'] = userInfo_data['city']
         userDetail['desc'] = userInfo_data['desc']
         userDetail['url'] = userInfo_data['url']
     else:
         userDetail['city'] = ''
         userDetail['desc'] = ''
         userDetail['url'] = ''
     return userDetail
Exemple #4
0
    def post(self):
        have_error = False
        username = self.request.get('username')
        password = self.request.get('password')
        confirm = self.request.get('confirm')
        email = self.request.get('email')
        template = 'blog-user-signup-page.html'
        params = {'username': username, 'email': email}

        # validity checks for valid sign up information
        if not self.valid_username(username):
            params['error_inval_username'] = '''Please enter a valid username,
                                                you little minx'''
            have_error = True

        if UserInfo.by_name(username):
            params['error_unavail_username'] = '''This is hard for me to say to
                                                  you, but that username is
                                                  taken'''
            have_error = True

        if not self.valid_password(password):
            params['error_password'] = '''DANGER! PASSWORD DOES NOT COMPUTE!
                                          BLEEP BLORP!'''
            have_error = True
        elif password != confirm:
            params['error_confirm'] = '''Stop it with these mis-matchy
                                         passwords ya jive turkey'''
            have_error = True

        if not self.valid_email(email):
            params['error_inval_email'] = '''UGHHHH we've been over this!'''
            have_error = True

        if UserInfo.by_email(email):
            params['error_unavail_email'] = '''ZOINKS! We already have that
                                               email registered'''
            have_error = True

        if have_error:
            self.render(template, **params)
        else:
            u = UserInfo.register(username, password, email)
            u.put()
            self.login(u)
            self.redirect('/blog/welcome-page')
Exemple #5
0
    def post(self):
        username = self.request.get('username')
        password = self.request.get('password')
        template = 'blog-login.html'
        params = {'username': username, 'password': ''}
        user = UserInfo.login(username, password)

        if not user:
            params['error'] = 'Not valid username and password combination.'
            self.render(template, **params)
        else:
            self.login(user)
            self.redirect('/blog/welcome-page')
Exemple #6
0
 def get_user(self):
     '''Retrieves user id from cookie, checks hmac encryption if user id exists
     in UserInfo database. If user_id exists, returns user_id and user
     entity. If not, returns None for both'''
     user_id_cookie = self.read_secure_cookie('user_id')
     if user_id_cookie:
         user_id = user_id_cookie.split('|')[0]
         user = UserInfo.by_id(int(user_id))
         if not user:
             user_id = None
             user = None
     else:
         user_id = None
         user = None
     return user_id, user