def get(self): model = {} user = current_user() if user: model["user_name"] = user.username self.response.out.write(template.render('views/index.html', model))
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("/")
def get(self): user = current_user() if not user: self.redirect("/login") else: parameters = {} parameters["total_points"] = User.all().\ filter("twitter =", user.twitter).get().total_points parameters["total_words"] = Dictionary.all().\ filter("twitter_user =", user.twitter).count() self.view(parameters)
def __init__(self): super( Profile, self).__init__() user = current_user() # List of people you follow on twitter who are also languagebot users self.friends_list = self.get_friends_list(user) # List of users you are following on languagebot self.i_follow_list = user.i_follow.split(',') if '' in self.i_follow_list: self.i_follow_list.remove('')
def __init__(self): user = current_user() if user: if user.message_type == "reply": self.is_reply_checked = "checked" if user.message_type == "direct": self.is_direct_checked = "checked" if user.account_status == "disabled": self.is_account_disabled = "checked" else: self.is_account_disabled = ""
def get(self): result = None user = current_user() if user: action = self.request.get("action") if action == "getLatestAnswers": result = getLatestAnswers(user) self.response.out.write(result) if action == "getUsers": result = getUsers() self.response.out.write(result) else: self.error(404) exit
def get(self): user_name = self.request.path.split('/')[-1] viewed_user = User.all().filter("username ="******"") and (viewed_user is None): self.error(404) if viewed_user: parameters = getParameters(viewed_user) self.view(parameters, "views/view_vocabulary.html") elif curr_user: parameters = getParameters(curr_user) self.view(parameters, "views/vocabulary.html")
def post(self): result = None user = current_user() if user: action = self.request.get("action") if action == "editDictEntry": original_word = self.request.get("original") new_string = self.request.get("newentry") result = editDictEntry(user, original_word, new_string) self.response.out.write(result) if action == "deleteDictEntry": word = self.request.get("word") result = deleteDictEntry(user, word) self.response.out.write(result) else: self.error(404) exit
def get(self): user = current_user() if user: self.redirect("/details") else: self.redirect("/login")
def post(self): user = current_user() text = self.request.get("new_word") message_dict = parseMessage(text, '') addNewWord(message_dict, user, None) self.redirect("/vocabulary")
def get(self): user = current_user() model = ProfileModel() self.view(model, user)