Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,44 @@
# Blogger CLI+ORM Project

## Create authors and posts to be persisted to a relational database backend, all within the CLI!
This a a group project that was created by Dan Jacoby and Grant Cummings to showcase our skills we have aquired learning how to interact with a database. The project uses Python along with SQL commands to interact with a sqlite3 database. As a user you will be able to do the following:

## User Stories:

* As a user, I would like to create Blog Posts linked to a specific author
* As a user, I would like to link each post to a specific category
* As a user, I would like to view all Authors
* As a user, I would like to find an author by their ID
* As a user, I would like to find an author by their name
* As a user, I would like to view posts by a specific author
* As a user, I would like to view all posts by all authors
* As a user, I would like to view all posts by a specific category
* As a user, I would like to know how many posts a specific author has created
* As a user, I would like to edit an existing user's name
* As a user, I would like to edit an existing post
* As a user, I would like to delete an author and all the posts linked to that author
* As a user, I would like to delete a specific post

## Requirements:

This a a group project that was created by Don Jacody and Grant Cummings to showcase our skills we have aquired learning how to interact with a database. The project uses Python along with SQL commands to interact with a sqlite3 database. As a user you will be able to do the following:
* User should be able to exit the terminal from the main menu
* When creating an authors name, name must by a string and between 1 and 15 characters
* When creating a new post, user must link the post to an existing author
* If no author exists, user will be prompted to create an author
* For each post, a title must be given and be between 1 and 20 charachters
* For each post, a category must be linked from a list of given categories
* For each post, the user must enter content for the post
* If the user doesn't want to add an author or post, they should be able to navigate back to the main menu
* When searching for author related content, if the author doesn't exist, it should error out
* If the user doesn't want to view author or post related content, they should be able to navigate back to the main menu
* For editing authors, if there are no authors to edit, it should bring the user back to the edit menu
* For editing posts, if there are no posts to edit, it should bring the user back to the edit menu
* If the user doesn't want to edit author or post, they should be able to navigate back to the main menu
* When deleting an author, both the author and the related posts should be deleted
* If the user doesn't want to delete an author or post, they should be able to navigate back to the main menu



## Create authors and posts to be persisted to a relational database backend, all within the CLI!

* Initially choose between a set of options to redirect you to 4 different types of menus that have to do with create, read, update and deleting authors or posts
* Create authors to be intialized with a name and favorite category
Expand Down
9 changes: 8 additions & 1 deletion lib/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,15 @@ def delete_author():
print("Author id is not in list")
author_id = input(f"To remove an author, select an author id from this list {author_ids} ")
selected_author = Author.find_by_id(author_id)
print(f"You deleted {selected_author.name}")
print(f"You deleted {selected_author.name} and all their posts")
author_posts = [post for post in Post.get_all()]
for post in author_posts:
if str(post.author_id) == author_id:
post.delete()
else:
continue
selected_author.delete()

else:
print("There are no authors to delete")
delete_menu()