Django-Private-Chat Documentation: Release 0.3.0
Django-Private-Chat Documentation: Release 0.3.0
Release 0.3.0
delneg
2 Installation 7
3 Usage 9
4 Messages 11
5 Settings 13
6 Admin 15
8 Contributing 19
8.1 Types of Contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
8.2 Get Started! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
8.3 Pull Request Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
8.4 Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
9 Credits 23
9.1 Development Lead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
9.2 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
10 0.3.0 (2020-05-03) 25
11 0.2.2 (2018-12-12) 27
12 0.2.1 (2018-12-07) 29
13 0.2.0 (2018-10-22) 31
14 0.1.9 (2018-07-16) 33
15 0.1.8 (2018-03-23) 35
i
16 0.1.7 (2018-03-20) 37
17 0.1.6 (2017-04-11) 39
18 0.1.5 (2017-03-11) 41
19 0.1.4 (2017-02-12) 43
20 0.1.3 (2017-02-11) 45
21 0.1.2 (2017-02-11) 47
22 0.1.1 (2017-02-10) 49
23 0.1.0 (2017-02-10) 51
ii
django-private-chat Documentation, Release 0.3.0
Contents:
CONTENTS 1
django-private-chat Documentation, Release 0.3.0
2 CONTENTS
CHAPTER
ONE
This app uses separate management command, run_chat_server for running Websockets in Django context. It is
intended to be used with something like Supervisor or Systemd to run asyncio webserver as a separate one from
Django. We didn’t want our app to be limited to be used together with Django Channels - that’s why we did it that
way.
You can find an example Systemd config to run it as a service at https://github.com/Bearle/django-private-chat/blob/
dev/example.service
P.S. Don’t forget to change CHAT_WS_SERVER_HOST && CHAT_WS_SERVER_PORT &&
CHAT_WS_SERVER_PROTOCOL settings!
3
django-private-chat Documentation, Release 0.3.0
1.2 Documentation
The full documentation is (finally) at https://django-private-chat.readthedocs.io . You can also check the docstrings &
this readme.
You can check out our example project by cloning the repo and heading into example/ directory. There is a README
file for you to check, initial data to check out the chat included.
venv/lib/pythonX.X/site-packages/django_private_chat/templates/django_private_chat/
˓→dialogs.html
to
yourapp/templates/django_private_chat/dialogs.html
And feel free to edit it as you like! We intentionally left the JS code inside for it to be editable easily.
Install django-private-chat:
Migrate:
Note: you can use this package with or without uvloop, just run either
or run
INSTALLED_APPS = (
...
'django_private_chat',
...
)
Add the server & port for your asyncio server to settings:
CHAT_WS_SERVER_HOST = 'localhost'
CHAT_WS_SERVER_PORT = 5002
CHAT_WS_SERVER_PROTOCOL = 'ws'
DATETIME_FORMAT
urlpatterns = [
...
url(r'^', include('django_private_chat.urls')),
...
]
Add
/dialogs/some_existing_username
(also works with uvloop). The “cert.pem” file should be a plaintext PEM file containing first a private key, then a
certificate (may be a concatenation of a .key and a .crt file). Please note that wss will use TLSv1 by default for python
3.5 & 3.4 and will use ssl.PROTOCOL_TLS_SERVER for 3.6 and above. Features ——–
-:white_check_mark: Uses current app model (get_user_model() and settings.AUTH_USER_MODEL)
-:white_check_mark: Translatable (uses ugettext and {% trans %} )
-:white_check_mark: One-to-one user chat
-:white_check_mark: Works using WebSockets
-:white_check_mark: Works (optionally) using WSS (TLS) connections (disclaimer - security not guaranteed)
-:white_check_mark: Displays online/offline status
-:white_check_mark: Display typing/not typing status
-:white_check_mark: Soft deletable message model - be sure to keep messages to comply with message-keeping laws
-:white_check_mark: Flash the dialog button when the user you are not currently talking to wrote you a message
-:point_right: TODO: add a dialog to the list when new one started
-:point_right: TODO: add user-not-found and other alerts
-:point_right: possible Redis backend intergration
source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox
1.7 Credits
TWO
INSTALLATION
7
django-private-chat Documentation, Release 0.3.0
8 Chapter 2. Installation
CHAPTER
THREE
USAGE
INSTALLED_APPS = (
...
'django_private_chat',
...
)
Add the server & port for your asyncio server to settings:
CHAT_WS_SERVER_HOST = 'localhost'
CHAT_WS_SERVER_PORT = 5002
CHAT_WS_SERVER_PROTOCOL = 'ws'
urlpatterns = [
...
url(r'^', include(django_private_chat_urls)),
...
]
or
urlpatterns = [
...
path('', include(django_private_chat.urls)),
...
]
Add
9
django-private-chat Documentation, Release 0.3.0
10 Chapter 3. Usage
CHAPTER
FOUR
MESSAGES
'new-message',
'new-user',
'online',
'offline',
'check-online',
'is-typing',
'read_message'
{
type: 'new-message',
session_key: '{{ request.session.session_key }}',
username: opponent_username,
message: message
}
In the handler, a new Message object is created and the received packet along with the additional parameters is
sene to the other user’s websocket (if present)
packet['created'] = msg.get_formatted_create_datetime()
packet['sender_name'] = msg.sender.username
packet['message_id'] = msg.id
online Informs the users when someone of other has gone online.
11
django-private-chat Documentation, Release 0.3.0
12 Chapter 4. Messages
CHAPTER
FIVE
SETTINGS
CHAT_WS_SERVER_HOST = 'localhost'
CHAT_WS_SERVER_PORT = 5002
CHAT_WS_SERVER_PROTOCOL = 'ws'
DATETIME_FORMAT = "d.m.Y H:i:s"
13
django-private-chat Documentation, Release 0.3.0
14 Chapter 5. Settings
CHAPTER
SIX
ADMIN
Application provides django admin intergration for Dialog and Message models.
In order to provide custom admin representation, first you have to unregister existing:
15
django-private-chat Documentation, Release 0.3.0
16 Chapter 6. Admin
CHAPTER
SEVEN
17
django-private-chat Documentation, Release 0.3.0
EIGHT
CONTRIBUTING
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Look through the GitHub issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.
Look through the GitHub issues for features. Anything tagged with “feature” is open to whoever wants to implement
it.
django-private-chat could always use more documentation, whether as part of the official django-private-chat docs, in
docstrings, or even on the web in blog posts, articles, and such.
19
django-private-chat Documentation, Release 0.3.0
3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up
your fork for local development:
$ mkvirtualenv django-private-chat
$ cd django-private-chat/
$ python setup.py develop
To get flake8 and tox, just pip install them into your virtualenv.
6. Commit your changes and push your branch to GitHub:
$ git add .
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature
20 Chapter 8. Contributing
django-private-chat Documentation, Release 0.3.0
Before you submit a pull request, check that it meets these guidelines:
1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function
with a docstring, and add the feature to the list in README.rst.
8.4 Tips
22 Chapter 8. Contributing
CHAPTER
NINE
CREDITS
• delneg <[email protected]>
• guitarmustafa <[email protected]>
9.2 Contributors
23
django-private-chat Documentation, Release 0.3.0
24 Chapter 9. Credits
CHAPTER
TEN
0.3.0 (2020-05-03)
25
django-private-chat Documentation, Release 0.3.0
ELEVEN
0.2.2 (2018-12-12)
27
django-private-chat Documentation, Release 0.3.0
TWELVE
0.2.1 (2018-12-07)
29
django-private-chat Documentation, Release 0.3.0
THIRTEEN
0.2.0 (2018-10-22)
31
django-private-chat Documentation, Release 0.3.0
FOURTEEN
0.1.9 (2018-07-16)
33
django-private-chat Documentation, Release 0.3.0
FIFTEEN
0.1.8 (2018-03-23)
35
django-private-chat Documentation, Release 0.3.0
SIXTEEN
0.1.7 (2018-03-20)
37
django-private-chat Documentation, Release 0.3.0
SEVENTEEN
0.1.6 (2017-04-11)
• Fixed bugs with static files and added comment about extra_js block to readme
39
django-private-chat Documentation, Release 0.3.0
EIGHTEEN
0.1.5 (2017-03-11)
• Added flashing other user button when he sent you a message and you’re in another dialog
41
django-private-chat Documentation, Release 0.3.0
NINETEEN
0.1.4 (2017-02-12)
43
django-private-chat Documentation, Release 0.3.0
TWENTY
0.1.3 (2017-02-11)
45
django-private-chat Documentation, Release 0.3.0
TWENTYONE
0.1.2 (2017-02-11)
47
django-private-chat Documentation, Release 0.3.0
TWENTYTWO
0.1.1 (2017-02-10)
• Added migrations.
49
django-private-chat Documentation, Release 0.3.0
TWENTYTHREE
0.1.0 (2017-02-10)
51