Skip to content

Commit

Permalink
update channels from 3.0.5 to 4.1.0 (#713)
Browse files Browse the repository at this point in the history
This is a change that requires some updates to the development setup and
test requirements files.
  • Loading branch information
pyrox0 authored Sep 5, 2024
1 parent 939d7fc commit 6d50307
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ question if it's in the list.
Clone the Git repo and install it in edit mode:

- `git clone git@github.com:GamesDoneQuick/donation-tracker`
- `pip install -e donation-tracker`
- `pip install -e donation-tracker[development]`

Start up a new Django Project like the [Django Tutorial](https://docs.djangoproject.com/en/dev/intro/tutorial01/).

Expand All @@ -130,7 +130,7 @@ Install remaining development dependencies:
- `pre-commit install`
- `pre-commit install --hook-type pre-push`

Add the following apps to the `INSTALLED_APPS` section of `tracker_development/settings.py`:
Add the `daphne` app **to the top of** the `INSTALLED_APPS` section of `tracker_development/settings.py`, then add the following after all other apps:

```
'channels',
Expand Down Expand Up @@ -173,6 +173,7 @@ from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.security.websocket import AllowedHostsOriginValidator
from django.urls import path
from django.core.asgi import get_asgi_application

import tracker.routing

Expand All @@ -184,6 +185,7 @@ application = ProtocolTypeRouter({
)
)
),
'http': get_asgi_application()
})
```

Expand All @@ -203,17 +205,19 @@ urlpatterns = [
]
```

In the main project folder:
In the `tracker_development` folder:

- `python manage.py migrate`
- `python manage.py createsuperuser`
- `python manage.py runserver`

In a separate shell, in the `donation-tracker` folder:

- `yarn start`

If everything boots up correctly, you should be able to visit the [Index Page](http://localhost:8080/tracker).
Additionally, you should be able to open the [Websocket Test Page](http://localhost:8080/tracker/websocket_test/) and
see the heartbeat. If the page loads but the pings don't work, Channels isn't set up correctly. The
You should also be able to open the [Diagnostics Page](http://localhost:8080/admin/tracker/event/diagnostics) and run the websocket test.
If the page loads but the pings don't work, Channels isn't set up correctly. The
[Channels Documentation](https://channels.readthedocs.io/en/latest/installation.html) may be helpful.

## Contributing
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_package_name(name):
install_requires=[
'backports.zoneinfo;python_version<"3.9"',
'celery~=5.0',
'channels>=2.0',
'channels>=4.0',
'Django>=4.2,<5.2',
'django-ajax-selects~=2.1', # publish error, see: https://github.com/crucialfelix/django-ajax-selects/issues/306
'django-ical~=1.7',
Expand All @@ -62,6 +62,9 @@ def get_package_name(name):
'python-dateutil~=2.8.1;python_version<"3.11"',
'requests>=2.27.1,<2.33.0',
],
extras_require={
'development': ['daphne~=4.0'],
},
python_requires='>=3.8, <3.13',
classifiers=[
'Development Status :: 5 - Production/Stable',
Expand Down
3 changes: 2 additions & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# base
celery==5.4.0
channels==3.0.4
channels==4.1.0
# django explicitly not listed here because azure installs a particular series immediately after
django-ajax-selects==2.1.0 # publish error, see: https://github.com/crucialfelix/django-ajax-selects/issues/306
django-ical==1.9.2
Expand All @@ -17,6 +17,7 @@ backports.zoneinfo==0.2.1 ; python_version<"3.9"
python-dateutil==2.8.2 ; python_version<"3.11"
webpack-manifest==2.1.1
# only for testing
daphne==4.1.2
lxml==4.9.4 ; python_version<"3.10" # azure issue?
responses~=0.25.3
selenium==4.24.0
Expand Down
2 changes: 2 additions & 0 deletions tests/routing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.security.websocket import AllowedHostsOriginValidator
from django.core.asgi import get_asgi_application
from django.urls import path

import tracker.routing
Expand All @@ -14,5 +15,6 @@
)
)
),
'http': get_asgi_application(),
}
)
1 change: 1 addition & 0 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
DOMAIN = 'testserver'
SECRET_KEY = 'ForTestingPurposesOnly'
INSTALLED_APPS = [
'daphne',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
Expand Down

0 comments on commit 6d50307

Please sign in to comment.