def post(self, current_user): research_key = self.__create(current_user, request.json) self.__add_relationship(research_key, current_user) current_user.supervisor_in += 1 current_user.put() add_task(research_key) return created(ResearchIdJson(research_key))
def post(self, current_user, research): forum = Forum(creator_key=current_user.key, research_key=research.key, status=StatusType.ACTIVE, subject=request.json['subject']) forum_key = forum.put() current_user.created_forums += 1 current_user.put() return created(ForumIdJson(forum_key))
def post(self, current_user, forum): message = Message( creator_key=current_user.key, forum_key=forum.key, status=StatusType.ACTIVE, text=request.json['message']) message_key = message.put() current_user.posted_messages += 1 current_user.put() add_task(message_key.id()) return created(MessageIdJson(message_key))
def post(self, current_user): title = request.json['title'] body = request.json['body'] default_image_url = os.environ['DEFAULT_IMAGE'] image_url = request.json.get('image_url', default_image_url) news = News(creator_key=current_user.key, title=title, body=body, image_url=image_url) news_key = news.put() return created(NewsIdJson(news_key))
def post(self): json_request = request.json email = json_request['email'] name = json_request['name'] password = json_request['password'] cv = json_request.get('cv', '') user = User.by_email(email) if user: return bad_request('User with email {0} already exists'.format(email)) user = User(name=name, email=email, cv=cv, is_admin=False, status=StatusType.ACTIVE, hashed_password=hash_password(password)) user_key = user.put() return created(Token(user_key.id()).json())