Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Contribute

OGKevin edited this page May 30, 2017 · 8 revisions

Contribute to community bunq web app

gif


All contributions are welcome, even if they don't pass the tests I'll take a look at it and make the appropriate changes. Of course your pull request must make sense, and should not be something completely random.


Run local development server

If you want to run the entire app locally via the development server you must perform a few setup steps. Before you do the following, it would be smart to set up a virtual environment so that the python modules dont get installed system wide. This app runs on python 3.5.1 so you should get a version of python above that.

Once you have installed Python:

  • install virtualenv by running $ pip isntall virtualenv.

    1. Create a virtualenv by running $ virtualenv -p path/to/python/executable path/where/u/want/your/venv

      Make user you use the python executable of the version you installed.

    2. Starting the virtual environment is OS dependent, follow the instructions based on your os here.

  • install postgresql. Installation steps can vary depending on your OS. Therefore follow the installation steps provided via the link.

    1. Create a database CREATE DATABASE mydb;
    2. login on the database psql -d mydb -U myuser

After you have virtualenv en postgresql set up:

  1. Clone the repo $ git clone  https://github.com/OGKevin/ComBunqWebApp.git and cd to the root directory of the project.
  2. Install the requirements via $ pip install -r requirements.txt and npm install. (You must have pip and npm installed)
  3. Set up a postgres database, start it and change the the following section in the settings.py. For more information regaring these settings see django docs.
  else:  # pragma: no cover
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.postgresql',
          'NAME':  'KevinH',
      }
  }
  1. Make the migrations in the database by running $ python manage.py migrate
  2. The local development server does not run with HTTPS enabled so you will need to disable this in the settings.
 
 DEBUG = True
 SECURE_SSL_REDIRECT = True  # change this to False
 SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
 ALLOWED_HOSTS = ['.combunqweb.herokuapp.com', '.127.0.0.1']
 LOGIN_URL = 'two_factor:login'
 SESSION_EXPIRE_AT_BROWSER_CLOSE = True
 SESSION_COOKIE_SECURE = True  # change this to False
  1. Before you can run the local server you must remove the proxy settings, and use your own static ip. In apiwrapper/clients/api_client.py remove:
   def request(self, method, endpoint, payload=None):
         headers = self.create_headers(method, endpoint, payload)

         url = '%s%s' % (self._uri, endpoint)

         proxies = {
             'https': str(Proxy.objects.values_list('proxy_uri', flat=True)[0])
         } # remove this variable
         return requests.request(
             method, url,
             headers=headers,
             json=payload,
             proxies=proxies) # remove proxy here
  1. Now you should be able to run the local development server by running $ python manage.py runserver

t


Front end

For front end contributions you can skip the local development server however it would be better to get the local development server running either way. The HTML, CSS and JS of this project are stored in the templates and static folder. Please maintain the current folder structure. Add new files in the right folder, Eg. you want to add some CSS to the home page ?

  1. Create a file called index.css. Same name as the HTML name.
  2. Its HTML is stored in templates/Home/index.html, so the .css file will be saved in static/Home/CSS/index.css
  3. Load the css in the html file by placing the following code:
<link rel="stylesheet" href="{%static "Path/to/file/without/static"%}"/>
<link rel="stylesheet" href="{%static "Home/CSS/index.css"%}"/>

In the HTML files you can encounter code like {{description}} and {{balance.value}} which are placeholders for values that will be returned from the server. For examples of what these values can be you can read it on the bunq api docs. Basically each button has its own html located in static/{appName}/templates/mustache and renders the data return. Via the documentation links you can se examples of the returned data.

+-static/
  |
  +-BunqAPI/
  | |
  | +-CSS/
  | |
  | +-JS/
  | | |
  | | +-my_bunq.js
  | |
  | +-templates/
  |   |
  |   +-mustache/
  |     |
  |     +-accounts.html
  |     |
  |     +-payments.html
  |     |
  |     +-start_session.html
  |     |
  |     +-users.html
  |
  +-Manager/
    |
    +-CSS/
    | |
    | +-form.css
    | |
    | +-index.css
    |
    +-images/
    | |
    | +-bunq-Desktop.png
    |
    +-JS/
      |
      +-index.js

+-templates/
  |
  +-BunqAPI/
  | |
  | +-my_bunq.html
  | |
  | +-error/
  | | |
  | | +-notLogIn.html
  | | |
  | | +-notYourFile.html
  | |
  | +-index.html
  |
  +-Home/
  | |
  | +-index.html
  |
  +-Manager/
  | |
  | +-form.html
  | |
  | +-index.html
  | |
  | +-thanks.html
  |
  +-registration/
    |
    +-logged_out.html
    |
    +-register.html

Make pull request

After you are done making your changes you can make a pull request, there are some tests that need to pass before this pr can be accepted. To run these tests locally you can run $ coverage run manage.py test && coverage html -d htmlcov/ && open htmlcov/index.html. This will run the tests and open a web page that shows you the coverage of the test. Please try to follow PEP8 rules while coding in python.