Skip to content
Closed
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
12 changes: 3 additions & 9 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.

26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -29,9 +29,8 @@ Previously:

```python
urlpatterns = [
...
path('friendship/', include('friendship.urls'))
...
# other paths
path("friendship/", include("friendship.urls"))
]
```

Expand Down Expand Up @@ -87,17 +86,20 @@ 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:

```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()
```
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ Indices and tables
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

2 changes: 1 addition & 1 deletion friendship/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
Expand Down
2 changes: 1 addition & 1 deletion friendship/migrations/0002_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("friendship", "0001_initial"),
Expand Down
2 changes: 1 addition & 1 deletion friendship/migrations/0003_block_unique_together.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("friendship", "0002_block"),
Expand Down
2 changes: 1 addition & 1 deletion friendship/migrations/0004_auto_20200408_1844.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class Migration(migrations.Migration):

dependencies = [
("friendship", "0003_block_unique_together"),
]
Expand Down
2 changes: 1 addition & 1 deletion friendship/migrations/0005_auto_20211005_1716.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class Migration(migrations.Migration):

dependencies = [
('friendship', '0004_auto_20200408_1844'),
]
Expand Down
2 changes: 1 addition & 1 deletion friendship/templates/friendship/block/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
<input type="hidden" name="blocked_username" value="{{ blocked_username }}" />
<input type="submit" value="block {{ blocked_username }}" />
</form>
{% endif %}
{% endif %}
2 changes: 1 addition & 1 deletion friendship/templates/friendship/block/blocked_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
<h1>Blocking</h1>
{% get_by_name friendship_context_object_name as var %}
{% blocking var %}
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion friendship/templates/friendship/block/blockers_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
<h1>Blocking</h1>
{% get_by_name friendship_context_object_name as var %}
{% blocking var %}
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion friendship/templates/friendship/block/blocking_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
<h1>Blockers</h1>
{% get_by_name friendship_context_object_name as var %}
{% blockers var %}
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion friendship/templates/friendship/follow/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
<input type="hidden" name="followee_username" value="{{ followee_username }}" />
<input type="submit" value="start following {{ followee_username }}" />
</form>
{% endif %}
{% endif %}
2 changes: 1 addition & 1 deletion friendship/templates/friendship/follow/followers_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
<h1>Followers</h1>
{% get_by_name friendship_context_object_name as var %}
{% followers var %}
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion friendship/templates/friendship/follow/following_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
<h1>Following</h1>
{% get_by_name friendship_context_object_name as var %}
{% following var %}
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion friendship/templates/friendship/friend/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
<input type="hidden" name="to_username" value="{{ to_username }}" />
<input type="submit" value="add {{ to_username }} as a friend" />
</form>
{% endif %}
{% endif %}
2 changes: 1 addition & 1 deletion friendship/templates/friendship/friend/user_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
<h1>Your Friends</h1>
{% get_by_name friendship_context_object_name as var %}
{% friends var %}
{% endblock %}
{% endblock %}
4 changes: 2 additions & 2 deletions friendship/templates/friendship/templatetags/blockers.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ul>
{% for f in blockers %}
<li>{{ f.first_name }} {{ f.last_name }}</li>
{% endfor %}
</ul>
{% endfor %}
</ul>
4 changes: 2 additions & 2 deletions friendship/templates/friendship/templatetags/followers.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ul>
{% for f in followers %}
<li>{{ f.first_name }} {{ f.last_name }}</li>
{% endfor %}
</ul>
{% endfor %}
</ul>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{% if friend_count %}{{ friend_count }}{% endif %}
{% if friend_count %}{{ friend_count }}{% endif %}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{% if friend_rejected_count %}{{ friend_rejected_count }}{% endif %}
{% if friend_rejected_count %}{{ friend_rejected_count }}{% endif %}
2 changes: 1 addition & 1 deletion friendship/tests/templates/friendship/block/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
<input type="hidden" name="blocked_username" value="{{ blocked_username }}" />
<input type="submit" value="start blocking {{ blocked_username }}" />
</form>
{% endif %}
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% block content %}
{% block content %}
{% load friendshiptags %}
<h1>Blockers</h1>
{% blockers object %}
{% endblock %}
{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% block content %}
{% load friendshiptags %}
{% block content %}
{% load friendshiptags %}
<h1>Blocking</h1>
{% blocking object %}
{% endblock content %}
2 changes: 1 addition & 1 deletion friendship/tests/templates/friendship/follow/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
<input type="hidden" name="followee_username" value="{{ followee_username }}" />
<input type="submit" value="start following {{ followee_username }}" />
</form>
{% endif %}
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% block content %}
{% block content %}
{% load friendshiptags %}
<h1>Followers</h1>
<h1>Followers</h1>
{% followers object %}
{% endblock %}
{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% block content %}
{% load friendshiptags %}
<h1>Following</h1>
{% block content %}
{% load friendshiptags %}
<h1>Following</h1>
{% following object %}
{% endblock content %}
2 changes: 1 addition & 1 deletion friendship/tests/templates/friendship/friend/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
<input type="hidden" name="to_username" value="{{ to_username }}" />
<input type="submit" value="add {{ to_username }} as a friend" />
</form>
{% endif %}
{% endif %}
6 changes: 3 additions & 3 deletions friendship/tests/templates/friendship/friend/user_list.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% block content %}
{% block content %}
{% load friendshiptags %}
<h1>Your Friends</h1>
<h1>Your Friends</h1>
{% friends object %}
{% endblock %}
{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ul>
{% for f in followers %}
<li>{{ f.first_name }} {{ f.last_name }}</li>
{% endfor %}
</ul>
{% endfor %}
</ul>
3 changes: 2 additions & 1 deletion friendship/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
21 changes: 15 additions & 6 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down