Giter VIP home page Giter VIP logo

flask-shipping's Introduction

flask-base

Circle CI Code Climate Issue Count python3.x python2.x

flask-base

A Flask application template with the boilerplate code already done for you.

Documentation available at http://hack4impact.github.io/flask-base.

What's included?

  • Blueprints
  • User and permissions management
  • Flask-SQLAlchemy for databases
  • Flask-WTF for forms
  • Flask-Assets for asset management and SCSS compilation
  • Flask-Mail for sending emails
  • gzip compression
  • Redis Queue for handling asynchronous tasks
  • ZXCVBN password strength checker
  • CKEditor for editing pages

Demos

Home Page:

home

Registering User:

registering

Admin Editing Page:

edit page

Admin Editing Users:

edit user

Setting up

Create your own repository from this Template

Navigate to the main project page and click the big, green "Use this template" button at the top right of the page. Give your new repository a name and save it.

Clone the repository
$ git clone https://github.com/YOUR_USERNAME/REPO_NAME.git
$ cd REPO_NAME
Initialize a virtual environment

Windows:

$ python3 -m venv venv
$ venv\Scripts\activate.bat

Unix/MacOS:

$ python3 -m venv venv
$ source venv/bin/activate

Learn more in the documentation.

Note: if you are using a python before 3.3, it doesn't come with venv. Install virtualenv with pip instead.

(If you're on a Mac) Make sure xcode tools are installed
$ xcode-select --install
Add Environment Variables

Create a file called config.env that contains environment variables. Very important: do not include the config.env file in any commits. This should remain private. You will manually maintain this file locally, and keep it in sync on your host.

Variables declared in file have the following format: ENVIRONMENT_VARIABLE=value. You may also wrap values in double quotes like ENVIRONMENT_VARIABLE="value with spaces".

  1. In order for Flask to run, there must be a SECRET_KEY variable declared. Generating one is simple with Python 3:

    $ python3 -c "import secrets; print(secrets.token_hex(16))"
    

    This will give you a 32-character string. Copy this string and add it to your config.env:

    SECRET_KEY=Generated_Random_String
    
  2. The mailing environment variables can be set as the following. We recommend using Sendgrid for a mailing SMTP server, but anything else will work as well.

    MAIL_USERNAME=SendgridUsername
    MAIL_PASSWORD=SendgridPassword
    

Other useful variables include:

Variable Default Discussion
ADMIN_EMAIL [email protected] email for your first admin account
ADMIN_PASSWORD password password for your first admin account
DATABASE_URL data-dev.sqlite Database URL. Can be Postgres, sqlite, etc.
REDISTOGO_URL http://localhost:6379 Redis To Go URL or any redis server url
RAYGUN_APIKEY None API key for Raygun, a crash and performance monitoring service
FLASK_CONFIG default can be development, production, default, heroku, unix, or testing. Most of the time you will use development or production.
Install the dependencies
$ pip install -r requirements.txt
Other dependencies for running locally

You need Redis, and Sass. Chances are, these commands will work:

Sass:

$ gem install sass

Redis:

Mac (using homebrew):

$ brew install redis

Linux:

$ sudo apt-get install redis-server

You will also need to install PostgresQL

Mac (using homebrew):

brew install postgresql

Linux (based on this issue):

sudo apt-get install libpq-dev
Create the database
$ python manage.py recreate_db
Other setup (e.g. creating roles in database)
$ python manage.py setup_dev

Note that this will create an admin user with email and password specified by the ADMIN_EMAIL and ADMIN_PASSWORD config variables. If not specified, they are both [email protected] and password respectively.

[Optional] Add fake data to the database
$ python manage.py add_fake_data

Running the app

$ source env/bin/activate
$ honcho start -e config.env -f Local

For Windows users having issues with binding to a redis port locally, refer to this issue.

Gettin up and running with Docker

Currently we have a Dockerfile intended for testing purposes and it automates the whole cycle of running the application, setting up the database and redis.

How to use the docker file

In only three simple steps :

  • change the variables MAIL_USERNAME , MAIL_PASSWORD and SECRET_KEY
  • `docker build -t <image_name> .
  • docker run -it -d -p 5000:5000 --name <container name> <image_name> /bin/bash
  • To run in foreground mode docker run -it -p 5000:5000 --name <container name> <image_name> /bin/bash
Note

A more robust version with docker-compose is being developed to separate redis in separate container and allow the deployment of production-level applications automatically without the need of manual provisioning

Formatting code

Before you submit changes to flask-base, you may want to autoformat your code with python manage.py format.

Contributing

Contributions are welcome! Please refer to our Code of Conduct for more information.

Documentation Changes

To make changes to the documentation refer to the Mkdocs documentation for setup.

To create a new documentation page, add a file to the docs/ directory and edit mkdocs.yml to reference the file.

When the new files are merged into master and pushed to github. Run mkdocs gh-deploy to update the online documentation.

Related

https://medium.freecodecamp.com/how-we-got-a-2-year-old-repo-trending-on-github-in-just-48-hours-12151039d78b#.se9jwnfk5

License

MIT License

flask-shipping's People

Contributors

h1tman1978 avatar dependabot[bot] avatar

Watchers

James Cloos avatar  avatar

flask-shipping's Issues

Redo README file

Current README file was from the flask-base template. Needs to be redone for this project.

Data Model

Here's a list of tables and their fields that need to be implemented in this app:

ADDRESSES:

address_id: Primary Key field (can be an integer for right now, might be changed in production) Required
attention: Foreign Key field to USER table. Required. (should display <user.first_name><user.last_name>)
company: String field. Required
address1: String field. Required
address2: String field. Required
city: String field. Required
state_province: string field. Optional (not required on all foreign shipments)
postal_code: string field. Required
country: string field. Optional (not required on Domestic shipments.)
template_name: String Field. Optional (used to store the address as a template)

USERS (needed for demo purposes. Eventually will be replaced with query to bluepages:)

user_id: Primary Key Field
first_name: String field. Required.
last_name: String field. Required.
email: String field. Required.
user_name: string field, required
password_hash: string field, required
slack_handle: string field, required. (Needs to have validation that the string starts with "@")

HANDLING_UNIT:

case_number: Primary Key Field 12 digit Integer field. Required
instruction_id: Foreign Key Field to Shipping_Instruction table
type: string field (drop down field with box, pallet, case, drum, crate as options) Required
length: float number representing the length of the handling unit. Optional for creating instruction, mandatory for shipping
width: same as length
height: same as length
weight: integer field (weights will be rounded up to the nearest whole unit.) Optional for creating instruction, mandatory for shipping
has_shipped: Boolean Field
tracking_number: String Field. Required when shipped
carrier: String Field. Required when shipped

CONTENTS:

content_id: Primary Key Field. Integer Field. Required
case_id: Foreign Key Field linking to Handling Unit table. (The relationship should be a many-to-one relationship with 1 handling unit linking to many contents data) Required.
is_machine: Boolean Field. Required. Flaggable field to distinguish between parts and machines. If true part_number will be displayed as "Machine Type-Model" instead of "Part Number" on the web app.
quantity: Integer Field. Required.
part_number: String Field. Required. Holds either the part number or MTM of the machine.
serial_number: String Field. required if is_machine is true

SHIPPING_INSTRUCTION:

instruction_id: Primary Key Field. Integer Field. Required
SI_number: String Field, Required. (Should be auto generated by the system with XXMMDDYY-HHMMSS format where XX is the creator's initials.)
has_chemicals: Boolean Field. Required (Corresponds to Question A in HAZMAT Shipping Section)
is_magnatized: Boolean Field. Required (Corresponds to Question B in HAZMAT Shipping Section)
has_batteries: Boolean Field. Required (Corresponds to Question C in HAZMAT Shipping Section)
reason_for_shipment: String Field. Required
originator_certification: DateTime Field. Required. (Corresponds to "I certify that the above information is true and correct." popup.)
manager_approval_required: Boolean Field. Required. (Domestic shipments should default to False, International to True)
manager_approval_timestamp: DateTime Field for when the manager approves shipment
finance_approval_required: Boolean Field. Required. (Domestic shipments should default to False, International to True)
finance_approval_timestamp: DateTime Field for when the finance approves shipment

Main Page should have SI search field.

Users should be able to search for any SI and pull up the completed form. If they are the creator of the instruction or work in the shipping department, the form will be editable. Otherwise it will not be.

Branding

Since we're currently creating a demo for IBM, let's brand the site with their logo which is attached.
_ibm logo4-removebg-preview

if we rename this image file with a generic term such as logo.png and then use the same generic term in our code, we'll be able to use this across projects

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.