def GetInterPostUserId(): user_id = request.args.get('user_id') data = GetInterPostsByUserId(user_id) user = getUserById(user_id) ret_data = [] for p in data: obj = DObject() obj.user_id = user.id obj.post_id = p[0].id obj.first_name = user.first_name obj.last_name = user.last_name obj.community_name = p[1].name obj.title = p[0].title obj.message = p[0].content obj.category = p[0].category obj.timestamp = str(p[0].timestamp) obj.admin_approved = p[0].admin_approved if p[0].file_id: k = get_file_obj(p[0].file_id).key if k is None: obj.file_id = None else: file_id = (k).split(",")[0] obj.file_id = "https://s3.amazonaws.com/s3-cmpe-281/" + file_id else: obj.file_id = None obj.image = "https://d19rpgkrjeba2z.cloudfront.net/e82de29ec673c6fa/static/nextdoorv2/images/avatars/avatar-" + user.first_name[ 0].lower() + ".png" ret_data.append(obj.__dict__) return json.dumps(ret_data)
def PostInterPost(): content = request.json for c_id in content["communityIds"].split(','): InterPostObj = DObject() InterPostObj.title = content["title"] InterPostObj.content = content["content"] InterPostObj.category = content['category'] InterPostObj.timestamp = datetime.datetime.now() InterPostObj.image_ids = content['image_ids'] InterPostObj.user_id = decode_auth_token(content['token']) InterPostObj.community_id = c_id #InterPostObj.post_type = content["postType"] InterPostObj.admin_approved = False InterPostObj.image_ids = content['image_ids'] InsertInterPost(InterPostObj) return json.dumps({"success": True})