A full Django project packaged for installation
Project description
Github
https://github.com/RobertNagy299/django-webshop
PyPi
https://pypi.org/project/band-landing-page-webshop/0.2.0/
Demo Video
Test coverage
I used the coverage package and Django's built in testing framework to
achieve at least 50% test coverage for all major python files.
Coverage report can be seen in the demo video
Code quality
I used Flake8 and bandit to assure that my code follows Pythonic coding standards, and that it doesn't contain any vulnerabilities.
The results of the code analysis can be seen in the demo video.
Features
The website includes a dark/light mode switch, and every page is responsive and looks great on any device!
The site consists of the following pages:
-
Homepage
- Jumbotron with a 'contact us' call-to-action button
- A grid view of the band members, with images and short descriptions
-
Shop
- Grid view of the items
- "Add to cart" buttons
- Users can change the quantity of the items
-
Contact
- Contact form, where users can enter their email and their message
-
Concerts
- A Bootstrap Carousel element contains images and short descriptions of concerts
-
News
- This page contains a form, that users can use to subscribe to the newsletter
-
Cart
- The cart page contains the items the user has put in their shopping cart
- Users can remove items, or proceed to checkout
- Clicking the checkout button will open the Stripe Checkout page.
-
Custom admin page for composing a letter
- This page is only available for site admins
- This page contains a form, which admins can use to send an email to everyone who is subscribed to the newsletter
- Admins can include a call-to-action button
- Furthermore, they can include unique discounts with the CTA button
- The discounts work as unique llinks, only available if the user clicks on the button.
-
Newsletter
- Users can subscribe
- Users can unsubscribe (each email contains the unsubscribe link which is based on a UUID token)
- The site admin can send a letter to all subscribers with a simple form on a custom admin view
- It is not possible to subscribe with the same email address multiple times
- All form fields are validated on the backend
- The sent emails are based on an html template to make them look good, but there is also a fallback in case the html couldn't be rendered in the email
- Users cannot reach the admin site
- Subscribed users are stored in a database
- Unsubscribed users are deleted from the database
-
Contact form
- Users can fill out a contact form
- The form is validated on the backend
- The form is saved in a database
- An email is sent to the site admin containing the contents of the contact form upon a successful submission
-
Shop
- Webshop with Stripe (third party payment processor integration)
- Real payments simulated using Stripe's checkout page using the Stripe API
- Real discount coupons and promo codes implemented with Stripe API (These can be created and sent from the custom admin page - send-newsletter.html - just tick the "include CTA button" checkbox and then specify the percentage and duration)
- Coupon expiration handled on the UI and backend
Installation notes:
-
Create a virtual environment (recommended)
python -m venv venvsource venv/bin/activate
On Windows:venv\Scripts\activate
-
Install the package
- Run the installation command (Can be found on PyPi)
- Run the installation command (Can be found on PyPi)
-
Set up environment variables
- Create a .env file in your project root:
- Create all environment variables (see below)
-
Run migrations
run-myproject migrate
-
Create a superuser - also known as an admin (optional)
run-myproject createsuperuser
-
Run the development server
run-myproject runserver
-
Then open your browser and go to
http://127.0.0.1:8000
Environment variables:
SECURITY WARNING: keep the secret key used in production secret!
SECURITY WARNING: don't run with debug turned on in production!
SECRET_KEY = config("SECRET_KEY")
DEBUG = config("DEBUG", cast=bool)
DEFAULT_HOST_BASE_URL = config("DEFAULT_HOST_BASE_URL")
Email config
EMAIL_BACKEND = config("EMAIL_BACKEND") EMAIL_HOST = config("EMAIL_HOST") EMAIL_PORT = config("EMAIL_PORT") EMAIL_USE_TLS = config("EMAIL_USE_TLS", cast=bool) EMAIL_HOST_USER = config("EMAIL_HOST_USER")
Not your actual Gmail password! Use an App Password.
EMAIL_HOST_PASSWORD = config("EMAIL_HOST_PASSWORD")
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SYSADMIN_DEFAULT_EMAIL_RECIPIENT = config("SYSADMIN_DEFAULT_EMAIL_RECIPIENT")
Stripe setup
STRIPE_SECRET_KEY = config("STRIPE_SECRET_KEY")
STRIPE_PUBLISHABLE_KEY = config("STRIPE_PUBLISHABLE_KEY")
Example .env file:
SECRET_KEY='asd'
EMAIL_BACKEND='youremailbackend'
EMAIL_HOST='yourhost.example.com'
EMAIL_PORT=1521
EMAIL_USE_TLS=True
EMAIL_HOST_USER='yourname@gmail.com'
EMAIL_HOST_PASSWORD='acde efgh ijkl mnop'
SYSADMIN_DEFAULT_EMAIL_RECIPIENT='admin@gmail.com'
DEBUG=False
DEFAULT_HOST_BASE_URL="http://127.0.0.1:8000"
DB_ENGINE='dbengine'
DB_NAME='dbname'
STRIPE_SECRET_KEY='stripe_secret_key'
STRIPE_PUBLISHABLE_KEY='stripe_publishable_key'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file band_landing_page_webshop-1.0.0.tar.gz.
File metadata
- Download URL: band_landing_page_webshop-1.0.0.tar.gz
- Upload date:
- Size: 6.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b47450781ce7956812454935e3f3bbfc0978804469d9774e6f8cf68e7a4cadc9
|
|
| MD5 |
1311f3195d87df91b29cecb55e804b0f
|
|
| BLAKE2b-256 |
d69c1c7e4e010ebda2a68a85c107206b4b600403e88362a12e7d4ae6f2a62bc0
|
File details
Details for the file band_landing_page_webshop-1.0.0-py3-none-any.whl.
File metadata
- Download URL: band_landing_page_webshop-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
caf2654c6182398414e8ea1f2e2561907021933440bb576130d427267332a689
|
|
| MD5 |
9ad7043f1d047965c0690d37a26666dd
|
|
| BLAKE2b-256 |
07a5cd05b40d404ee7976e9d5f403ff10c9e7c2f8562c77c222d64f15e75689f
|