Skip to content

Freso/metabrainz.org

 
 

Repository files navigation

metabrainz.org

Website for the MetaBrainz Foundation. This is a Flask-based web application that provides info about the foundation and its supporters, accepts donations from users and organizations, and provides access to the replication packets for MusicBrainz.

Development setup

The easiest way to set up MetaBrainz website for development is to use Docker. Make sure that it is installed on your machine before following the instructions.

Configuration

Custom configuration must be stored in the file called custom_config.py. You can use an example one (custom_config.py.example) and tweak the configuration:

$ cp custom_config.py.example custom_config.py
$ vim custom_config.py

You need to make sure that required variables are set.

MusicBrainz OAuth

To allow users to log in, you'll need to set two keys: MUSICBRAINZ_CLIENT_ID and MUSICBRAINZ_CLIENT_SECRET. To obtain these keys, you need to register your instance of MetaBrainz.org on MusicBrainz at https://musicbrainz.org/account/applications/register. Set Callback URL field to http://<your host>/login/musicbrainz/post (if PREFERRED_URL_SCHEME in the config file is set to https, make sure that you specify the same protocol for callback URL). If you run server locally, replace <your host> with localhost.

Payments

Next is the configuration of the payment systems. We use PayPal and Stripe to accept payments to our foundation. PAYPAL_ACCOUNT_IDS dictionary contains PayPal IDs or email addresses of accounts for each supported currency. PAYPAL_BUSINESS is an address for non-donations; all payments sent there will be ignored.

After these settings have been set and you are sure that your configuration is working properly with in test mode, you can flip the switch. Set DEBUG to False and PAYMENT_PRODUCTION to True. WARNING! For development purposes you should only use payments in debug mode.

Serving replication packets

Replication packets must be copied into ./data/replication_packets directory. It must have the following structure:

./data/replication_packets/
    - hourly replication packets

Startup

This command will build and start all the services that you will be able to use for development:

$ docker-compose -f docker/docker-compose.dev.yml up --build -d

The first time you set up the application, database needs to be initialized:

$ docker-compose -f docker/docker-compose.dev.yml run web python manage.py init_db

Web server should now be accessible at http://localhost:80/.

Building style sheets

Due to the way development environment works with Docker, it's necessary to build CSS separately from building an image. To do that you need to start the development server (all the containers with Docker Compose) and attach to the web container:

$ docker-compose -f docker/docker-compose.dev.yml exec web /bin/bash

Then install npm modules and build CSS:

web# npm install
web# ./node_modules/.bin/lessc ./metabrainz/static/css/main.less > ./metabrainz/static/css/main.css
web# ./node_modules/.bin/lessc ./metabrainz/static/css/theme/boostrap/boostrap.less > ./metabrainz/static/css/theme/boostrap/boostrap.css
web# ./node_modules/.bin/lessc ./metabrainz/static/fonts/font_awesome/less/font-awesome.less > ./metabrainz/static/fonts/font_awesome/less/font-awesome.css

Last two builds are necessary only if you are planning to use the admin interface.

Translations

Extracting strings

Once you have built and started all the services as mentioned above, run:

$ docker-compose -f docker/docker-compose.dev.yml run web python manage.py extract_strings

Compiling the strings

The POT files are compiled automatically every time the services are built, but in case you make any changes to the POT files and want to compile the translation files again, run:

$ docker-compose -f docker/docker-compose.dev.yml run web python manage.py compile_translations

Testing

To run all tests use:

$ py.test

or with Docker:

$ docker-compose -f docker/docker-compose.test.yml up --build --remove-orphans

Testing payments

Before doing anything make sure that PAYMENT_PRODUCTION variable in configuration file is set to False! This way you'll use testing environments where credit cards and bank accounts are not actually charged. More info about testing environments for each payment service can be found in their documentation:

Please note that in order for IPNs to work, application MUST be publicly available. If you are doing development on your local machine it is likely that your callback endpoints will not be reachable for payment processors.

About

Modern version of the MetaBrainz Foundation website

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 43.7%
  • CSS 33.6%
  • Python 21.2%
  • PLpgSQL 1.2%
  • Other 0.3%