Giter Site home page Giter Site logo

code4romania / seismic-risc Goto Github PK

View Code? Open in Web Editor NEW
34.0 9.0 65.0 15.91 MB

Web app for keeping track of buildings in danger of collapsing in the event of an earthquake

Home Page: https://seismic-risc.vercel.app/

License: Mozilla Public License 2.0

Python 38.87% HTML 1.84% JavaScript 50.34% Makefile 3.02% Shell 0.78% SCSS 5.08% Batchfile 0.02% CSS 0.05%
civic-tech crowdsourcing earthquakes code4ro django react python javascript

seismic-risc's Issues

Makefile installation of Docker fails on Ubuntu 19.10

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(shell lsb_release -cs) stable", on Ubuntu 19.10, will add the repository for "ubuntu eoan stable", but Docker.com does not provide packages for Ubuntu Eoan: docker/for-linux#833

I've worked around this by using the Docker repository for the previous version of Ubuntu:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu disco stable"

[Discussion] API and client interaction in the blog

Blog posts are generated in the same way as other pages through the Django CMS
The Django REST API should be able to return these articles
The React client should be able to add a style over them

We would need to form a better opinion on how such an architecture might look
Anyone with experience in this area is welcome to contribute to the discussion

[Frontend] Create blog posts page

As a user, I want to see blog posts written on the platform, through the CMS, all in one page, so that I can inform myself about the risks of an earthquake.

The articles should support tags so that I can filter them by city.

For reference, see the third mockup image.

[api] Add tests to the buildings api

Create a api/tests/test_buildings_api.py file that tests the basic CRUD functionality of the buildings api.

We used the pytest testing framework, make sure you use of all its awesome features. :)

[client] Build files should be placed in the ./api folder

Because some of the CSS will be shared between the client and the api, we need to have a way for the api code to be able to serve those files from within it's container.

For now we should just build the client files into the ./api/public/ folder. That folder is already in the git ignore list so it should be fine.

[client] Make use of the API to get map data

Right now the client uses an outdated json dump of the data and the json-server package to serve it.

The client code should be able to take an environment variable with the site domain and get the data directly from the api.

You can load some dummy data into the buildings api by running the make init-db (this will also create a superuser for you in the django admin).

[Initialization] Dev setup data load fails

On a fresh clone

$  python3 manage.py loaddata buildings

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/django/db/models/options.py", line 565, in get_field
    return self.fields_map[field_name]
KeyError: 'nr_cadastral'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/django/core/serializers/json.py", line 69, in Deserializer
    yield from PythonDeserializer(objects, **options)
  File "/usr/local/lib/python3.7/site-packages/django/core/serializers/python.py", line 118, in Deserializer
    field = Model._meta.get_field(field_name)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/options.py", line 567, in get_field
    raise FieldDoesNotExist("%s has no field named '%s'" % (self.object_name, field_name))
django.core.exceptions.FieldDoesNotExist: Building has no field named 'nr_cadastral'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 72, in handle
    self.loaddata(fixture_labels)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 114, in loaddata
    self.load_label(fixture_label)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 172, in load_label
    for obj in objects:
  File "/usr/local/lib/python3.7/site-packages/django/core/serializers/json.py", line 73, in Deserializer
    raise DeserializationError() from exc
django.core.serializers.base.DeserializationError: Problem installing fixture '/Users/iuliux/seismic-risc/seismic_site/map_app/fixtures/buildings.json':

[Django] Clean up the old unused API

Also called the "legacy API". We're at that stage where we don't have to keep legacy.

Should be safe to just completely nuke the seismic_site/api folder and remove this one line https://github.com/code4romania/seismic-risc/blob/master/seismic_site/seismic_site/urls.py#L27

While at it, the seismic_site/map_app/serializers.py is a complete duplicate (unused) of seismic_site/buildings/serializers.py (left-over from #61, my bad). This one would actually give an error if it were to be used.

[frontend] Create detailed building view

As a user, when I click on a building, I want to see a side-view on the right-hand side of the map where I can read all the details about the currently selected building, in order to understand the context in which it was marked as being a risk.

As reference, use the second mockup image.

[api] Add tests to the blog api

Create a api/tests/test_blog_api.py file that tests the basic read functionality of the blog api.

We used the pytest testing framework, make sure you use of all its awesome features. :)

Internationalise the interface

All the text displayed should be multilingual, allowing us to deploy the application in different languages
This also allows the display of Romanian strings while at the same time allowing developers to easily understand what those strings represent

Languages supported: en-GB (code language), ro-RO

Mock text can be used in the beginning to not spend much time on translating everything

Django i18n docs: https://docs.djangoproject.com/en/3.0/topics/i18n/

[api] Make the pages api read-only

The create/update functionality should only be available in the django admin.
Add tests showing this is not possible from the client facing api.

Data model refactoring

The data model of the application needs to be refactored:

  • translate data model to english
  • make the data model more general, as currently the model is mostly designed for Bucharest

[DevOps] GitHub Actions pipeline for basic checks on master branch for Python

In order to make sure that the master branch is safe, we need to put in place a basic pipeline, using GitHub Actions, for running the basic scripts. The purpose of the pipeline is to ensure we don't push broken functionality in the repository.

The pipeline should make sure that the following scripts can be properly run:

python3 manage.py loaddata buildings
python3 manage.py runserver

[DevOps] Consider configuring the app through environment variables

Rather than hard-coding things like database host, name, user, Django secret key and other things, we could take them from the environment.

This ensures that our app follows the 12-factor app design principles and makes our lives easier, because it will be easier to pass different configuration depending on the deployment.

Here is how this looks: https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/

Basically, the database settings would look something like this:

DATABASES = {
    "default": {
        "ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.sqlite3"),
        "NAME": os.environ.get("SQL_DATABASE", os.path.join(BASE_DIR, "db.sqlite3")),
        "USER": os.environ.get("SQL_USER", "user"),
        "PASSWORD": os.environ.get("SQL_PASSWORD", "password"),
        "HOST": os.environ.get("SQL_HOST", "localhost"),
        "PORT": os.environ.get("SQL_PORT", "5432"),
    }
}

We could use django-configurations, which makes it easier to read from the environment. Additionally, it gives us a way to separate development and production settings.

[api] Add tests to the pages api

Create a api/tests/test_pages_api.py file that tests the basic view functionality of the pages api. No need to test the create/update methods as those will be removed from the client facing api.

We use the pytest testing framework, make sure you use of all its awesome features. :)

Implement Django REST framework

To have a more streamlined communication between front-end and back-end, a better, more flexible API should be created to handle the information

[Map] Search locations on map based on address

As a user of the platform, I want to be able to search location on the map based on the address.

Update: The search bar is implemented in the client but there is no connection to the backend. Functionality should be implemented in Django, on the backend.

Internationalise the interface

All the text displayed should be multilingual, allowing us to deploy the application in different languages
This also allows the display of Romanian strings while at the same time allowing developers to easily understand what those strings represent

Languages supported: en-GB (code language), ro-RO

Mock text can be used in the beginning to not spend much time on translating everything

Relevant React i18n docs:

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.