Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mamageprojects updates + update requirements #227

Merged
merged 3 commits into from
Feb 20, 2024
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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{html,css,js}]
insert_final_newline = false

[*.py]
max_line_length = 119

Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.11", "3.10", "3.9"]
django-version: ["4.2", "4.1", "3.2"]
python-version: ["3.12", "3.11", "3.10"]
django-version: ["5.0", "4.2", "3.2"]
steps:
- name: Checkout
run: |
echo $GITHUB_REF $GITHUB_SHA
git clone --depth 1 https://github.com/$GITHUB_REPOSITORY.git .
git clone https://github.com/$GITHUB_REPOSITORY.git .
git fetch origin $GITHUB_SHA:temporary-ci-branch
git checkout $GITHUB_SHA || (git fetch && git checkout $GITHUB_SHA)

Expand All @@ -42,10 +42,9 @@ jobs:
run: |
./manage.py --help

# FIXME:
#- name: 'Safety'
# run: |
# ./manage.py safety
- name: 'Safety'
run: |
./manage.py safety

- name: 'Python ${{ matrix.python-version }} Django ${{ matrix.django-version }}'
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.egg-info
__pycache__
/dist/
/build/
/coverage.*
*.orig

Expand Down
5 changes: 3 additions & 2 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""

import hashlib
import shlex
import signal
import subprocess
import sys
Expand Down Expand Up @@ -78,7 +79,7 @@ def venv_up2date():


def verbose_check_call(*popen_args):
print(f'\n+ {" ".join(str(arg) for arg in popen_args)}\n')
print(f'\n+ {shlex.join(str(arg) for arg in popen_args)}\n')
return subprocess.check_call(popen_args)


Expand All @@ -95,7 +96,7 @@ def main(argv):

# Create virtual env in ".venv/":
if not PYTHON_PATH.is_file():
print('Create virtual env here:', VENV_PATH.absolute())
print(f'Create virtual env here: {VENV_PATH.absolute()}')
builder = venv.EnvBuilder(symlinks=True, upgrade=True, with_pip=True)
builder.create(env_dir=VENV_PATH)
# Update pip
Expand Down
14 changes: 9 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ readme = "README.md"
authors = [
{name = 'Jens Diemer', email = '[email protected]'}
]
requires-python = ">=3.9,<4" # Keep Python 3.9 until Yunohost contains a newer Python Version ;)
requires-python = ">=3.9" # Keep Python 3.9 until Yunohost contains a newer Python Version ;)
dependencies = [
"django",
"django-reversion", # https://github.com/etianen/django-reversion
"diff-match-patch", # https://github.com/diff-match-patch-python/diff-match-patch
"rich", # https://github.com/Textualize/rich
]
[project.optional-dependencies]
dev = [
Expand Down Expand Up @@ -56,10 +57,12 @@ dev = [
"model_bakery", # https://github.com/model-bakers/model_bakery
"requests-mock",
"django-override-storage", # https://github.com/danifus/django-override-storage
"beautifulsoup4", # https://pypi.org/project/beautifulsoup4/
"freezegun", # https://github.com/spulec/freezegun
]
django32=["django>=3.2,<3.3"]
django41=["django>=4.1,<4.2"]
django42=["django>=4.2,<4.3"]
django50=["django>=5.0,<5.1"]

[project.urls]
Documentation = "https://github.com/jedie/django-reversion-compare"
Expand Down Expand Up @@ -144,7 +147,7 @@ exclude_lines = [
legacy_tox_ini = """
[tox]
isolated_build = True
envlist = py{312,311,310,39}-django{42,41,32}
envlist = py{312,311,310,39}-django{50,42,32}
skip_missing_interpreters = True

[testenv]
Expand All @@ -153,12 +156,12 @@ skip_install = true
commands_pre =
pip install -U pip-tools
django32: pip-sync requirements.django32.txt
django41: pip-sync requirements.django41.txt
django42: pip-sync requirements.django42.txt
django50: pip-sync requirements.django50.txt
commands =
django32: {envpython} -m coverage run --context='{envname}' -m reversion_compare_project test --buffer
django41: {envpython} -m coverage run --context='{envname}' -m reversion_compare_project test --buffer --shuffle --parallel
django42: {envpython} -m coverage run --context='{envname}' -m reversion_compare_project test --buffer --shuffle --parallel
django50: {envpython} -m coverage run --context='{envname}' -m reversion_compare_project test --buffer --shuffle --parallel
"""


Expand All @@ -180,6 +183,7 @@ applied_migrations = [
"00fbc5d", # 2023-04-07T12:35:09+02:00
"c1a9d97", # 2023-11-01T19:59:17+01:00
"363c360", # 2023-12-16T19:37:39+01:00
"a66e5ae", # 2024-01-16T19:13:13+01:00
]

[manageprojects.cookiecutter_context.cookiecutter]
Expand Down
1,057 changes: 403 additions & 654 deletions requirements.dev.txt

Large diffs are not rendered by default.

1,063 changes: 406 additions & 657 deletions requirements.django32.txt

Large diffs are not rendered by default.

1,338 changes: 0 additions & 1,338 deletions requirements.django41.txt

This file was deleted.

1,057 changes: 403 additions & 654 deletions requirements.django42.txt

Large diffs are not rendered by default.

1,087 changes: 1,087 additions & 0 deletions requirements.django50.txt

Large diffs are not rendered by default.

34 changes: 23 additions & 11 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# ./manage.py update_req
Expand All @@ -12,21 +12,33 @@ diff-match-patch==20230430 \
--hash=sha256:953019cdb9c9d2c9e47b5b12bcff3cf4746fc4598eb406076fa1fc27e6a1f15c \
--hash=sha256:dce43505fb7b1b317de7195579388df0746d90db07015ed47a85e5e44930ef93
# via django-reversion-compare (pyproject.toml)
django==5.0 \
--hash=sha256:3a9fd52b8dbeae335ddf4a9dfa6c6a0853a1122f1fb071a8d5eca979f73a05c8 \
--hash=sha256:7d29e14dfbc19cb6a95a4bd669edbde11f5d4c6a71fdaa42c2d40b6846e807f7
django==5.0.2 \
--hash=sha256:56ab63a105e8bb06ee67381d7b65fe6774f057e41a8bab06c8020c8882d8ecd4 \
--hash=sha256:b5bb1d11b2518a5f91372a282f24662f58f66749666b0a286ab057029f728080
# via
# django-reversion
# django-reversion-compare (pyproject.toml)
django-reversion==5.0.8 \
--hash=sha256:229ad0d2819416157502ff13d81bad2366227b763ce85b63b8a223edb756a513 \
--hash=sha256:45d378bc6e606df6b2ad0077aec8b0a00e35f18c74ca2a1ae9cc262ceb32fb9a
django-reversion==5.0.12 \
--hash=sha256:5884e9f77f55c341b3f0a8d3b0af000f060530653776997267c8b1e5349d8fee \
--hash=sha256:c047cc99a9f1ba4aae6db89c3ac243478d6de98ec8a60c7073fcc875d89c5cdb
# via django-reversion-compare (pyproject.toml)
markdown-it-py==3.0.0 \
--hash=sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1 \
--hash=sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb
# via rich
mdurl==0.1.2 \
--hash=sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8 \
--hash=sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba
# via markdown-it-py
pygments==2.17.2 \
--hash=sha256:b27c2826c47d0f3219f29554824c30c5e8945175d888647acd804ddd04af846c \
--hash=sha256:da46cec9fd2de5be3a8a784f434e4c4ab670b4ff54d605c4c2717e9d49c4c367
# via rich
rich==13.7.0 \
--hash=sha256:5cb5123b5cf9ee70584244246816e9114227e0b98ad9176eede6ad54bf5403fa \
--hash=sha256:6da14c108c4866ee9520bbffa71f6fe3962e193b7da68720583850cd4548e235
# via django-reversion-compare (pyproject.toml)
sqlparse==0.4.4 \
--hash=sha256:5430a4fe2ac7d0f93e66f1efc6e1338a41884b7ddf2a350cedd20ccc4d9d28f3 \
--hash=sha256:d446183e84b8349fa3061f0fe7f06ca94ba65b426946ffebe6e3e8295332420c
# via django
typing-extensions==4.9.0 \
--hash=sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783 \
--hash=sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd
# via asgiref
13 changes: 8 additions & 5 deletions reversion_compare/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
:license: GNU GPL v3 or above, see LICENSE for more details.
"""

import datetime
import decimal
import logging

from django.conf import settings
Expand All @@ -19,6 +21,7 @@
from reversion import is_registered
from reversion.models import Version
from reversion.revisions import _get_options
from rich.pretty import pretty_repr


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -53,11 +56,11 @@ def __init__(self, field, field_name, obj, version_record, follow):
self.value = version_record.field_dict.get(field_name, DOES_NOT_EXIST)

def _obj_repr(self, obj):
# FIXME: How to create a better representation of the current value?
try:
return force_str(obj)
except Exception:
return repr(obj)
if isinstance(obj, (datetime.time, datetime.date, datetime.datetime)):
return obj.isoformat()
if isinstance(obj, decimal.Decimal):
return str(obj)
return pretty_repr(obj, max_width=300, indent_size=4, expand_all=True)

def _choices_repr(self, choices):
flatchoices = dict(self.field.flatchoices)
Expand Down
2 changes: 1 addition & 1 deletion reversion_compare/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def compare(self, obj, version1, version2):
# logger.debug("%s %s %s", field, field.db_type, field.get_internal_type())
try:
field_name = field.name
except BaseException:
except AttributeError:
# is a reverse FK field
field_name = field.field_name

Expand Down
35 changes: 35 additions & 0 deletions reversion_compare/static/reversion_compare.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@media (prefers-color-scheme: dark) {
:root {
--del: #59000f;
--ins: #005608;
}
}
html[data-theme="dark"] {
--del: #59000f;
--ins: #005608;
}
@media (prefers-color-scheme: light) {
:root {
--del: #ff7c8e;
--ins: #7df69a;
}
}
html[data-theme="light"] {
--del: #ff7c8e;
--ins: #7df69a;
}
pre.highlight {
max-width: 900px;
border: 1px solid var(--border-color);
border-radius: 4px;
padding: 5px 6px;
margin-top: 0;
color: var(--body-fg);
background-color: var(--body-bg);
}
del {
background-color: var(--del);
}
ins {
background-color: var(--ins);
}
31 changes: 4 additions & 27 deletions reversion_compare/templates/reversion-compare/compare.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,9 @@
{% extends "admin/base_site.html" %}
{% load i18n %}
{% load i18n static %}

{% block extrastyle %}{{ block.super }}
<style type="text/css">
/* minimal style for the diffs */
pre.highlight {
max-width: 900px;
white-space: pre-line;
}
del, ins {
color: #000;
text-decoration: none;
}
del { background-color: #fdb8c0 }
ins { background-color: #acf2bd; }
sup.follow { color: #5555ff; }
.diff-line {
display: inline-block;
width: 100%;
margin-left: -1.0em;
padding-left: 0.5em;
background-color: #f6f6f6;
color: #222;
}
.diff-line.diff-ins { border-left: 0.5em solid #bef5cb; background-color: #e6ffed; }
.diff-line.diff-del { border-left: 0.5em solid #fdaeb7; background-color: #ffeef0; }
.diff-line.diff-ins.diff-del { border-left: 0.5em solid #bef5cb; background-color: #e6ffed; } /* mixed del/ins == green */
</style>
{% block extrastyle %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="{% static 'reversion_compare.css' %}">
{% endblock %}

{% block breadcrumbs %}
Expand Down
Loading
Loading