Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dans branch #66

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
fb9f8bb
changed readme
gant802 May 24, 2024
cdb0132
Merge pull request #1 from gant802/grants-branch
gant802 May 24, 2024
907bdaa
added posts.py
gant802 May 24, 2024
91fe2c1
Merge pull request #2 from gant802/grants-branch
gant802 May 24, 2024
e064c69
author
dcjacoby1 May 24, 2024
9afb685
added category att, title property method
dcjacoby1 May 24, 2024
0324ce9
Merge pull request #3 from gant802/dans-branch
dcjacoby1 May 24, 2024
b8b6c6e
add: create and drop table class method for Post
gant802 May 24, 2024
5bb4f63
Merge pull request #4 from gant802/grants-branch
gant802 May 24, 2024
e32602e
property methods content and category
dcjacoby1 May 24, 2024
7b1d95c
Merge pull request #5 from gant802/dans-branch
dcjacoby1 May 24, 2024
9096df8
author.py added name property method
dcjacoby1 May 24, 2024
c2f0603
Merge pull request #6 from gant802/dans-branch
dcjacoby1 May 24, 2024
dd61b81
add: update() method on Post
gant802 May 24, 2024
b8f320f
Merge pull request #7 from gant802/grants-branch
gant802 May 24, 2024
0aa2acd
finished post.py methods
gant802 May 26, 2024
347df5c
Merge pull request #8 from gant802/grants-branch
gant802 May 26, 2024
5a3a5fb
all database methods for author
dcjacoby1 May 26, 2024
b176359
Merge pull request #9 from gant802/dans-branch
dcjacoby1 May 26, 2024
d526535
helper function for write_post and add_author
dcjacoby1 May 27, 2024
5d1efea
Merge pull request #10 from gant802/dans-branch
dcjacoby1 May 27, 2024
36e91c0
added viewing and search functionality
gant802 May 27, 2024
d113f0b
Merge pull request #11 from gant802/grants-branch
gant802 May 27, 2024
21e13d3
edit posts and author
dcjacoby1 May 27, 2024
77949ae
Merge pull request #12 from gant802/dans-branch
dcjacoby1 May 27, 2024
687d1f0
delete function cli setup
dcjacoby1 May 27, 2024
e750d69
Merge pull request #13 from gant802/dans-branch
dcjacoby1 May 27, 2024
4240422
added better visual to found objects
gant802 May 27, 2024
c5712fb
Merge pull request #14 from gant802/grants-branch
gant802 May 27, 2024
6fffaee
Add: delete post functionality
gant802 May 28, 2024
4a1c704
Merge pull request #15 from gant802/grants-branch
gant802 May 28, 2024
9aaaeb8
delete author method
dcjacoby1 May 28, 2024
50ca931
Merge pull request #16 from gant802/dans-branch
dcjacoby1 May 28, 2024
a0ab2bf
add: comments to improve readability
gant802 May 28, 2024
1be9f2a
Merge pull request #17 from gant802/grants-branch
gant802 May 28, 2024
a5f5a7e
Finished readme
gant802 May 28, 2024
e7c1557
Merge pull request #18 from gant802/grants-branch
gant802 May 28, 2024
34fdac8
for delete author - deletes all posts linked to author. added user st…
dcjacoby1 May 28, 2024
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
239 changes: 67 additions & 172 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,172 +1,67 @@
# Phase 3 CLI+ORM Project Template

## Learning Goals

- Discuss the basic directory structure of a CLI.
- Outline the first steps in building a CLI.

---

## Introduction

You now have a basic idea of what constitutes a CLI. Fork and clone this lesson
for a project template for your CLI.

Take a look at the directory structure:

```console
.
├── Pipfile
├── Pipfile.lock
├── README.md
└── lib
├── models
│ ├── __init__.py
│ └── model_1.py
├── cli.py
├── debug.py
└── helpers.py
```

Note: The directory also includes two files named `CONTRIBUTING.md` and
`LICENSE.md` that are specific to Flatiron's curriculum. You can disregard or
delete the files if you want.

---

## Generating Your Environment

You might have noticed in the file structure- there's already a Pipfile!

Install any additional dependencies you know you'll need for your project by
adding them to the `Pipfile`. Then run the commands:

```console
pipenv install
pipenv shell
```

---

## Generating Your CLI

A CLI is, simply put, an interactive script and prompts the user and performs
operations based on user input.

The project template has a sample CLI in `lib/cli.py` that looks like this:

```py
# lib/cli.py

from helpers import (
exit_program,
helper_1
)


def main():
while True:
menu()
choice = input("> ")
if choice == "0":
exit_program()
elif choice == "1":
helper_1()
else:
print("Invalid choice")


def menu():
print("Please select an option:")
print("0. Exit the program")
print("1. Some useful function")


if __name__ == "__main__":
main()
```

The helper functions are located in `lib/helpers.py`:

```py
# lib/helpers.py

def helper_1():
print("Performing useful function#1.")


def exit_program():
print("Goodbye!")
exit()
```

You can run the template CLI with `python lib/cli.py`, or include the shebang
and make it executable with `chmod +x`. The template CLI will ask for input, do
some work, and accomplish some sort of task.

Past that, CLIs can be whatever you'd like, as long as you follow the project
requirements.

Of course, you will update `lib/cli.py` with prompts that are appropriate for
your application, and you will update `lib/helpers.py` to replace `helper_1()`
with a useful function based on the specific problem domain you decide to
implement, along with adding other helper functions to the module.

In the `lib/models` folder, you should rename `model_1.py` with the name of a
data model class from your specific problem domain, and add other classes to the
folder as needed. The file `lib/models/__init__.py` has been initialized to
create the necessary database constants. You need to add import statements to
the various data model classes in order to use the database constants.

You are also welcome to implement a different module and directory structure.
However, your project should be well organized, modular, and follow the design
principal of separation of concerns, which means you should separate code
related to:

- User interface
- Data persistence
- Problem domain rules and logic

---

## Updating README.md

`README.md` is a Markdown file that should describe your project. You will
replace the contents of this `README.md` file with a description of **your**
actual project.

Markdown is not a language that we cover in Flatiron's Software Engineering
curriculum, but it's not a particularly difficult language to learn (if you've
ever left a comment on Reddit, you might already know the basics). Refer to the
cheat sheet in this assignments's resources for a basic guide to Markdown.

### What Goes into a README?

This README serves as a template. Replace the contents of this file to describe
the important files in your project and describe what they do. Each Python file
that you edit should get at least a paragraph, and each function should be
described with a sentence or two.

Describe your actual CLI script first, and with a good level of detail. The rest
should be ordered by importance to the user. (Probably functions next, then
models.)

Screenshots and links to resources that you used throughout are also useful to
users and collaborators, but a little more syntactically complicated. Only add
these in if you're feeling comfortable with Markdown.

---

## Conclusion

A lot of work goes into a good CLI, but it all relies on concepts that you've
practiced quite a bit by now. Hopefully this template and guide will get you off
to a good start with your Phase 3 Project.

Happy coding!

---

## Resources

- [Markdown Cheat Sheet](https://www.markdownguide.org/cheat-sheet/)
# Blogger CLI+ORM Project

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:

* 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
* Create posts to be initialized with a title, content, category and author id
* Find authors by name or id from database
* Find posts by title or id from database
* View all authors
* View all posts
* View all posts by a specific author
* View all posts by a specific category
* View number of posts by an author
* Update authors and posts
* Delete authors and posts
* Exit the program

## How to install and use this application in your local computer

1. Fork and clone the repo to a repository within your GitHub.
2. Open the project in your code editor of choice (ours is VS Code)
3. In your terminal within the the project's folder run "$ pipenv install" to install all dependencies for the project
4. Run "$ pipenv shell" to create a shell environment to use the program
5. Run "$ python lib/cli.py" to use the program within your terminal


## Final note
This is a backend only project and would work much better if there was a frontend when it comes to the amount of posts that can be generated. This project is a representation of the skills we have when interacting with the database of a program.
28 changes: 28 additions & 0 deletions lib/1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# lib/cli.py

from helpers import (
exit_program,
helper_1
)


def main():
while True:
menu()
choice = input("> ")
if choice == "0":
exit_program()
elif choice == "1":
helper_1()
else:
print("Invalid choice")


def menu():
print("Please select an option:")
print("0. Exit the program")
print("1. Some useful function")


if __name__ == "__main__":
main()
Loading