Coding standards

Developer Certificate of Origin

Before pushing code or content to the project’s repo, you have to check that you own the appropriate rights to publish it under the project’s licenses, and approve the terms of the Developer Certificate of Origin version 1.1. To do so, you have to sign-off your commits by adding the --signoff option to your git commit commands.

REUSE standard

We try to follow the REUSE standard. So if you add a new file or make significant changes to one, please add also the appropriate headers following the template:

# SPDX-FileCopyrightText: 2021 Hermine-team <hermine@inno3.fr>
# SPDX-License-Identifier: AGPL-3.0-only 

Code linting

We use Black for harmonising code formatting, Ruff for linting and DjHTML for indenting Django Templates.

To quickly check and reformat your files, run the following commands:

black {source_file_or_directory}

ruff check {source_file_or_directory}

djhtml {source_file_or_directory}

Naming conventions

We try to stay consistent in naming Django models, views, route names and so on. Here are some example for a hypothetical ObjectName model and its associated views:

# urls.py

urlpatterns = [
    # ...
    path("objectnames/", views.ObjectNameListView.as_view(), name="objectname_list"),
    path("objectnames/new/", views.ObjectNameCreateView.as_view(), name="objectname_create"),
    path("objectnames/<int:pk>/", views.ObjectNameDetailView.as_view(), name="objectname_detail"),
    path("objectnames/<int:pk>/edit/", views.ObjectNameUpdateView.as_view(), name="objectname_update"),
    path("objectnames/<int:pk>/delete/", views.ObjectNameDeleteView.as_view(), name="objectname_delete"),
    # ...
]


# views.py
class ObjectNameDetailView(DetailView):
    model = ObjectName
    template_name = "objectname_detail.html"

class ObjectNameListView(ListView):
    model = ObjectName
    template_name = "objectname_list.html"

class ObjectNameCreateView(CreateView):
    model = ObjectName
    template_name = "objectname_create.html"  # or default "objectname_form.html"

class ObjectNameUpdateView(UpdateView):
    model = ObjectName
    template_name = "objectname_update.html" # or default "objectname_form.html"
    
class ObjectNameDeleteView(DetailView):
    model = ObjectName
    template_name = "objectname_confirm_delete.html" # this is django default

Commit messages

It would be nice to try to follow the Conventional Commits standards. In order to respect it, the commit message should follows the template:

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

For example, a commit message for a new feature could look like this:

feat: name of the feature

Short description

Signed-off-by: # auto generated by git commit --signoff