Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.0

build:
Expand All @@ -32,38 +32,42 @@ jobs:


steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"

- name: Apt update
run: sudo apt update

- name: Install apt packages
run: sudo apt install -y graphicsmagick mupdf-tools ghostscript unoconv python3-dev
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install python packages
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install the project
run: uv sync --dev

- name: Django checks
run: ./manage.py check
run: uv run ./manage.py check

- name: Check migrations
run: ./manage.py makemigrations --dry-run --check
run: uv run ./manage.py makemigrations --dry-run --check

- name: mypy
run: mypy
run: uv run mypy

- name: Statics checks
run: ./manage.py collectstatic --noinput -v 0
run: uv run ./manage.py collectstatic --noinput -v 0

- name: pytest with SQLite
run: pytest -k "not unoconv"
run: uv run pytest -k "not unoconv"

- name: pytest with PostgreSQL
run: pytest -k "not unoconv" -m postgresql
run: uv run pytest -k "not unoconv" -m postgresql
env:
DB_URL: postgres://postgres:postgres@localhost:5432/postgres

Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
repos:
- repo: https://github.com/psf/black
rev: 24.10.0
rev: 25.1.0
hooks:
- id: black

- repo: https://github.com/pycqa/isort
rev: 5.13.2
rev: 6.0.1
hooks:
- id: isort

Expand All @@ -17,7 +17,7 @@ repos:
files: \.html$

- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
rev: v3.19.1
hooks:
- id: pyupgrade
args: [ "--py310-plus" ]
Expand All @@ -30,13 +30,13 @@ repos:
- id: djjs

- repo: https://github.com/adamchainz/django-upgrade
rev: 1.22.2
rev: 1.24.0
hooks:
- id: django-upgrade
args: [ --target-version, "4.1" ]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.8.2'
rev: 'v0.11.3'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

This page tries to contain all changes made on DocHub.

# 2025.6.0

* Switch to UV as the package manager
* Upgrade dependencies
* Switch to Python 3.13
* Remove deprecated `filemagic` and replace with `python-magic`
* Remove unmaintained docker compose setup

# 2024.3.0

* Upgrade JS libraries (notable change is Turbo 8)
Expand Down
21 changes: 1 addition & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
ifeq ($(CI),true)
PY=python3
else
ifndef VIRTUAL_ENV
PY=ve/bin/python
else
PY=python3
endif
endif
PY=uv run

init: database

install: packages

ve:
$(PY) -m venv ve

packages: ve
ve/bin/pip install -r requirements.txt

database:
$(PY) manage.py migrate -v 0
Expand All @@ -26,10 +11,6 @@ database:
@echo "Creating user blabevue with password 'test'"
@echo "from users.models import User; u=User.objects.get_or_create(netid='blabevue', first_name='Bertrand', last_name='Labevue', email='blabevue@fake.ulb.ac.be'); u[0].set_password('test'); u[0].save()" | $(PY) manage.py shell > /dev/null

# @echo "Loading an minimal course tree"
# $(PY) manage.py load_tree
# $(PY) manage.py load_courses

@echo "Creating some tags"
@echo "[__import__('tags').models.Tag.objects.create(name=x) for x in ('syllabus', 'officiel', 'examen', 'resume', 'synthese', 'notes')]" | $(PY) manage.py shell > /dev/null

Expand Down
62 changes: 25 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

[![License](https://img.shields.io/badge/license-AGPL%20v3-blue.svg)](https://github.com/UrLab/dochub/blob/master/LICENSE)

DocHub is a website, written in django. It's main goal is to provide a space for students (for now form the [ULB](https://ulb.ac.be) university) to collaborate, help each other and distribute old exams and exercices.
DocHub is a website written in django. Its main goal is to provide a space for students
(for now form the [ULB](https://ulb.ac.be) university) to collaborate, help each other and distribute old exams and exercises.

There is a [live instance of DocHub](https://dochub.be) hosted by [UrLab](https://urlab.be) and the [Cercle Informatique](https://cerkinfo.be).

Expand All @@ -14,11 +15,22 @@ There is a [live instance of DocHub](https://dochub.be) hosted by [UrLab](https:

## Tech

DocHub currently (Feb 2022) runs with Python 3.10 and Postgresql 14.
DocHub currently (Feb 2025) runs with Python 3.13 and Postgresql 16.

### Dependencies
### Installation

If you install the packages listed above and follow the installation steps exactly, you should have a running version
of DocHub on your machine. If it's not the case, **you are not the problem**, it means we have a bug.

Please open an issue with the output of your console and describe the problem you encountered, we **will** and will fix
it for you and all the next users :rocket:

First, install uv and system dependencies:

```console
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh

# Ubuntu
sudo apt-get install unoconv python3-dev ruby libtiff5-dev libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk mupdf-tools redis-server
sudo systemctl enable --now redis-server
Expand All @@ -30,27 +42,8 @@ sudo pacman -S unoconv ruby python mupdf-tools redis
sudo systemctl enable --now redis
```


### Installation

If you install the packages listed above and follow the installation steps exactly, you should have a running version
of DocHub on your machine. If it's not the case, **you are not the problem**, it means we have a bug.

Please open an issue with the output of your console and describe the problem you encountered, we **will** and will fix
it for you and the all the next users :rocket:

To create the virtual environment and install the requirements, run the following command:
```console
make install

# Alternatively, if you prefer to do it by hand
python3 -m venv ve
source ve/bin/activate
pip install -r requirements.txt
```

To create a database and fill it with some dummy data, run the following command. Observe the output, it
will tell you the credentials you can then use to log in.
To create a database and fill it with some fake data, run the following command.
Observe the output, it will tell you the credentials you can then use to log in.
```console
make database
```
Expand All @@ -60,45 +53,44 @@ make database
This will have to be done each time you want to run DocHub.

```console
source ve/bin/activate
./manage.py runserver
uv run manage.py runserver
```

Then go http://localhost:8000/

There will already be 2 users in the database, both with `test` as a password:

- $(USER) : your username on your machine
- $(USER): your username on your machine
- blabevue

### Misc

#### Add another user to the db

```console
./manage.py createuser
uv run manage.py createuser
```

#### Requirements

To add a requirement, write it in `requirements.in` file, and generate the requirements.txt file with the following command
To add a requirement, use:

```console
pip-compile
uv add <package-name>
```

## Testing

Run only fast tests (total time < 2 sec) : not testing actual file conversions

```console
py.test -k "not slow"
uv run pytest -k "not slow"
```

Run all tests (~20 sec)

```console
py.test
uv run pytest
```

## Contribute !
Expand All @@ -112,13 +104,9 @@ Check the issues tab and look and the issues tagged with the `easy pick` label.
Assign yourself to an issue and start working on it *in your own branch*. If you have any questions or issue, feel free to ask them in the issue or tag some people you know can help.<br/>
If your PR is completed, ask for reviews either by mentioning the people you want to review your PR (You can also set them as reviewers on the right) or by asking on our irc channel **#urlab** on libera.chat.

### Any question ?

Come by #urlab on libera.chat and feel free to ask anything !

## License

Copyright 2012 - 2022, Cercle Informatique ASBL. All rights reserved.
Copyright 2012, Cercle Informatique ASBL. All rights reserved.

This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published by
Expand Down
16 changes: 0 additions & 16 deletions build.sh

This file was deleted.

1 change: 1 addition & 0 deletions catalog/management/commands/download_programs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# mypy: disable-error-code="union-attr, arg-type"
from typing import Any

import json
Expand Down
17 changes: 0 additions & 17 deletions docker/Dockerfile

This file was deleted.

1 change: 0 additions & 1 deletion docker/celery.sh

This file was deleted.

Loading