diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 3c4fb1e..e4c99b7 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -22,26 +22,20 @@ jobs: matrix: django-version: - "4.2" - - "5.0" - "5.1" + - "5.2" python-version: - - "3.8" - "3.9" - "3.10" - "3.11" - "3.12" + - "3.13" exclude: # Django 5.0 is compatible with Python 3.10+ - - python-version: "3.8" - django-version: "5.0" - python-version: "3.9" - django-version: "5.0" - # Django 5.1 is compatible with Python 3.10+ - - python-version: "3.8" django-version: "5.1" - python-version: "3.9" - django-version: "5.1" - + django-version: "5.2" steps: - uses: actions/checkout@v4 diff --git a/LICENSE.txt b/LICENSE.txt index 43898e3..29afb8d 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -6,7 +6,7 @@ are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. @@ -25,4 +25,4 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + diff --git a/README.md b/README.md index 919297d..ba4b5ec 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ This application enables you to create and manage follows, blocks and bi-directi Django 5.0 and 5.1 + Python 3.11 and Python 3.12 support added **>v1.9.6** -Previously: +Previously: - **Django 3.2 since v1.9.1** - **Django 1.11+** since v1.7.0 (latest release supporting **Django 1.10** is v1.6.0) @@ -29,9 +29,8 @@ Previously: ```python urlpatterns = [ - ... - path('friendship/', include('friendship.urls')) - ... + # other paths + path("friendship/", include("friendship.urls")) ] ``` @@ -87,9 +86,10 @@ from friendship.models import Friend, Follow, Block ```python other_user = User.objects.get(pk=1) Friend.objects.add_friend( - request.user, # The sender - other_user, # The recipient - message='Hi! I would like to add you') # This message is optional + request.user, # The sender + other_user, # The recipient + message="Hi! I would like to add you", +) # This message is optional ``` #### Let the user who received the request respond: @@ -97,7 +97,9 @@ Friend.objects.add_friend( ```python from friendship.models import FriendshipRequest -friend_request = FriendshipRequest.objects.get(from_user=request.user, to_user=other_user) +friend_request = FriendshipRequest.objects.get( + from_user=request.user, to_user=other_user +) friend_request.accept() # or friend_request.reject() ``` @@ -167,9 +169,11 @@ Then use any of the following: `django-friendship` supports the following settings: ```python -FRIENDSHIP_CONTEXT_OBJECT_NAME = 'user' -FRIENDSHIP_CONTEXT_OBJECT_LIST_NAME = 'users' -FRIENDSHIP_MANAGER_FRIENDSHIP_REQUEST_SELECT_RELATED_STRATEGY = 'select_related' # ('select_related', 'prefetch_related', 'none') +FRIENDSHIP_CONTEXT_OBJECT_NAME = "user" +FRIENDSHIP_CONTEXT_OBJECT_LIST_NAME = "users" +FRIENDSHIP_MANAGER_FRIENDSHIP_REQUEST_SELECT_RELATED_STRATEGY = ( + "select_related" # ('select_related', 'prefetch_related', 'none') +) ``` ### Contributing diff --git a/docs/index.rst b/docs/index.rst index 0fde331..8331bc7 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -20,4 +20,4 @@ Indices and tables * :ref:`genindex` * :ref:`modindex` * :ref:`search` - + diff --git a/friendship/migrations/0001_initial.py b/friendship/migrations/0001_initial.py index 34241a1..ce55ff4 100644 --- a/friendship/migrations/0001_initial.py +++ b/friendship/migrations/0001_initial.py @@ -5,7 +5,7 @@ class Migration(migrations.Migration): - + dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] diff --git a/friendship/migrations/0002_block.py b/friendship/migrations/0002_block.py index f2c4759..1ed1934 100644 --- a/friendship/migrations/0002_block.py +++ b/friendship/migrations/0002_block.py @@ -5,7 +5,7 @@ class Migration(migrations.Migration): - + dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ("friendship", "0001_initial"), diff --git a/friendship/migrations/0003_block_unique_together.py b/friendship/migrations/0003_block_unique_together.py index 9ed4277..f6f4752 100644 --- a/friendship/migrations/0003_block_unique_together.py +++ b/friendship/migrations/0003_block_unique_together.py @@ -7,7 +7,7 @@ class Migration(migrations.Migration): - + dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ("friendship", "0002_block"), diff --git a/friendship/migrations/0004_auto_20200408_1844.py b/friendship/migrations/0004_auto_20200408_1844.py index 992fccd..227b3c2 100644 --- a/friendship/migrations/0004_auto_20200408_1844.py +++ b/friendship/migrations/0004_auto_20200408_1844.py @@ -4,7 +4,7 @@ class Migration(migrations.Migration): - + dependencies = [ ("friendship", "0003_block_unique_together"), ] diff --git a/friendship/migrations/0005_auto_20211005_1716.py b/friendship/migrations/0005_auto_20211005_1716.py index b3dbcae..cb02ad5 100644 --- a/friendship/migrations/0005_auto_20211005_1716.py +++ b/friendship/migrations/0005_auto_20211005_1716.py @@ -4,7 +4,7 @@ class Migration(migrations.Migration): - + dependencies = [ ('friendship', '0004_auto_20200408_1844'), ] diff --git a/friendship/templates/friendship/block/add.html b/friendship/templates/friendship/block/add.html index 24d707b..0b8766a 100644 --- a/friendship/templates/friendship/block/add.html +++ b/friendship/templates/friendship/block/add.html @@ -5,4 +5,4 @@ -{% endif %} \ No newline at end of file +{% endif %} diff --git a/friendship/templates/friendship/block/blocked_list.html b/friendship/templates/friendship/block/blocked_list.html index dd5b720..0fbaa85 100644 --- a/friendship/templates/friendship/block/blocked_list.html +++ b/friendship/templates/friendship/block/blocked_list.html @@ -3,4 +3,4 @@

Blocking

{% get_by_name friendship_context_object_name as var %} {% blocking var %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/friendship/templates/friendship/block/blockers_list.html b/friendship/templates/friendship/block/blockers_list.html index dd5b720..0fbaa85 100644 --- a/friendship/templates/friendship/block/blockers_list.html +++ b/friendship/templates/friendship/block/blockers_list.html @@ -3,4 +3,4 @@

Blocking

{% get_by_name friendship_context_object_name as var %} {% blocking var %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/friendship/templates/friendship/block/blocking_list.html b/friendship/templates/friendship/block/blocking_list.html index f190721..d4b60c1 100644 --- a/friendship/templates/friendship/block/blocking_list.html +++ b/friendship/templates/friendship/block/blocking_list.html @@ -3,4 +3,4 @@

Blockers

{% get_by_name friendship_context_object_name as var %} {% blockers var %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/friendship/templates/friendship/follow/add.html b/friendship/templates/friendship/follow/add.html index 2e2af2e..48eb83a 100644 --- a/friendship/templates/friendship/follow/add.html +++ b/friendship/templates/friendship/follow/add.html @@ -5,4 +5,4 @@ -{% endif %} \ No newline at end of file +{% endif %} diff --git a/friendship/templates/friendship/follow/followers_list.html b/friendship/templates/friendship/follow/followers_list.html index 1bedc3c..6dbebe8 100644 --- a/friendship/templates/friendship/follow/followers_list.html +++ b/friendship/templates/friendship/follow/followers_list.html @@ -3,4 +3,4 @@

Followers

{% get_by_name friendship_context_object_name as var %} {% followers var %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/friendship/templates/friendship/follow/following_list.html b/friendship/templates/friendship/follow/following_list.html index 1993c03..bd82f1b 100644 --- a/friendship/templates/friendship/follow/following_list.html +++ b/friendship/templates/friendship/follow/following_list.html @@ -3,4 +3,4 @@

Following

{% get_by_name friendship_context_object_name as var %} {% following var %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/friendship/templates/friendship/friend/add.html b/friendship/templates/friendship/friend/add.html index 7d2f6fa..126c88c 100644 --- a/friendship/templates/friendship/friend/add.html +++ b/friendship/templates/friendship/friend/add.html @@ -5,4 +5,4 @@ -{% endif %} \ No newline at end of file +{% endif %} diff --git a/friendship/templates/friendship/friend/user_list.html b/friendship/templates/friendship/friend/user_list.html index 687fc44..09905ed 100644 --- a/friendship/templates/friendship/friend/user_list.html +++ b/friendship/templates/friendship/friend/user_list.html @@ -3,4 +3,4 @@

Your Friends

{% get_by_name friendship_context_object_name as var %} {% friends var %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/friendship/templates/friendship/templatetags/blockers.html b/friendship/templates/friendship/templatetags/blockers.html index bd61376..d15f9b3 100644 --- a/friendship/templates/friendship/templatetags/blockers.html +++ b/friendship/templates/friendship/templatetags/blockers.html @@ -1,5 +1,5 @@ + {% endfor %} + diff --git a/friendship/templates/friendship/templatetags/followers.html b/friendship/templates/friendship/templatetags/followers.html index de9ac1c..66f6482 100644 --- a/friendship/templates/friendship/templatetags/followers.html +++ b/friendship/templates/friendship/templatetags/followers.html @@ -1,5 +1,5 @@ + {% endfor %} + diff --git a/friendship/templates/friendship/templatetags/friend_count.html b/friendship/templates/friendship/templatetags/friend_count.html index 36c57b6..b1c7a8a 100644 --- a/friendship/templates/friendship/templatetags/friend_count.html +++ b/friendship/templates/friendship/templatetags/friend_count.html @@ -1 +1 @@ -{% if friend_count %}{{ friend_count }}{% endif %} \ No newline at end of file +{% if friend_count %}{{ friend_count }}{% endif %} diff --git a/friendship/templates/friendship/templatetags/friend_rejected_count.html b/friendship/templates/friendship/templatetags/friend_rejected_count.html index b451cca..39167c4 100644 --- a/friendship/templates/friendship/templatetags/friend_rejected_count.html +++ b/friendship/templates/friendship/templatetags/friend_rejected_count.html @@ -1 +1 @@ -{% if friend_rejected_count %}{{ friend_rejected_count }}{% endif %} \ No newline at end of file +{% if friend_rejected_count %}{{ friend_rejected_count }}{% endif %} diff --git a/friendship/tests/templates/friendship/block/add.html b/friendship/tests/templates/friendship/block/add.html index ed77a90..5c962c1 100644 --- a/friendship/tests/templates/friendship/block/add.html +++ b/friendship/tests/templates/friendship/block/add.html @@ -4,4 +4,4 @@ -{% endif %} \ No newline at end of file +{% endif %} diff --git a/friendship/tests/templates/friendship/block/blockers_list.html b/friendship/tests/templates/friendship/block/blockers_list.html index 7c2c33f..b8c1639 100644 --- a/friendship/tests/templates/friendship/block/blockers_list.html +++ b/friendship/tests/templates/friendship/block/blockers_list.html @@ -1,5 +1,5 @@ -{% block content %} +{% block content %} {% load friendshiptags %}

Blockers

{% blockers object %} -{% endblock %} +{% endblock %} diff --git a/friendship/tests/templates/friendship/block/blocking_list.html b/friendship/tests/templates/friendship/block/blocking_list.html index 4b0720b..448dd78 100644 --- a/friendship/tests/templates/friendship/block/blocking_list.html +++ b/friendship/tests/templates/friendship/block/blocking_list.html @@ -1,5 +1,5 @@ -{% block content %} -{% load friendshiptags %} +{% block content %} +{% load friendshiptags %}

Blocking

{% blocking object %} {% endblock content %} diff --git a/friendship/tests/templates/friendship/follow/add.html b/friendship/tests/templates/friendship/follow/add.html index ec13839..f52ca7e 100644 --- a/friendship/tests/templates/friendship/follow/add.html +++ b/friendship/tests/templates/friendship/follow/add.html @@ -4,4 +4,4 @@ -{% endif %} \ No newline at end of file +{% endif %} diff --git a/friendship/tests/templates/friendship/follow/followers_list.html b/friendship/tests/templates/friendship/follow/followers_list.html index 39b9557..bc8e195 100644 --- a/friendship/tests/templates/friendship/follow/followers_list.html +++ b/friendship/tests/templates/friendship/follow/followers_list.html @@ -1,5 +1,5 @@ -{% block content %} +{% block content %} {% load friendshiptags %} -

Followers

+

Followers

{% followers object %} -{% endblock %} +{% endblock %} diff --git a/friendship/tests/templates/friendship/follow/following_list.html b/friendship/tests/templates/friendship/follow/following_list.html index 9ec7c2f..aee3a14 100644 --- a/friendship/tests/templates/friendship/follow/following_list.html +++ b/friendship/tests/templates/friendship/follow/following_list.html @@ -1,5 +1,5 @@ -{% block content %} -{% load friendshiptags %} -

Following

+{% block content %} +{% load friendshiptags %} +

Following

{% following object %} {% endblock content %} diff --git a/friendship/tests/templates/friendship/friend/add.html b/friendship/tests/templates/friendship/friend/add.html index 4e2ff74..3c85903 100644 --- a/friendship/tests/templates/friendship/friend/add.html +++ b/friendship/tests/templates/friendship/friend/add.html @@ -4,4 +4,4 @@ -{% endif %} \ No newline at end of file +{% endif %} diff --git a/friendship/tests/templates/friendship/friend/user_list.html b/friendship/tests/templates/friendship/friend/user_list.html index fb37398..6cbef7f 100644 --- a/friendship/tests/templates/friendship/friend/user_list.html +++ b/friendship/tests/templates/friendship/friend/user_list.html @@ -1,5 +1,5 @@ -{% block content %} +{% block content %} {% load friendshiptags %} -

Your Friends

+

Your Friends

{% friends object %} -{% endblock %} +{% endblock %} diff --git a/friendship/tests/templates/friendship/templatetags/followers.html b/friendship/tests/templates/friendship/templatetags/followers.html index de9ac1c..66f6482 100644 --- a/friendship/tests/templates/friendship/templatetags/followers.html +++ b/friendship/tests/templates/friendship/templatetags/followers.html @@ -1,5 +1,5 @@ + {% endfor %} + diff --git a/friendship/tests/tests.py b/friendship/tests/tests.py index 6ea1ee3..c829ead 100644 --- a/friendship/tests/tests.py +++ b/friendship/tests/tests.py @@ -227,7 +227,8 @@ def test_multiple_friendship_requests(self): ) def test_multiple_calls_add_friend(self): - """Ensure multiple calls with same friends, but different message works as expected""" + """Ensure multiple calls with same friends, but different + message works as expected""" Friend.objects.add_friend(self.user_bob, self.user_steve, message="Testing") with self.assertRaises(AlreadyExistsError): diff --git a/noxfile.py b/noxfile.py index ee0b481..c698ffe 100644 --- a/noxfile.py +++ b/noxfile.py @@ -3,14 +3,21 @@ # DJANGO_STABLE_VERSION should be set to the latest Django LTS version # and should *not* appear in DJANGO_VERSIONS -DJANGO_STABLE_VERSION = "4.2" -DJANGO_VERSIONS = ["4.2", "5.0", "5.1", "main"] +DJANGO_STABLE_VERSION = "5.2" +DJANGO_VERSIONS = ["4.2", "5.1", "main"] # PYTHON_STABLE_VERSION should be set to the latest stable Python version # and should *not* appear in PYTHON_VERSIONS -PYTHON_STABLE_VERSION = "3.11" -PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11", "3.12"] +PYTHON_STABLE_VERSION = "3.13" +PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12"] + + +INVALID_PYTHON_DJANGO_SESSIONS = [ + ("3.9", "5.1"), + ("3.9", "5.2"), +] + nox.options.default_venv_backend = "uv|venv" nox.options.reuse_existing_virtualenvs = True @@ -41,8 +48,10 @@ def test_django_version(session: nox.Session, django: str) -> None: @nox.session(python=PYTHON_VERSIONS, tags=["python"]) @nox.parametrize("django", [DJANGO_STABLE_VERSION]) def test_python_version(session: nox.Session, django: str) -> None: - if session.python == PYTHON_STABLE_VERSION: - session.skip() + if (session.python, django) in INVALID_PYTHON_DJANGO_SESSIONS: + session.skip( + f"Skipping invalid combination: Python {session.python} + Django {django}" + ) session.install(".[test]") session.install(f"django~={django}.0")