def fill_view_attrs(self): user_agent = self.request.headers['User-Agent'] view = self.view.type self.view.device = device.get_device(user_agent, view) self.view.content.blog_id = '' user = users.get_current_user() if user: user_settings = model.get_user_settings(user.user_id()) if user_settings.blog_id: self.view.content.blog_id = user_settings.blog_id if user_settings.mod_time: self.view.mod_time = user_settings.mod_time.strftime("%Y-%m-%d %H:%M:%S") else: logging.error("This feature cannot perform without user login.")
def post(self): user = users.get_current_user() if user: user_settings = model.get_user_settings(user.user_id()) if self.request.get('delete') == 'yes': user_settings.delete() else: new_id = self.request.get('blog_id') logging.debug("Blog ID: %s", new_id) modified = False if new_id != '' and new_id != user_settings.blog_id: user_settings.blog_id = new_id modified = True if modified: if not user_settings.account: user_settings.account = user user_settings.put() else: logging.error("This feature cannot perform without user login.") self.redirect('/')
def __init__(self): user = users.get_current_user() if user: self.user_settings = model.get_user_settings(user.user_id())