Git Product home page Git Product logo

django-directmessages's Introduction

Django-Directmessages

image

Django-Directmessages is a low-level and easy-to-use Django App to manage simple directmessages. In contrast to other Django Apps for messaging, Django-Directmessages doesn't use any type of pre-built templates and is concentrated on the programmatic usage.

Django-Directmessage is thought to be used with APIs or small apps, but can be used for any type of messaging. It featues:

  • Sending of private 1-to-1 messages between users.
  • Listing unread messages for a given user.
  • Read a given message
  • Get all conversation partners/contacted users for a given user
  • Read a whole conversation between two users.

Requirements

Django >= 1.5 is supported

Installation

  1. pip install django-directmessages
  2. add "directmessages" to INSTALLED_APPS and run python manage.py migrate.

Usage

Import the Message Management API on top of your views.py :

from directmessages.apps import Inbox
  • Send message: Inbox.send_message(from_user, to_user, message)
  • List all unread messages: Inbox.get_unread_messages(user)
  • Read a message (and mark as read): Inbox.read_message(message)
  • Print a message as <user>: <message>: Inbox.read_message_formatted(message)
  • Print a list of all conversation partners for a user: Inbox.get_conversations(users)
  • Get a conversation between two users: Inbox.get_conversation(user1, user2, _limit_, _reversed_, _mark_read_)
    • Limit (Int: optional): Instead of getting the whole conversation, get the first 50 (depends on reversed)
    • Reversed (Bool: optional): Usually the 'limit'-param gives back the first x messages, if you put Reversed to True, limit will give back the x latest messages.
    • Mark_Read (Bool: optional): Mark all messages in conversation as read

Signals

You can use the following signals to extend the app for your needs

  • message_sent:

    Gets called as soon as a message is sent. Provides the Message object, the sender and the recipient as params.

  • message_read:

    Gets called as soon as a message is read: Provides the Message object, the sender and the recipient as params.

Contributing

Bug reports, patches and fixes are always welcome!

To Do

  • Add some security functions (e.g checking if user is allowed to read a message)
  • Add some custom exceptions (e.g. when no message was found)

django-directmessages's People

Contributors

ad-m avatar dmonn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

django-directmessages's Issues

On delete parameter foreign key error on migrate

When migration is done the following error is thrown. Kindly include foreign key on delete parameter to the models.

File "manage.py", line 15, in <module> File "/media/phang/venv/lib/python3.6/site-packages/directmessages/models.py", line 16, in <module> class Message(models.Model): File "/media/phang/venv/lib/python3.6/site-packages/directmessages/models.py", line 21, in Message sender = models.ForeignKey(AUTH_USER_MODEL, related_name='sent_dm', verbose_name=_("Sender")) TypeError: __init__() missing 1 required positional argument: 'on_delete'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.