def post(self): success = User.set_new_password(self.data['token'], self.data['password']) if not success: raise PyError({'msg': 'invalid_token'}) return {'msg': 'password_updated'}
def post(self): email = self.data['email'] password = self.data['password'] new_user = createUser(email, password) if new_user is None: raise PyError({'msg': 'existing_email'}) return {'token': gen_token(new_user)}
def post(self): "Add or remove chapter from provided URL to bookmark list" if self.data['action'] not in ('add', 'remove'): raise PyError({'msg': 'invalid_action'}) chapter = Chapter.get_by_url(self.data['url']) if chapter is None: raise PyError({'msg': 'chapter_not_created'}) if self.data['action'] == 'add': if not self.user.bookmark_chapter(chapter): raise PyError({'msg': 'chapter_already_bookmarked'}) return {} else: if not self.user.unbookmark_chapter(chapter): raise PyError({'msg': 'chapter_not_bookmarked'}) return {}
def post(self): "Add or remove series from provided URL to bookmark list" if self.data['action'] not in ('add', 'remove'): raise PyError({'msg': 'invalid_action'}) series = Series.get_by_url(self.data['url']) if series is None: raise PyError({'msg': 'series_not_created'}) if self.data['action'] == 'add': if not self.user.bookmark_series(series): raise PyError({'msg': 'series_already_bookmarked'}) return {} else: if not self.user.unbookmark_series(series): raise PyError({'msg': 'series_not_bookmarked'}) return {}
def post(self): url = self.data['url'] progress = self.data['progress'] chapter = Chapter.get_by_url(url) if chapter is None: raise PyError('nonexistent_chapter') ChapterProgress.set_progress(self.user.key.id(), progress, chapter.url, chapter.series_url) return {}
def post(self): email = self.data['email'] password = self.data['password'] user = User.auth_with_password(email, password) expires = not self.data['remember'] if user: return { 'token': gen_token(user, expires=expires), 'settings': user.settings, } else: raise PyError({'msg': 'invalid_password'})
def post(self): email = self.data['email'] token = User.generate_reset_password_token(email) if token is None: raise PyError({'msg': 'email_not_found'}) # Email password reset token to user app_name = get_application_id() sender = 'noreply@%s.appspotmail.com' % app_name subject = '%s password reset' % app_name.capitalize() body = """ A password reset has been requested for your account. If you did not request it, simply ignore this email, otherwise visit this link to reset your password: https://%s.appspot.com/reset-password/%s """ % (app_name, token) mail.send_mail(sender, email, subject, body) return {'msg': 'reset_link_sent'}
def post(self): language = self.data['language'] enable_shortcut = self.data['enable_shortcut'] webtoon_mode = self.data['webtoon_mode'] changed_fields = [] if language not in ['en', 'vi']: # TODO: refactor out hardcoded supported language list raise PyError({'msg': 'unsupported_language'}) for field in ['language', 'enable_shortcut', 'webtoon_mode']: if getattr(self.user, field) != locals()[field]: changed_fields.append(field) self.user.language = language self.user.enable_shortcut = enable_shortcut self.user.webtoon_mode = webtoon_mode self.user.put() return { 'changed_fields': changed_fields, }
def get(self): keyword = self.data['keyword'] type = self.data['type'] search_results = {} # {order: [series, series, ...]} if type == 'name': # search by series name func_name = 'search_series' elif type == 'author': # search by author name func_name = 'search_by_author' else: raise PyError('invalid_type') def _search(queue): keyword, site, order = queue.get() search_func = getattr(site, func_name) try: series_list = search_func(unidecode(keyword)) search_results[order] = series_list except Exception: print traceback.format_exc() search_results[order] = [] queue.task_done() q = Queue() # Dirty fix: search Kissmanga (site index 0) only for order, site in enumerate(sites.searchable_sites): q.put((keyword, site, order)) worker = Thread(target=_search, args=(q, )) worker.setDaemon(True) worker.start() q.join() # Get ordered list of series results series = [] for i in sorted(search_results): series.extend(search_results[i]) return series