def get(self): resource_keys = util.param("resource_keys", list) if resource_keys: resource_db_keys = [ndb.Key(urlsafe=k) for k in resource_keys] resource_dbs = ndb.get_multi(resource_db_keys) return helpers.make_response(resource_dbs, model.Resource.FIELDS) resource_dbs, next_cursor = model.Resource.get_dbs() return helpers.make_response(resource_dbs, model.Resource.FIELDS, next_cursor)
def get(self): project_keys = util.param('project_keys', list) if project_keys: project_db_keys = [ndb.Key(urlsafe=k) for k in project_keys] project_dbs = ndb.get_multi(project_db_keys) return helpers.make_response(project_dbs, model.project.FIELDS) project_dbs, project_cursor = model.Project.get_dbs() return helpers.make_response(project_dbs, model.Project.FIELDS, project_cursor)
def get(self): member_keys = util.param('member_keys', list) if member_keys: member_db_keys = [ndb.Key(urlsafe=k) for k in member_keys] member_dbs = ndb.get_multi(member_db_keys) return helpers.make_response(member_dbs, model.member.FIELDS) member_dbs, member_cursor = model.Member.get_dbs() return helpers.make_response(member_dbs, model.Member.FIELDS, member_cursor)
def get(self): user_keys = util.param('user_keys', list) if user_keys: user_db_keys = [ndb.Key(urlsafe=k) for k in user_keys] user_dbs = ndb.get_multi(user_db_keys) return helpers.make_response(user_dbs, model.User.FIELDS) user_dbs, user_cursor = model.User.get_dbs() return helpers.make_response(user_dbs, model.User.FIELDS, user_cursor)
def get(self): repo_keys = util.param('repo_keys', list) if repo_keys: repo_db_keys = [ndb.Key(urlsafe=k) for k in repo_keys] repo_dbs = ndb.get_multi(repo_db_keys) return helpers.make_response(repo_dbs, model.repo.FIELDS) repo_dbs, repo_cursor = model.Repo.get_dbs() return helpers.make_response(repo_dbs, model.Repo.FIELDS, repo_cursor)
def get(self): album_keys = util.param('album_keys', list) if album_keys: album_db_keys = [ndb.Key(urlsafe=k) for k in album_keys] album_dbs = ndb.get_multi(album_db_keys) return helpers.make_response(album_dbs, model.album.FIELDS) album_dbs, album_cursor = model.Album.get_dbs() return helpers.make_response(album_dbs, model.Album.FIELDS, album_cursor)
def get(self): crash_keys = util.param('crash_keys', list) if crash_keys: crash_db_keys = [ndb.Key(urlsafe=k) for k in crash_keys] crash_dbs = ndb.get_multi(crash_db_keys) return helpers.make_response(crash_dbs, model.crash.FIELDS) crash_dbs, crash_cursor = model.Crash.get_dbs() return helpers.make_response(crash_dbs, model.Crash.FIELDS, crash_cursor)
def get(self): person_keys = util.param('person_keys', list) if person_keys: person_db_keys = [ndb.Key(urlsafe=k) for k in person_keys] person_dbs = ndb.get_multi(person_db_keys) return helpers.make_response(person_dbs, model.person.FIELDS) person_dbs, person_cursor = model.Person.get_dbs() return helpers.make_response(person_dbs, model.Person.FIELDS, person_cursor)
def post(self, module_id): module_config_obj = util.param(MODULE_CONFIG) if not module_config_obj: helpers.make_bad_request_exception("`module_config` parameter is expected to be found in the request") meta = {META_KEYWORDS: util.param(META_KEYWORDS), META_DESCRIPTION: util.param(META_DESCRIPTION)} module_config_db = store_module_config(module_config_obj, meta, module_id) return helpers.make_response(module_config_db, model.ModuleConfig.FIELDS)
def get(self): query = model.Story.query() # Retrieve all Story entities root_story_only = util.param('root-stories', bool) if root_story_only: query = query.filter(model.Story.parent_story_key is None); stories_with_items = util.param('stories-with-items', bool) if stories_with_items: query = query.filter(model.Story.story_item_count > 0); story_keys = util.param('story-keys', list) if story_keys: story_db_keys = [ndb.Key(urlsafe=k) for k in story_keys] story_dbs = ndb.get_multi(story_db_keys) return helpers.make_response(story_dbs, model.Story.FIELDS) story_dbs, story_cursor = model.Story.get_dbs(query) fields = {}; fields.update(model.Story.FIELDS); load_items = util.param('load-items', bool); if load_items: fields.update(model.Story.FIELD_STORY_ITEMS); load_childs = util.param('load-childs', bool); if load_childs: fields.update(model.Story.FIELD_CHILD_STORIES); load_parent = util.param('load-parent', bool); if load_parent: fields.update(model.Story.FIELD_PARENT_STORY); return helpers.make_response(story_dbs, fields, story_cursor)
def post(self): username = util.param('username') or util.param('email') password = util.param('password') if not username or not password: return flask.abort(400) if username.find('@') > 0: user_db = model.User.get_by('email', username.lower()) else: user_db = model.User.get_by('username', username.lower()) if user_db and user_db.password_hash == util.password_hash(user_db, password): auth.signin_user_db(user_db) return helpers.make_response(user_db, model.User.FIELDS) return flask.abort(401)
def post(self): args = parser.parse({ 'username': wf.Str(missing=None), 'email': wf.Str(missing=None), 'password': wf.Str(missing=None), }) handler = args['username'] or args['email'] password = args['password'] if not handler or not password: return flask.abort(400) user_db = model.User.get_by( 'email' if '@' in handler else 'username', handler.lower() ) if user_db and user_db.password_hash == util.password_hash(user_db, password): auth.signin_user_db(user_db) return helpers.make_response(user_db, model.User.FIELDS) return flask.abort(401)
def post(self): id = util.param("id", long) key = util.param("key", str) form = ResourceForm() if form.validate(): resource_db = None if key is not None: resource_db = ndb.Key(urlsafe=key).get() elif id is not None: resource_db = model.Resource().get_by("id", id) else: resource_db = model.Resource() populate_resource_db(resource_db, form) resource_db.put() return helpers.make_response(resource_db, model.Resource.FIELDS) return helpers.make_invalid_form_response(form.data, form.errors)
def post(self): id = util.param('id', long) key = util.param('key', str) form = StoryForm() if form.validate(): story_db = None if key is not None: story_db = ndb.Key(urlsafe=key).get(); elif id is not None: story_db = model.Story().get_by('id', id); else: story_db = model.Story(); populate_story_db(story_db, form) story_db.put() return helpers.make_response(story_db, model.Story.FIELDS) return helpers.make_invalid_form_response(form.data, form.errors)
def get(self, language_key): language_db = ndb.Key(urlsafe=language_key).get() if not language_db: helpers.make_not_found_exception('Language %s not found' % language_key) return helpers.make_response(language_db, model.Language.FIELDS)
def get(self): return helpers.make_response(config.CONFIG_DB, model.Config.FIELDS)
def get(self, repo_key): repo_db = ndb.Key(urlsafe=repo_key).get() if not repo_db: helpers.make_not_found_exception('Repo %s not found' % repo_key) return helpers.make_response(repo_db, model.Repo.FIELDS)
def get(self, song_key): song_db = ndb.Key(urlsafe=song_key).get() if not song_db: helpers.make_not_found_exception('song %s not found' % song_key) return helpers.make_response(song_db, model.Song.FIELDS)
def post(self): resource_db = resource_db_from_upload() if resource_db: return helpers.make_response(resource_db, model.Resource.FIELDS) else: flask.abort(500)
def get(self): repo_dbs, repo_cursor = model.Repo.get_dbs() return helpers.make_response(repo_dbs, model.Repo.FIELDS, repo_cursor)
def get(self, key): resource_db = ndb.Key(urlsafe=key).get() if not resource_db: helpers.make_not_found_exception('Resource %s not found' % key) return helpers.make_response(resource_db, model.Resource.FIELDS)
def get(self, lesson_key): """Returns lesson""" lesson_db = ndb.Key(urlsafe=lesson_key).get() if not lesson_db: return helpers.make_not_found_exception("Lesson %s not found" % lesson_key) return helpers.make_response(lesson_db, model.Lesson.FIELDS)
def get(self, module_id): module_config_db = find_by_module_id(module_id) return helpers.make_response(module_config_db, model.ModuleConfig.FIELDS)
def get(self): currency_dbs, currency_cursor = model.Currency.get_dbs() return helpers.make_response(currency_dbs, model.Currency.FIELDS, currency_cursor)
def delete(self, post_key): post_db = ndb.Key(urlsafe=post_key).get() if not post_db: helpers.make_not_found_exception('Post %s not found' % post_key) post_db.key.delete() return helpers.make_response(post_db, model.Post.FIELDS)
def get(self): post_dbs, post_cursor = model.Post.get_dbs() return helpers.make_response(post_dbs, model.Post.FIELDS, post_cursor)
def delete(self, key): filter_db = ndb.Key(urlsafe=key).get() if not filter_db: helpers.make_not_found_exception('Filter %s not found' % key) delete_filter_key(filter_db.key) return helpers.make_response(filter_db, model.Filter.FIELDS)
def get(self): account_dbs, account_cursor = model.Account.get_dbs() return helpers.make_response(account_dbs, model.Account.FIELDS, account_cursor)
def get(self, member_key): member_db = ndb.Key(urlsafe=member_key).get() if not member_db: helpers.make_not_found_exception('member %s not found' % member_key) return helpers.make_response(member_db, model.Member.FIELDS)
def delete(self, price_key): price_db = ndb.Key(urlsafe=price_key).get() if not price_db: helpers.make_not_found_exception('Price %s not found' % price_key) price_db.key.delete() return helpers.make_response(price_db, model.Price.FIELDS)
def get(self): person_dbs, person_cursor = model.Person.get_dbs(user_key=auth.current_user_key()) return helpers.make_response(person_dbs, model.Person.FIELDS, person_cursor)
def delete(self, key): resource_db = ndb.Key(urlsafe=key).get() if not resource_db or resource_db.user_key != auth.current_user_key(): helpers.make_not_found_exception('Resource %s not found' % key) delete_resource_key(resource_db.key) return helpers.make_response(resource_db, model.Resource.FIELDS)
def get(self): issue_dbs, cursors = model.Issue.get_dbs(prev_cursor=True) return helpers.make_response(issue_dbs, model.Issue.FIELDS, cursors)
def get(self): serie_dbs, cursors = model.Serie.get_dbs() return helpers.make_response(serie_dbs, model.Serie.FIELDS, cursors)
def get(self): drawing_dbs, drawing_cursor = model.Drawing.get_dbs() return helpers.make_response(drawing_dbs, model.Drawing.FIELDS, drawing_cursor)
def post(self): resource_db = resource_db_from_upload() if resource_db: return helpers.make_response(resource_db, model.Resource.FIELDS) flask.abort(500)
def get(self): division_dbs, cursors = model.Division.get_dbs() return helpers.make_response(division_dbs, model.Division.FIELDS, cursors)
def get(self): return helpers.make_response( model.Course.query(model.Course.approved == True).fetch(), model.Course.FIELDS)
def get(self): language_dbs, language_cursor = model.Language.get_dbs() return helpers.make_response(language_dbs, model.Language.FIELDS, language_cursor)
def get(self, topic_key): topic_db = ndb.Key(urlsafe=topic_key).get() if not topic_db: helpers.make_not_found_exception("Topic %s not found" % topic_key) return helpers.make_response(topic_db, model.Topic.FIELDS)
def get(self, currency_key): currency_db = ndb.Key(urlsafe=currency_key).get() if not currency_db: helpers.make_not_found_exception('Currency %s not found' % currency_key) return helpers.make_response(currency_db, model.Currency.FIELDS)
def delete(self, user_key): user_db = ndb.Key(urlsafe=user_key).get() if not user_db: helpers.make_not_found_exception('User %s not found' % user_key) delete_user_dbs([user_db.key]) return helpers.make_response(user_db, model.User.FIELDS)
def get(self, team_identity): team = model.Team.query(model.Team.team_identity==team_identity).fetch() return helpers.make_response(team, model.Team.FIELDS)
def get(self): return helpers.make_response(model.Topic.query(model.Topic.approved == True).fetch(), model.Topic.FIELDS)
def delete(self, drawing_key): drawing_db = ndb.Key(urlsafe=drawing_key).get() if not drawing_db: helpers.make_not_found_exception('Drawing %s not found' % drawing_key) drawing_db.key.delete() return helpers.make_response(drawing_db, model.Drawing.FIELDS)
def get(self, key): album_db = ndb.Key(urlsafe=key).get() if not album_db: helpers.make_not_found_exception('Album %s not found' % key) return helpers.make_response(album_db, model.Album.FIELDS)
def get(self, account_key): account_db = ndb.Key(urlsafe=account_key).get() if not account_db: helpers.make_not_found_exception('Account %s not found' % account_key) return helpers.make_response(account_db, model.Account.FIELDS)
def get(self, title): issue = Issue.get_by_id(title) if not issue: helpers.make_not_found_exception('Issue %s not found' % title) app.logger.info("issue found: %s" % title) return helpers.make_response(issue, model.Issue.FIELDS)
def get(self, person_key): person_db = ndb.Key(urlsafe=person_key).get() if not person_db: helpers.make_not_found_exception('Person %s not found' % person_key) return helpers.make_response(person_db, model.Person.FIELDS)
def get(self, course_key): """Returns a course""" course_db = ndb.Key(urlsafe=course_key).get() if not course_db: return helpers.make_not_found_exception('Course %s not found' % course_key) return helpers.make_response(course_db, model.Course.FIELDS)
def get(self): return helpers.make_response(model.Team.query().fetch(), model.Team.FIELDS)
def get(self): comment_dbs, comment_cursor = model.Comment.get_dbs() return helpers.make_response(comment_dbs, model.Comment.FIELDS, comment_cursor)
def get(self, comment_key): comment_db = ndb.Key(urlsafe=comment_key).get() if not comment_db: helpers.make_not_found_exception('Comment %s not found' % comment_key) return helpers.make_response(comment_db, model.Comment.FIELDS)
def delete(self, user_key): user_db = ndb.Key(urlsafe=user_key).get() if not user_db: helpers.make_not_found_exception('User %s not found' % user_key) user_db.key.delete() return helpers.make_response(user_db, model.User.FIELDS)
def get(self): price_dbs, price_cursor = model.Price.get_dbs() return helpers.make_response(price_dbs, model.Price.FIELDS, price_cursor)