Skip to content
Web Application to submit suggestions for bike parking infrastructure. This is a snapshot repo, active development resides here: https://gitlab.com/bikespace/Bicycle-parking
PLpgSQL Python CSS JavaScript HTML Shell Dockerfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.ebextensions
.vscode
Bicycle_parking
bicycleparking
db
test
.gitattributes
.gitignore
.gitlab-ci.yml
CONTRIBUTING.md
LICENSE
Procfile
README.md
docker-compose.yml
manage.py
mkaddressdb
package-lock.json
package.json
requirements.txt
runtime.txt

README.md

pipeline status

coverage report

Toronto Bike Parking Project

Note: This is a debugging branch and should NOT be merged with the master until and unless the code is updated and stable.

Local Development

To use this project, we will work though the following steps:

  1. Install requirements
  2. Clone this repo
  3. Create a virtualenv in the project root folder
  4. Have a local instance of postgres running
  5. Install ngrok
  6. Code away

We strongly suggest on using virtualenv for python development.

Next we Install python3 on your computer

On mac osx

# On Mac OSX we suggest homebrew, also known as brew
# please visit https://brew.sh/
# follow the on-screen instructions of the website

# hopefully homebrew is installed
# let us now use brew to install python3
brew install python3

On windows

# On windows we suggest chocolatey, also known as choco
# please visit https://chocolatey.org/
# follow the on-screen instructions of the website

# let us now use choco to install python3
choco install python --version 3.6.3
Next we get the projects code setup to run

We now will setup an environment to run the python code of the https://gitlab.com/bikespace/Bicycle-parking project setup on your computer

pip3 install virtualenv

# get the repository of code on your machine and change to the directory
git clone git@gitlab.com:bikespace/Bicycle-parking.git bikespace

# change to the directory
cd bikespace

# setup a virtualenv for python3
virtualenv -p python3 venv
# note "venv" is now the name of the directory containing the python virtualenv

# Use the "venv" you setup earlier for your python3 project buy running the activate script
source venv/bin/activate

#(for windows:)
venv/Scripts/activate

# Install requirements
# Install the requirements from the supplied `requirements.txt`.
pip3 install -r requirements.txt

Database

Docker Workflow

Supplied with the repo is a docker-compose.yml file to get a postgres instance up and running with the postgis extension. The postgis extension is needed for the spatial data we use in the application.

For first time setup it requires a little bit of time in the terminal, so hang in there but once setup it will be smooth for the rest of the development process.

Install docker and docker-compose for your OS.

For Mac and Windows if you install docker, docker-compose is already installed so don't have to worry about that.

Supplied is a docker-compose.yml file for spinning up a containerized postgres with the necessary spatial files loaded already. Feel free to look around in the db folder for all the container startup files.

# To run the docker container of our postgres image
docker-compose -f docker-compose.yml up -d --build

# If all is successfully monitor the logs for first time setup
docker-compose logs -f

Note: Windows users might need to open some files in vim and set the fileformat to unix

:set fileformat=unix

Once all the spatial tables are loaded then the container db instance is ready to go. Keep in mind the port it is running on, in order to not conflict with any other postgres instance you might have running we bind host post to 5435 so that is the port where the postgres instance will be running.

Create the test data

To create test data to work on, for moderation or other purposes, run the test transaction script:

python test/LoadTestDB.py

For Linux:

Open your 5435 port it might be closed by default because of the firewall

#open 5435 code
sudo ufw allow from 127.0.0.1/24  to any port 5435

Start the Django Application

Once all the above steps are complete test by running the django app.

Run migrations to apply the models defined into the database

Run this migrate whenever the models.py for the app has been changed so the changes can be applied to the databases.

# First we run the migrations for the database
python manage.py migrate

# Let us first create a superuser for the admin web page
python manage.py createsuperuser

# Now we can run the django web app
python manage.py runserver

Contributing

See our contributing guidelines

Install ngrok

ngrok is needed to serve the local django application over ssl. To install ngrok, use npm.

Install ngrok globally:

We can use npm or yarn.

With npm:

which npm
npm install ngrok -g

Build client side js

We are using Webpack to bundle the js for the client side. To compile cd into the bicycleparking and run :

npm run local

For hot-reloading setup a watcher:

npm run 

With yarn:

Installing yarn and ngrok on Linux:

$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
$ sudo apt-get update && sudo apt-get install yarn
$ sudo yarn global add ngrok

Build client side js

In the main project directory:

$ yarn postinstall

For hot-reloading: In the bicycleparking directory

$ yarn run watch

# Now run ngrok to serve over https
# ngrok http [please_insert_port_django_is_running_on]
# for example
ngrok http 3000

Project Structure

This is the current project structure, please note:

  • the Bicycle_parking is the main Django Project folder
  • the bicycleparking dir is one of the apps for the project
├── bicycleparking
│   ├── admin.py
│   ├── apps.py
│   ├── geocode.py
│   ├── __init__.py
│   ├── intersection.py
│   ├── migrations
│   ├── models.py
│   ├── node_modules
│   ├── package.json
│   ├── __pycache__
│   ├── Routers.py
│   ├── serializers.py
│   ├── static
│   ├── templates
│   ├── tests.py
│   ├── uploader.py
│   ├── urls.py
│   └── views.py
├── Bicycle_parking
│   ├── __init__.py
│   ├── __pycache__
│   ├── settings
│   ├── static
│   ├── urls.py
│   └── wsgi.py
├── CONTRIBUTING.md
├── db.sqlite3
├── docker-compose.yml
├── HTML_CSS
│   ├── background_images
│   ├── files_old
│   ├── flatpickr.css
│   ├── happening.html
│   ├── icons
│   ├── index.html
│   ├── issue.html
│   ├── map.html
│   ├── mobilesheet.css
│   ├── Open_Sans
│   ├── picture.html
│   ├── stylesheet2.css
│   ├── stylesheet.css
│   ├── success.html
│   └── summary.html
├── LICENSE
├── manage.py
├── mkaddressdb
├── mkintersectiondb
├── node_modules
│   ├── flatpickr
│   ├── leaflet
│   └── leaflet-search
├── package.json
├── package-lock.json
├── Procfile
├── README.md
├── requirements.txt
├── runtime.txt
├── sql
│   ├── intersec2d.sql
│   ├── intersection_types.sql
│   ├── makegisdb.sql
│   └── visit_address.sql
├── test
│   ├── areas.xml
│   ├── geodata_001.xml
│   ├── intersection_test.cpg
│   ├── intersection_test.dbf
│   ├── intersection_test.prj
│   ├── intersection_test.shp
│   ├── intersection_test.shx
│   ├── makeAreas.py
│   ├── removeTestDB.py
│   ├── test_data.sql
│   ├── useaws
│   └── useci
└── venv
    ├── bin
    ├── include
    ├── lib
    ├── pip-selfcheck.json
    └── share

License: MIT

please see the LICENSE file generated using https://choosealicense.com/licenses/mit/

You can’t perform that action at this time.