2025-02-09 20:54:04 +02:00
2022-09-12 22:42:01 +03:00
2022-08-06 16:54:16 +03:00
2023-10-05 16:20:28 +03:00
2022-01-13 22:10:51 +02:00
2023-02-07 16:35:07 +02:00
2022-07-04 10:33:38 +03:00
2022-07-04 10:33:38 +03:00
2025-01-21 21:11:01 +00:00
2022-12-24 20:59:07 +02:00
2022-08-06 16:35:58 +03:00
2022-12-21 16:20:59 +02:00
2022-08-17 23:00:11 +03:00
2019-05-27 20:35:45 +03:00
2021-03-29 01:13:44 +03:00
2022-07-31 16:28:57 +03:00
2025-02-09 19:47:10 +02:00
2025-02-09 19:47:10 +02:00
2025-02-09 19:47:10 +02:00
2025-02-09 19:47:10 +02:00
2016-05-18 19:27:22 +03:00
2021-06-15 22:58:33 +03:00
2022-07-21 23:47:56 +03:00
2025-02-09 20:54:04 +02:00
2021-03-29 01:13:44 +03:00
2025-02-09 20:54:04 +02:00
2025-02-09 19:47:10 +02:00
2025-02-09 19:47:10 +02:00

Web 2.0 Backend

Django backend containing multiple small applications and api for Next.js frontend.

  • Web app: Backend for the main website.
  • Member register: Data table app for viewing and modifying the member register, member applications and membership payments.
  • Kaehmy: Form for creating and listing kaehmys
  • Ohlhafv: Form for creating and listing ohlhafv challenges.
  • Infoscreen: Angular-based slideshow app for the guild room's screens.

Installation

Set up your SSH key authentication in GitLab Profile Settings. Then clone the repository and checkout the development branch:

git clone git@gitlab.com:sahkoinsinoorikilta/vtmk/web2.0-backend.git
cd web2.0-backend
git checkout develop

Copy env file for local use:

cp .env.dev .env

Poetry

For depedencies and virtual environment, we use poetry.

First install python. Then install poetry:

python -m pip install poetry==2.0.1

The easiest integration with VSCode is to have poetry install virtual environment in project folder, configured with CMD

python -m poetry config virtualenvs.in-project true

Node

We use Node.js for few development tasks, like linting. Easiest way to install Node is nvm. After installing install dependencies:

npm install

TODO: List scripts

Database

To run a local development database docker is recommended. If you want to additianally use a db management tool pgAdmin is nice.

After installing docker use the following to create a database:

docker run --name sik.web.db -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres:12

Development

Activate virtual environment in shell

eval $(python -m poetry env activate)

Install dependencies

poetry install

Initializing data

Run the following manage.py commands to initialize a new database. Do not run these in production without thinking!

python manage.py migrate            # run migrations
python manage.py createdefaultadmin # creates an admin user
python manage.py initialize         # creates user groups
python manage.py createdummydata    # creates dummy members to the member register

Running

python manage.py runserver

Visit https://localhost:8000 in your browser!

Using address 0.0.0.0 will bind to all IP addresses. Using localhost will only bind to your machine.

python manage.py runserver 0.0.0.0:8000

Development workflow

When you start working on a feature, create a feature branch for your changes. These feature branches should be prefixed with feature.

Example of creating a feature branch:

git checkout -b feature-branch-name

When your changes are ready and the code works without errors, submit a merge request to develop in GitLab. Another developer reviews your changes and runs the merge. Feature branches should be closed on merge.

Bugfixes do not need their own feature branches and can be pushed straight to develop, but if the fix needs a notable amount of work, it should be done in a bugfix branch instead.

Merge requests to master should be reviewed by multiple developers. Only a moderator can accept merge requests to master.

Linting

Lint python files using black with

npm run lint:py                     # check changes
npm run lint:py:fix                 # fix errors

Lint javascript and markdown using eslint and remark with

npm run lint:md                     # markdown
npm run lint:js                     # javascript

Use an editor with linting capabilities to write pretty code that passes linting. Examples include VSCode, Atom and Pycharm.

Unit tests

Run unit tests with

python manage.py test

Due to the mostly static nature of the project, most elements are difficult to properly unit test. If you write code with actual logic, make sure to write at least one unit or integration test that tests your code's core functionality.

Tests are located in tests.py under every subproject.

Production

Project is run in production with Docker. See Dockerfile for details.

For more information about deployment check infra repository.

GitLab CI

All pushed changes go through the GitLab Continuous Integration, which consists of automated unit testing and linting. Make sure your changes pass both before merging to develop or master.

S
Description
Web 2.0 Backend. Django, Angular
Readme 21 MiB
Languages
JavaScript 54.6%
Python 36.7%
HTML 6.6%
CSS 1.8%
Shell 0.2%