ADI Assistant
Introduction
ADI Assistant is a web based app designed to help Approved Driving Instructors (ADIs) and Potential Driving Instructors (PDIs) run their business. This initial release has basic features to store customer information and record income and expenses as "Transactions".
There is potential for many more features beyond this initial site.
Code Institute Milestone 4 Project
Table of Contents
- Project Goals
- User Experience
- Scope
- Features
- Technologies Used
- Testing
- Deployment
- Credits
- Acknowledgements
Project Goals
The main goeals of this project are:
Site Owner
- To provide a valuable tool for Driving Instructors to run their business more easily.
- To provide the tool on a subscription basis to help fund it's further development.
- Adding customers will be available to non-subscribed users.
- Adding transactions will only be available to users with a subscription.
Site User
-
To make storing and updating customer and financial information quick and easy.
-
To be able to record information on the go without having to spend hours entering receipts.
In Future
- To integrate with feely available online calendering and contact services to leverage their capabilities without 'reinventing the wheel'.
- To provide insight into pupils' performance based on their own progress record and test results.
- Provide data based on the above that will highlight areas of developement for the ADI or PDI.
- To provide a resource of publicly available information that ADI's and PDI's can contribute to based on their own experiences.
Target Audience
- Approved Driving Instructors (ADIs)
- Potential Driving Instructors (PDIs)
User Stories
As an ADI I want to be able to:
-
Easily sign up to the site so I can browse the features and decide if I want to subscribe.
-
Use my Google account to sign up to the site.
-
Add my customers(pupils) to the site.
-
Record financial transactions on the site and link them to a Customer where applicable.
-
Set my own accoutning code structure to record my transactions against for ease of producing financial records.
In the future:
- Import my contacts from Google Contacts
- Download a list of my appointments(lessons) from Google Calendar, automatically link them to customers and add them to my Transactions as income.
As a PDI I want to be able to:
- User all of the features of an ADI for free.
Scope
Based on the goals of this project I have used Django to build this site. It's database manangement structure and templating features, as well as the extensive extensions available, make this an ideal choice for building a dynamic web application with robust user authentication and payment features.
In development SQL Lite will be used for the database and in production Postgresql.
Design
I have used the Bootstrap 5 framework with limited customisations.
For a future release I will more greatly customise the colour scheme of the site to make it more unique.
Database
The database schema shows the various models used in the project as well as models not yet implemented with a view to future features.
Typography
I have chosen the Quicksand font because I wanted something that is clear and easy to read, scales well and looks prefessional without being boring.
Features
- Sign up for an account manually.
- Sign up for an account using Google.
- Browse the site and create Customers without a subscription.
- Subscribe to either a 12 month or month by month plan.
- Add user own unique set of Accounting Codes in order to create financial transactions.
- Add Transactions to record income and expenditure.
- Manage subscription with an option to cancel.
Technologies Used
Languages
- HTML5
- CSS3
- Javascript (From W3C How To)
- Python
Frameworks, libraries and other tools
Google Fonts Site fonts and icons
Testing
Deployment
Stripe
The following instructions are based on a subscription model.
-
Register for an account at stripe.com
-
Click on Developers in the top right of the navigation.
-
On the left, click on API keys
-
Copy the values of the publishable & secret keys
-
In your local environment(.env) and heroku, create environment variables STRIPE_TEST_PUBLIC_KEY, STRIPE_TEST_SECRET_KEY with the publishable and secret key values.
Also include:
STRIPE_LIVE_MODE =False STRIPE_LIVE_SECRET_KEY =pk_live_
There are several different applications that need to be configured to run this application locally or on a cloud based service like Heroku.
Amazon WebServices
-
Create an account at aws.amazon.com.
-
Go to the AWS Management console under My Account.
-
Open the S3 application and create an S3 bucket named "ci-ms4-adi-assistant".
-
In the Object Ownership section ensure ACLs enabled is selected and Bucked owner preferred.
-
Uncheck the "Block All Public access setting".
-
Acknowledge that the bucket will be public.
-
In the Properties section scroll down to Static Website Hosting and click edit.
-
Enable the setting and set the index.html and the error.html values to these generic values as they're not used.
index.html error.html
-
In the Permissions section scroll down to the CORS configuration and paste in this configuration:
[ { "AllowedHeaders": [ "Authorization" ], "AllowedMethods": [ "GET" ], "AllowedOrigins": [ "*" ],"ExposeHeaders": [] } ]
-
From the top of this page find your ARN and copy it.
-
In the permissions section click edit on the bucket policy and set the following:
Policy type: S3 Bucket Principal: * Actions: GetObject Amazon Resource Name (ARN): [paste what you copied above e.g. arn:aws:s3::: ...]
-
click Add Statement, then Generate Policy, copy this policy into the policy editor.
-
Add /* to the end of the Resource: value.
-
In the permissions section click edit on the Access control list(ACL)
-
tick the box next to Everyone(public access)
-
The bucket is created, the next step is to open the IAM application to set up access
-
Create a new user group named "ci-ms4-adi-assistant"
-
Add the AmazonS3FullAccess policy permission for the user group
-
Go to Policies and click "Create New Policy"
-
Click Import Managed Policy, search for S3 and import AmazonS3FullAccess
-
In the JSON editor, update the policy Resource to include your ARN:
"Resource": [ "arn:aws:s3::: ...", "arn:aws:s3::: .../*", ]
-
Click Review Policy, give it a name and description then click "Create Policy"
-
Go to Groups > Manage your group > Attach Policy > Search for the policy you just created > select it > click Attach Policy.
-
Go to Users click Add user
-
Set the username to something like [your-project]-staticfiles-user
-
Select "Programmatic access" for the access type, click next
-
Add the user to the user group ci-ms4-adi-assistant by ticking the box
-
Click through to the last page where you can click Create user
-
Download the CSV file that will give you the users AWS_SECRET_ACCESS_KEY and AWS_ACCESS_KEY_ID
!!!YOU WILL NOT BE ABLE TO DO THIS AGAIN SO MUST DO IT NOW.
Heroku
I have used Heroku to deploy this site. If you would like to do the same follow these steps.
- Within your project directory create a .gitignore file & an .env file
- Install decouple
using pip3 install decouple
- Open .env and enter following environment variables:
SECRET_KEY =...your secret key goes here... DEBUG =True STRIPE_TEST_PUBLIC_KEY =...your stripe public test key goes here... STRIPE_TEST_SECRET_KEY =...your stripe secrect key goes here... STRIPE_LIVE_MODE =False # Change to True in production DJSTRIPE_WEBHOOK_SECRET =whsec_xxx STRIPE_LIVE_SECRET_KEY =sk_live_
- Add .env to the .gitignore file so this senstive information is not pushed to Github
- In a bash terminal type
pip3 freeze __local > requirements.txt
- Type
echo web: python app.py > Procfile
(note the capital P of Procfile) - Open the Procfile and remove any blank line from the bottom
git add
thengit push
these files to your repository- Visit heroku.com and sign in or sign up
- Click the New button > Create new app in the top right
- Enter a unique app name, this is unique to all of Heroku, not just your account
- Select the region closest to you
- Click Create app
- Make sure you're on the Deploy tab and select GitHub from Deployment Method
- Check that your GitHub account name is showing
- Type part of the name of your repo to search and click Search
- Click connect for the repo you want to connect
- Select the Settings tab
- Click Reveal config vars
- Enter the config vars as set in your .env file above
- Ensure that your Procfile and requirements.txt files are committed and pushed to GitHub
- Return to the Deploy tab
- Enable automatic deployments
- Select the branch (usually main) and click Deploy Branch
- Once the app been deployed, click on the Open app tab at the top right of the page.
Forking the GitHub Repository
If you would like to fork this respository so you can make changes without affecting the original please follow these steps:
- Log into your GitHub account and find the repository.
- Click 'Fork' (last button on the top right of the repository page).
- You will then have a copy of the repository in your own GitHub account.
Making a Local Clone
In order to make a clone of this repository to work on locally, follow these steps:
- Log into your GitHub account and find the repository.
- Click on the 'Code' button (next to 'Add file').
- To clone the repository using HTTPS, under clone with HTTPS, copy the link.
- For SSH, click the SSH tab and copy that link.
- Then open Git Bash.
- Change the current working directory to where you want the cloned directory to be made.
- In your IDE's terminal type 'git clone' followed by the URL you copied.
- Press Enter.
- Your local clone will now be made.
Credits
https://www.reddit.com/r/learnpython/comments/3hy3k5/pythonic_way_of_adding_classactive_to_navbar/
๐Determining input type on Django form
https://stackoverflow.com/questions/28877165/how-to-check-field-type-in-django-form
https://ordinarycoders.com/blog/article/django-stripe-monthly-subscription
https://testdriven.io/blog/django-stripe-subscriptions/
๐Getting social token from AllAuth for accessing Google account
https://stackoverflow.com/questions/30888487/django-get-the-social-token-form-allauth
https://www.section.io/engineering-education/django-google-oauth/