Esempio n. 1
0
    def post(self):
        model = model_from_request(self.request, ProfileModel)
        user = current_user()
        # validate data; on error, redisplay form with error messages
        if not model.validate():
            self.view(model, user)
            return
        user.message_type = "reply"
        user.repeat_times = int(model.repeat_times)
        user.messages_per_day = int(model.messages_per_day)

        # If checkbox is not checked model just doesn't have this attribute
        if hasattr(model, 'account_disabled'):
            user.account_status="disabled"
        else:
            user.account_status="enabled"

        # Building new list of people I follow based on checkboxes value
        new_i_follow_list = []
        for friend in self.friends_list:
            if hasattr(model, friend):
                new_i_follow_list.append(friend)

        # This is the list of users that were removed. Nedd to update
        # followed_by list for them
        removed_list = list(set(self.i_follow_list) - set(new_i_follow_list))

        self.update_followed_by_list(new_i_follow_list, removed_list, user.twitter)
        
        #user.followed_by = ""    
        user.i_follow = ",".join(new_i_follow_list)
        user.put()
        set_current_user(user)

        self.redirect("/")
Esempio n. 2
0
    def post(self):
        model = {}
        username = self.request.get("username")
        password = self.request.get("password")
        
        model["user_name"] = username
        model["password"] = password

        # load user by username and password...
        user = User.all()\
                .filter("username ="******"password ="******"/")
        else:
            model["login"] = "******"
            self.response.out.write(template.render("views/login.html", model))
    def post(self):
        model = model_from_request(self.request, RegisterModel)

        # validate data; on error, redisplay form with error messages
        if not model.validate():
            self.view(model)
            return

        # save new user        
        user = User()
        user.username = model.user_name
        user.email = model.email
        # todo: hash password
        user.password = model.password

        user.put()

        # put him into session
        set_current_user(user)

        # redirect to the home page
        self.redirect("/")
Esempio n. 4
0
    def post(self):
        twitter = Twitter.getInstance()
        model = model_from_request(self.request, RegisterModel)

        # validate data; on error, redisplay form with error messages
        if not model.validate():
            self.view(model)
            return

        # save new user
        user = User()
        user.username = model.twitter_name
        user.twitter = model.twitter_name
        user.email = ""
        pwd_hash = hashlib.md5()
        pwd_hash.update(model.password)
        user.password = pwd_hash.hexdigest()
        user.timezone = ""
        user.next_run_time = 0
        user.message_type = "reply"
        user.account_status = "enabled"
        user.repeat_times = 6
        user.followed_by = ""
        user.i_follow = ""
        user.messages_per_day = 10
        user.default_source_lang = "en"
        user.follow_lang_list = "en"
        user.total_points = 0

        user.put()
        try:
            twitter.api.CreateFriendship(model.twitter_name)
        except:
            pass
        # put him into session
        set_current_user(user)
        # redirect to the home page
        self.redirect("/profile")