def makeBuildAbandoned(blogNo): """Function specifically for fully populating the database from all recovered blogs.""" blogId, url, lastUpdate, posts = pullBlogFilter(blogNo) if blogId: fn, ln, gn = nameGenerate() profile = Profile( fname = fn, lname = ln, gender = gn, age = ageGenerate(), location = locationGenerate(), species = Species.abandoned, blog_id = blogId, blog_url = url, last_login = lastUpdate ) profile.position = profile.id assignImages(profile) for post in posts: newPost = Post( post_profile=profile, date_published=post[1], post_content=re.sub('<[^<]+?>', '', post[2]) ) newPost.save() return profile return None
def makeTaggedPost(profile, content, tagname): """Creates and returns a new Post object assigned to supplied Profile. Takes as input a Profile object, a content string, and an id for a Tag object. """ newPost = Post( post_content=content, post_profile=profile, date_published=timezone.now() ) newPost.save() newPost.tags.add(Tag.objects.filter(name=tagname)[0]) newPost.save() return newPost
def makePosts(profile): """Creates Post objects from posts of a recovered blog from source data. Returns a blog id, url, and last updated. Requires Profile to assign created Posts. """ blogId, url, lastUpdate, posts = pullBlog(None) for post in posts: newPost = Post( post_profile=profile, date_published=post[1], post_content=re.sub('<[^<]+?>', '', post[2]) ) newPost.save() return blogId, url, lastUpdate