lord-haffi / PulpScience

A Website where people can publish and read articles (or follow projects) about scientifical topics.
GNU General Public License v3.0
3 stars 0 forks source link

Pulp Science

A Website where people can publish and read articles (or follow projects) about scientifical topics.

Contributing

If you want to contribute please make sure to not commit directly to the master or development branch. Instead, create a new branch from development and create a pull request with the development branch.

Basic setup

To clone and contribute to this project please follow these steps:

And that's it!

Tips for frontend development

If you want to code on the stylesheets you will need to install a sass compiler. E.g. on Windows you can use choco install sass.

Hint: In PyCharm it is very comfortable to configure file watchers and scopes for the different scss main files. For example, I configured two file watchers with its own scopes to compile main_base.scss and main_index.scss.

Below you can see an example of how you can configure such a file watcher: Screenshot of file watcher

You can define a custom scope, since you only need to recompile when code is changed affecting the main_base.scss: Screenshot of file watcher scope

Server setups

There are two different setups. The easy-to-use test server of django and a docker image emulating the production use-case.

Django test setup

To use the django test server simply run:

python manage.py runserver

The backend will use the sqlite file as database. If you change something in your code you should see the changes live in your browser - you don't have to restart the server.

The server is addressable at localhost:8000.

Note: If you want to use djangos admin panel you may have to create the superuser first:

python manage.py createsuperuser

But if you didn't rebuilt the sqlite database there should already be a superuser. (user: admin, password: sekret1)

Docker production setup

To use the docker setup - including backend and Postgres database server - run:

docker-compose up -d

If you changed something in the code you may have to rebuild the image:

docker-compose up -d --build

If you added a database migration or rebuilt the database volume you have to migrate these changes. You have two options to do so:

  1. Go to Docker Desktop and open a terminal for the backend container. It should be named something like pulpscience_web_1. Type:
    python manage.py migrate
  2. Connect a terminal of your choice to the docker container and run migrations:
    docker exec -it pulpscience_web_1 /bin/bash
    python manage.py migrate

Alternatively, you can run this single command in the container directly with:

docker exec pulpscience_web_1 python manage.py migrate

To stop the docker container you can use:

docker-compose down

The server is addressable at localhost:8020. Both setups can run parallel.

Note: For the testing .env the admin account should be the same. (user: admin, password: sekret1)