Giter Site home page Giter Site logo

city-of-helsinki / berth-reservations Goto Github PK

View Code? Open in Web Editor NEW
4.0 20.0 1.0 23.42 MB

Registration API for berth reservations

License: MIT License

Dockerfile 0.14% Python 92.44% Shell 0.12% HTML 7.23% JavaScript 0.07%
python django graphql graphene-django

berth-reservations's Introduction

Berth reservations

Version Continuous integration Coverage License

⛵ Bare-bones registration API for berth reservations ⛵

Contents

Development with Docker

  1. Copy .env.example to .env and modify it if needed.

  2. Run docker-compose up

  3. Run migrations if needed:

    • docker exec berth python manage.py migrate
  4. Create superuser if needed:

    • docker exec -it berth python manage.py createsuperuser

The project is now running at localhost:8081

Development without Docker

Project uses following software versions:

  • Postgres 11
  • Postgis 2.5
  • Python 3.9

Database

To setup a database compatible with default database settings:

Create user and database

sudo -u postgres createuser -P -R -S berth_reservations  # use password `berth_reservations`
sudo -u postgres createdb -O berth_reservations berth_reservations

Create extensions in the database

sudo -u postgres psql berth_reservations -c "CREATE EXTENSION postgis;"

Allow user to create test database

sudo -u postgres psql -c "ALTER USER berth_reservations CREATEDB;"

Install Geospatial libraries

For Debian/Ubuntu:

apt-get install binutils libproj-dev gdal-bin

For more information, see https://docs.djangoproject.com/en/3.1/ref/contrib/gis/install/geolibs/

Daily running

  • Create .env file: touch .env
  • Set the DEBUG environment variable to 1.
  • Run python manage.py migrate
  • Run python manage.py runserver 0:8000

The project is now running at localhost:8000

Keeping Python requirements up to date

  1. Install pip-tools:

    • pip install pip-tools
  2. Add new packages to requirements.in or requirements-dev.in

  3. Update .txt file for the changed requirements file:

    • pip-compile requirements.in
    • pip-compile requirements-dev.in
  4. If you want to update dependencies to their newest versions, run:

    • pip-compile --upgrade requirements.in
  5. To install Python requirements run:

    • pip-sync requirements.txt

Code format

This project uses black for Python code formatting. We follow the basic config, without any modifications. Basic black commands:

  • To let black do its magic: black .
  • To see which files black would change: black --check .

The project also has pre-commit setup with few hooks to avoid having "style fixing" commits.

To install it, run:

pre-commit install

This will setup three pre-commit hooks: black, flake8, and isort.

Version control

Commits and pull requests

We try to keep a clean git commit history. For that:

  • Keep your commits as simple as possible
  • Always rebase your PRs, don't merge the latest master into your branch
  • Don't be afraid to push --force once you have fixed your commits
  • Avoid using the GitHub merge/rebase buttons

Releases

This project is following GitHub flow. Release notes can be found from GitHub tags/releases.

Running tests

pytest

In order to successfully run tests in applications/tests/test_applications_notifications.py you need to set env variable NOTIFICATIONS_ENABLED=1

Fixtures

Municipalities

There are some fixtures available, that contain basic data about public harbors and winter areas of the City of Helsinki. If you don't have divisions of Helsinki imported yet through django-munigeo, import them first:

./manage.py geo_import finland --municipalities
./manage.py geo_import helsinki --divisions

Resources

Then load the fixtures with the following commands:

./manage.py loaddata helsinki-ws-resources.json
./manage.py loaddata helsinki-harbor-resources.json
./manage.py loaddata helsinki-harbor-resources-fixes-2021-06-11.json

And assign the corresponding region to areas:

./manage.py assign_area_regions

Point harbor and ws images to customer ui images:

./manage.py add_helsinki_harbors_images
./manage.py add_helsinki_winter_areas_images

Berth switch reasons

Load the fixtures with reasons for berth switch:

./manage.py loaddata switch-reasons.json

Stickers

Create WS sticker sequences:

./manage.py create_ws_lease_sticker_sequences

User groups and permissions

Load the User Groups:

./manage.py loaddata groups.json

And install the model permissions:

./manage.py set_group_model_permissions

Products

There are fixtures for the pre-defined berth products. They are the products defined by the Boat Office, so they are the same for the production env.

./manage.py loaddata berth_products.json

berth-reservations's People

Contributors

a-rmz avatar ahie avatar charn avatar dependabot[bot] avatar frodotus avatar haavikko avatar hi-fi avatar igordavydsson avatar jakezu avatar joonvena avatar karisal-anders avatar klemmari1 avatar kristianjokela avatar mikkovihonen avatar nikomakela avatar nizar-rahme avatar quyenlq avatar santtul avatar tatuarvela avatar tebbon avatar terovirtanen avatar tuomas777 avatar vikoivun avatar vitals9367 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

vitals9367

berth-reservations's Issues

Improper data

Some ports are not separated into subports, which makes services available in them out of sync with reality.

Reservation export to CSV is out of date

  1. We have new fields on Reservation model, that need to be used as separate columns.
  2. Format should be .xls (Excel 2003), so that it would be easier for city admins to use.

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.