Toolhunt is a web application for editing Toolhub records in a fun and easy way. It allows users to view and add missing fields for tools in Toolhub.
This repository contains the project backend. The frontend can be found in the toolhunt-ui repository.
This is an Outreachy Internship project.
This project uses Phabricator to track issues.
API documentation is automatically generated by Swagger and can be accessed (while the app is running) at localhost:8082/api/documentation
Note that, as of the latest build, access to the API documentation and backend functionality happens through the frontend component of this app: toolhunt-ui repository
In other words, to do much of anything with this half of the project, you must have both front- and backend components running in Docker containers.
-
Clone this repo to your machine with the command
git clone https://github.com/wikimedia/toolhunt.git
-
Clone the frontend ui repo with
git clone https://github.com/wikimedia/toolhunt.git
In order to authenticate successfully, you must register your local version of the app with the Toolhub Demo Server.
-
To register, go to Developer Settings and complete the form.
-
Set
http://localhost:8082/api/authorize
as the Authorization Callback URL. -
Create an
.env
file in the root directory of your toolhunt repo and addTOOLHUB_CLIENT_ID
andTOOLHUB_CLIENT_SECRET
(set their values to be whatever you received from the demo server registration)
When building the Docker containers, the backend must go first.
From the toolhunt directory:
docker-compose up --build --detach
From the toolhunt-ui directory:
docker-compose up --build --detach
Then:
- Open a browser window to localhost:8082
- From the command line,
docker-compose exec flask-web flask db upgrade
- From the command line,
docker exec -it mariadb mariadb --user user -p mydatabase
(password: mypassword)
Whether you're working with the mock data or "real" data, the contents of the field
table will remain the same.
- From the command line,
docker-compose exec flask-web python manage.py insert_fields
This needs to be done first, before adding tool data.
The mock data set contains three tools and a set of completed tasks. When run, the function load_mock_data
will put the tools through the insertion process and auto-generate tasks, as it would with "real" data.
It will also enter completed tasks into the completed_task
table in the database.
- From the command line,
docker-compose exec flask-web python manage.py load_mock_data
The results will appear on the command line. This command may be run multiple times; observe the command line messages to see what changes when a tool and/or task is already present in the DB.
The set of completed tasks will allow us to test that the high scores, user contributions, and latest contributions are returning correctly.
- From the command line,
docker-compose exec flask-web python manage.py update_db
While in development mode, the fetch request associated with this pipeline draws data from the Toolhub Test Server. This command can be run prior to or following load_mock_data
.
Toolhunt uses tox to handle local CI (linting, syntax, style, code formatting and import sorting). To use it, follow the installation instructions and, from the toolhunt directory, enter tox
on the command line.
- Python
- Flask
- Redis
- Docker
- MariaDB