Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
7405741
added Alberto for Team Information
olivialba Jul 6, 2023
bc07326
Added Abdulrahamn Aljabali information
aaljabali1 Jul 9, 2023
fd38691
Added Alberto in p1
olivialba Jul 12, 2023
823fba2
Merge pull request #1 from olivialba/Alberto
olivialba Jul 12, 2023
ae339df
Added more team information
olivialba Jul 12, 2023
37849a7
p1.md update from Alberto
olivialba Jul 17, 2023
eb3afcd
Merge pull request #2 from olivialba/Alberto
olivialba Jul 17, 2023
d9c7d3b
Update p1.md
jgeorg24 Jul 17, 2023
e144058
Merge pull request #3 from olivialba/jgeorg24-patch-2
jgeorg24 Jul 17, 2023
31247cb
Update p0.md
jgeorg24 Jul 17, 2023
0e11bea
Merge pull request #4 from olivialba/jgeorg24-patch-4
jgeorg24 Jul 17, 2023
8f0c5e5
Merge pull request #5 from olivialba/main
olivialba Jul 17, 2023
127c1a7
Merge pull request #6 from olivialba/Alberto
olivialba Jul 17, 2023
0b5f1e7
Small formatting cleanup to p1.md
olivialba Jul 17, 2023
d3db5d1
Updated p1.md by aaljabali (AA)
aaljabali1 Jul 17, 2023
590cc7e
Merge branch 'main' into aaljabali-updates
olivialba Jul 17, 2023
6f90f4e
Merge pull request #7 from olivialba/aaljabali-updates
olivialba Jul 17, 2023
0d3c2a0
p1.md
Jul 18, 2023
5151cd0
p0.md
Jul 18, 2023
f6bf53a
Merge pull request #8 from olivialba/alimacnde-patch-2
olivialba Jul 18, 2023
d2d8827
p1.md
Jul 18, 2023
0982d6f
Merge pull request #9 from olivialba/alimacnde-patch-2
olivialba Jul 18, 2023
58c95ef
Task 1 for authentication
olivialba Jul 18, 2023
abd35cf
Add files via upload
jgeorg24 Jul 19, 2023
14916af
Merge pull request #10 from olivialba/jgeorg24-patch-1
jgeorg24 Jul 19, 2023
fcbf875
p1.md
Jul 19, 2023
f3f2633
Merge pull request #11 from olivialba/alimacnde-patch-2
olivialba Jul 19, 2023
79f2767
Merge pull request #12 from olivialba/alimacnde-patch-1
olivialba Jul 19, 2023
6adc5ef
Fixed formatting p1.md
olivialba Jul 19, 2023
a24d89c
Delete classes.puml
jgeorg24 Jul 19, 2023
15eb660
Merge pull request #13 from olivialba/jgeorg24-patch-1
jgeorg24 Jul 19, 2023
142e8ad
Delete packages.png
jgeorg24 Jul 19, 2023
b79a998
Merge pull request #14 from olivialba/jgeorg24-patch-2
jgeorg24 Jul 19, 2023
946233e
Add files via upload
jgeorg24 Jul 19, 2023
e227052
Merge pull request #15 from olivialba/jgeorg24-patch-3
jgeorg24 Jul 19, 2023
2acd20e
Testing package diagram
aaljabali1 Jul 20, 2023
0c27cd5
Merge pull request #16 from olivialba/aaljabali1-patch-1
olivialba Jul 22, 2023
a9dbe8b
updated authentication packages
olivialba Jul 24, 2023
ed7cee7
Updated use cases .puml
olivialba Jul 24, 2023
5406f25
Updated admin.puml
olivialba Jul 24, 2023
a4ec064
Changed guest actor
olivialba Jul 24, 2023
cb90ea6
Updated admin.puml
olivialba Jul 24, 2023
52d00b4
Added Bookstore manager (admin) sequence diagrams
aaljabali1 Jul 24, 2023
71da3c4
Fixed diagrams formatting, names and locations
olivialba Jul 24, 2023
1bb3a7d
Merge pull request #17 from olivialba/aaljabali1-patch-1
olivialba Jul 24, 2023
ea1ac44
Updated admin use cases to fit sequence
olivialba Jul 24, 2023
609cf8c
Changed admin to bookStoreManager
olivialba Jul 24, 2023
e87cd89
Add files via upload
jgeorg24 Jul 24, 2023
62a4bc8
Merge pull request #18 from olivialba/jgeorg24-patch-2
olivialba Jul 24, 2023
042616f
Add files via upload
jgeorg24 Jul 24, 2023
cd22914
Merge pull request #19 from olivialba/jgeorg24-patch-2
jgeorg24 Jul 24, 2023
9e4f61b
Update login.puml
jgeorg24 Jul 24, 2023
7b91f56
Merge pull request #20 from olivialba/jgeorg24-patch-3
jgeorg24 Jul 24, 2023
9ec86c0
Update Logout.puml
jgeorg24 Jul 24, 2023
24895e8
Merge pull request #21 from olivialba/jgeorg24-patch-4
jgeorg24 Jul 24, 2023
3ca98db
Update ViewCart.puml
jgeorg24 Jul 24, 2023
c71a7d2
Merge pull request #22 from olivialba/jgeorg24-patch-5
jgeorg24 Jul 24, 2023
c1454eb
Update register.puml
jgeorg24 Jul 25, 2023
2e28954
Merge pull request #23 from olivialba/jgeorg24-patch-2
jgeorg24 Jul 25, 2023
d7261c0
Update PurchaseCart.puml
jgeorg24 Jul 25, 2023
fba5b09
Merge pull request #24 from olivialba/jgeorg24-patch-3
jgeorg24 Jul 25, 2023
9940db6
Update SearchItems.puml
jgeorg24 Jul 25, 2023
a21049d
Merge pull request #25 from olivialba/jgeorg24-patch-5
jgeorg24 Jul 25, 2023
c096b67
Update ViewOrders.puml
jgeorg24 Jul 25, 2023
a8f990f
Merge pull request #26 from olivialba/jgeorg24-patch-6
jgeorg24 Jul 25, 2023
55b080d
Update ViewProfile.puml
jgeorg24 Jul 25, 2023
e149d16
Merge pull request #27 from olivialba/jgeorg24-patch-8
jgeorg24 Jul 25, 2023
07ea418
Update ViewWishlist.puml
jgeorg24 Jul 25, 2023
0125e20
Merge pull request #28 from olivialba/jgeorg24-patch-9
jgeorg24 Jul 25, 2023
71ee734
Update authentication.auth_tools.puml
jgeorg24 Jul 25, 2023
7e4ae24
Merge pull request #29 from olivialba/jgeorg24-patch-10
jgeorg24 Jul 25, 2023
dd5d843
Add files via upload
jgeorg24 Jul 25, 2023
3383034
Merge pull request #30 from olivialba/jgeorg24-patch-11
jgeorg24 Jul 25, 2023
4c4471c
p2 Task 1 - file location fixing
olivialba Jul 25, 2023
805595e
Added admin panel with 2 buttons, fixed registration css, added can't…
olivialba Jul 26, 2023
7696795
Reworked admin panel and added 'insert new item into database' functi…
olivialba Jul 27, 2023
0a09334
Added admin account to starting_data.sql
olivialba Jul 27, 2023
07e4b42
Added update_product functionality in Admin Panel + rework of Admindm…
olivialba Jul 28, 2023
18caea8
Fixed login not changing session or username, added new homepage navbar
olivialba Jul 28, 2023
957cc2e
Added logout
olivialba Jul 28, 2023
6d208c0
fixed admin_panel css
olivialba Jul 28, 2023
bd6770c
Started implementation of new header for website
olivialba Jul 28, 2023
9072eac
Fixed css style bugs in login and register page
olivialba Jul 28, 2023
3705218
Finished new header for website + changed website style to fit
olivialba Jul 28, 2023
0208311
Changed homepage navbar css style
olivialba Jul 28, 2023
2694104
Added changelog
olivialba Jul 28, 2023
f18fc06
Update CHANGELOG.md
olivialba Jul 28, 2023
d64adf0
Update CHANGELOG.md
olivialba Jul 28, 2023
4ccde08
Added books images
olivialba Jul 29, 2023
a9f203f
Added books to starting_data for database resets
olivialba Jul 29, 2023
4fd2958
Merge branch 'main' of github.com:olivialba/onlineStoreTemplate
olivialba Jul 29, 2023
441ed32
Changed CSS to fit new books products
olivialba Jul 29, 2023
e37725f
Update CHANGELOG.md
olivialba Jul 29, 2023
1d6dc85
Users keep their cart saved even after logging out
olivialba Jul 29, 2023
3b23ab1
Fix: tax_rate was converted to int instead of float
olivialba Jul 29, 2023
b76f8b0
Added rounding to two decimals for total cost
olivialba Jul 29, 2023
238ba64
Added checkout page table with cart info
olivialba Jul 29, 2023
a469345
Added Checkout update quantity of items
olivialba Jul 29, 2023
dd60b54
Updated CHANGELOG.md
olivialba Jul 29, 2023
b969754
Added Sales/Checkout system
olivialba Jul 30, 2023
4cd209f
Fixed Date format where seconds had decimals
olivialba Jul 31, 2023
c9c7dfe
Added view past orders page
olivialba Jul 31, 2023
545671b
Added starting sales to database
olivialba Jul 31, 2023
bf749a8
Update p1.md
olivialba Jul 31, 2023
f8b3ada
Updated CHANGELOG.md
olivialba Jul 31, 2023
667f8bd
Merge branch 'main' of github.com:olivialba/onlineStoreTemplate
olivialba Jul 31, 2023
7023127
Update CHANGELOG.md
olivialba Jul 31, 2023
789a41d
REQ-9: Added stock function to sales and checkout
olivialba Jul 31, 2023
9f6f53f
REQ-5: Admin can now see inventory from admin panel
olivialba Jul 31, 2023
e19a0bb
Fixed some routes
olivialba Jul 31, 2023
98e5956
Updated p3 CHANGELOG
olivialba Jul 31, 2023
63826f1
Added a lot of documentation and comments
olivialba Aug 1, 2023
8b7fa2c
Added about us page + minor fixes
olivialba Aug 1, 2023
6791ffd
Updated README.md
aaljabali1 Aug 7, 2023
9589ac3
Updated about_us.html
aaljabali1 Aug 7, 2023
af42d65
Updated style.css
aaljabali1 Aug 7, 2023
64bdf18
Update header.css
aaljabali1 Aug 7, 2023
94368ef
Merge pull request #31 from olivialba/aaljabali1-patch-1
olivialba Aug 7, 2023
1ce388a
Merge pull request #32 from olivialba/aaljabali1-patch-2
olivialba Aug 7, 2023
1998891
Merge pull request #33 from olivialba/aaljabali1-patch-3
olivialba Aug 7, 2023
2cfef45
Merge pull request #34 from olivialba/aaljabali1-patch-4
olivialba Aug 7, 2023
dc92b63
Fixed REQ-12 and added test for REQ-12
olivialba Aug 7, 2023
31f17b6
Fixed some problems with REQ-5
olivialba Aug 7, 2023
7629158
Added aolivi review for test, fixed REQ-5 testing
olivialba Aug 7, 2023
bf9010b
Updated aolivi_review
olivialba Aug 7, 2023
82c2d02
Add files via upload
jgeorg24 Aug 8, 2023
d841e69
Merge pull request #35 from olivialba/jgeorg24-patch-1
jgeorg24 Aug 8, 2023
2549719
Update jgeorg24_review.md
jgeorg24 Aug 8, 2023
e141476
Merge pull request #36 from olivialba/jgeorg24-patch-2
jgeorg24 Aug 8, 2023
3b73d58
Update db_tests.py
aaljabali1 Aug 8, 2023
f1c940f
Update core_tests.py
aaljabali1 Aug 8, 2023
729f903
Merge pull request #37 from olivialba/aaljabali1-patch-1
jgeorg24 Aug 8, 2023
f9a1098
Merge pull request #38 from olivialba/aaljabali1-patch-2
jgeorg24 Aug 8, 2023
4a1e41b
Update jgeorg24_review.md
jgeorg24 Aug 8, 2023
a860071
Merge pull request #39 from olivialba/jgeorg24-patch-4
jgeorg24 Aug 8, 2023
13120ca
Fixed ../database path not working correctly
olivialba Aug 9, 2023
b49a5a1
Added tests review
aaljabali1 Aug 9, 2023
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
37 changes: 37 additions & 0 deletions P3 CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# P3 Implementation Changelog

## **Changes by Alberto**
### Website:

- **REQ-1:** Added Homepage navbar with home button to redirect to homepage - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/18caea8cbcf944fd41e9b9a98fd1623d5565908e) - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/370521892db1ca19dc27f95c0b657920d2da17db) - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/0208311f4df315586c961a88ccda8a430d727032)
- **REQ-2:** Users can register account into the database and login - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/9072eacd0b405eebb15afbdb7c6357a643ff2616) - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/9072eacd0b405eebb15afbdb7c6357a643ff2616)
- **REQ-3:** Users have their cart saved even after logging out - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/1d6dc85768a670a6f7f3af8e7404e2b336209318)
- **REQ-4:** Customers can now add products to the shopping cart and view the content - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/238ba64e30c9bc58f8ff03d8792e8e08b91e144f)
- **REQ-5:** `Admin Panel` added to manage some database functions. Only accessible through admin login - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/7696795c4466f83ee2be3e97e6510c5d14c7202d) - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/9f6f53fca778f01a1dee26c16d15a982e1f17028) - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/07e4b425f239c1ac5c1d221a535feda6e2512cfc) - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/7696795c4466f83ee2be3e97e6510c5d14c7202d)
- **REQ-6:** Customers can checkout product in the index page, but needs to have an account to checkout - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/b96975418ae36ef286ce214c9c54ddfb7066cafc)
- **REQ-7:** Items are displayed neatly with name, image, info and price - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/a9f203fced50599f64ee3ad2aa8e51ccc65529a1) - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/441ed3288de037ea8bcedc3eafb43a85aafa807f) - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/441ed3288de037ea8bcedc3eafb43a85aafa807f)
- **REQ-8:** Database storing inventory, sales and users' informations - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/545671b11dc075284acd5c714f931c56a2249de1) - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/a9f203fced50599f64ee3ad2aa8e51ccc65529a1) - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/0a0933441cafe76ac1258b12cb1671568431b363)
- **REQ-9:** Added items stock function to keep track of items available, can't buy items if not enough in stock warning - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/789a41d5e2b3bb15d3d537a150a13fb8eeba81dc)
- **REQ-10:** Checkout page will now show total cost of the order - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/238ba64e30c9bc58f8ff03d8792e8e08b91e144f) - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/b76f8b0f67809ad985299cf0dce4e4e627a1d05f)
- **REQ-11:** Admin Panel will now allow admin to update products information - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/07e4b425f239c1ac5c1d221a535feda6e2512cfc)
- **REQ-12:** Admin Panel will now allow admin to add products to database - [COMMIT](https://github.com/olivialba/onlineStoreTemplate/commit/7696795c4466f83ee2be3e97e6510c5d14c7202d)
- Added Header
- Added Logout
- Added Order Page table to see a user's past orders
- Added Users can update quantity of items at checkout
- Changed overall CSS style of the Website
- Changed Login and Register buttons

### Admin Panel:
- Bookstoremanager login will show an Admin panel, the panel is defined in 'admin_panel.html' and 'admin_panel.py'
- Bookstoremanager login info:
- Username: `Admin`
- Password: `Admin`

### Fixed Bugs:
- Prevent: users can't register with 'default' or 'admin' in their username, to prevent bugs
- Fixed: login users didn't change session to their new login
- Fixed: customers can't login if username or password invalid
- Fixed: incorrect and uneven css style for login and register .html pages
- Fixed: Incorrect backend for login-logout
- Fixed: Users now keep their cart saved even after logging out
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Description

This repository contains template code for a simple online store, built for my students in ITSC 3155 - Software Engineering at UNC Charlotte. Since the code is written as a starting template for students' group final projects, this repository should not be seen as a complete, production-ready online store. Functional features like user session management, database access, unit testing, and server-side rendering are included but kept at an abstract level. Users are instructed to fork this repository and customize it to the needs of their own project.
This repository contains code for an online bookstore created by our team based on the ITSC 3155 template. the website displays list of items in stock but one must be logged in to place an order. A customer can log in using the login button or register a new user using the register button.

## How to Use

Expand All @@ -22,7 +22,7 @@ pip3 install -r requirements.txt
The project uses a SQLite database, which is stored in the `database` directory. To create or reset the database, navigate to the `database` directory and run the following command:

```bash
python3 reset_database.py
python3 ./database/reset_database.py
# Note: depending on your system, you may need to use `python3.10` or `py` instead of `python3`
```

Expand Down
129 changes: 129 additions & 0 deletions admin_panel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Admin Panel by Alberto Olivi

from authentication.auth_tools import login_pipeline, update_passwords, hash_password
from flask import Blueprint, Flask, render_template, request
from core_info import sessions, db, admin_add_new_item

admin_panel_bp = Blueprint('admin_panel', __name__)

"""
Used to update product info
First is textfield from which to take value, second is method to use to update said value
"""
field_to_db_update = {
'itemname_update': db.set_item_name,
'info_update': db.set_item_info,
'price_update': db.set_item_price,
'stock_update': db.set_item_stock,
'image_url_update': db.set_item_image_url,
'category_update': db.set_item_category
}


@admin_panel_bp.route('/admin_panel/add-product', methods=['POST'])
def add_product():
"""
Renders the add-product request when the user is at the `/admin_panel/add-product` endpoint with a POST request.
Add product to the database.

args:
- None

returns:
- None

modifies:
- database/store_records.db: add a product to the inventory in the database.
"""
item_name = request.form['itemname']
price = request.form['price']
info = request.form['info']
stock = request.form['stock']
image_url = request.form['image_url']
category = request.form['category']

success, message = admin_add_new_item(db, item_name, price, info, stock, image_url, category)
if success:
print(message)
return render_template('admin_panel.html', product_added=True)
else:
print("Error: ", message)
return render_template('admin_panel.html', error_message=message)


@admin_panel_bp.route('/admin_panel/update-product', methods=['POST'])
def update_product():
"""
Renders the update-product page when the user is at the `/admin_panel/update-product` endpoint with a POST request.
Shows product data and allows for product data to be edited in the database.

args:
- None

returns:
- Data: shows product's data in the /update-product page

modifies:
- database/store_records.db: change a product data
"""

# Button to search for product in database
if 'button_send' in request.form and request.form['button_send'] == 'find_product':
item_id = request.form['itemid']
return render_item_info(item_id)

# Button to update a product in database
elif 'button_send' in request.form and request.form['button_send'] == 'update_product':
item_id = request.form['id_update']
for field, update_info in field_to_db_update.items():
new_value = request.form[field].strip()
if new_value:
update_info(item_id, new_value)
return render_item_info(item_id)

else:
print('Error: Could not detect button pressed. How were you even able to cause this error?')
return render_template('admin_panel.html')


@admin_panel_bp.route('/admin_panel/view-inventory', methods=['POST'])
def view_inventory():
"""
Renders the inventory products when the user is at the `/admin_panel/view-inventory` endpoint with a POST request.
With 'GET' you can go directly to the url even without admin access or log in?

args:
- None

returns:
- None
"""
inventory = db.get_full_inventory()
return render_template('admin_panel.html', inventory=inventory)



def render_item_info(item_id: int):
"""
Get all the product data corresponding to the product item_id from the database.
Used to display data for the 'Update Product' panel

args:
- item_id: integer for product id

returns:
- Render admin_panel page with product/item information
"""
check = db.get_item_name_by_id(item_id)

# Couldn't find item ID in database, send item_not_found error
if check is None:
return render_template('admin_panel.html', item_not_found=True)

name = check['item_name']
info = db.get_item_info_by_id(item_id)['info']
price = db.get_item_price_by_id(item_id)['price']
stock = db.get_item_stock_by_id(item_id)['stock']
image_url = db.get_item_image_url_by_id(item_id)['image_url']
category = db.get_item_category_by_id(item_id)['category']
return render_template('admin_panel.html', item_found=True, item_id=item_id, name=name, info=info, price=price, stock=stock, image_url=image_url, category=category)
Loading