• Stars
    star
    197
  • Rank 196,519 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created over 14 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a Django app for allowing users of your site to send messages to each other

Pinax Messages

CircleCi Codecov

Table of Contents

About Pinax

Pinax is an open-source platform built on the Django Web Framework. It is an ecosystem of reusable Django apps, themes, and starter project templates. This collection can be found at http://pinaxproject.com.

Important Links

Where you can find what you need:

pinax-messages

Overview

pinax-messages is an app for providing private user-to-user threaded messaging.

Supported Django and Python Versions

Django / Python 3.6 3.7 3.8
2.2 * * *
3.0 * * *

Documentation

Installation

To install pinax-messages:

    $ pip install pinax-messages

Add pinax.messages to your INSTALLED_APPS setting:

INSTALLED_APPS = [
    # other apps
    "pinax.messages",
]

Run Django migrations to create pinax-messages database tables:

    $ python manage.py migrate

Add pinax.messages.urls to your project urlpatterns:

    urlpatterns = [
        # other urls
        url(r"^messages/", include("pinax.messages.urls", namespace="pinax_messages")),
    ]

Usage

pinax-messages handles user-to-user private threaded messaging primarily by the inclusion of template snippets. These snippets fall into three categories: view message inbox (all threads), view message thread, and create (or respond to) a message.

Access Inbox

Place this snippet wherever a "Message Inbox" link is needed for viewing user message inbox:

<a href="{% url 'pinax_messages:inbox' %}"><i class="fa fa-envelope"></i> {% trans "Message Inbox" %}</a>

View Message Thread

Place this snippet wherever you have need to view a specific message thread:

<a href="{% url 'pinax_messages:thread_detail' thread.pk %}"><i class="fa fa-envelope"></i> {% trans "View Message Thread" %}</a>

Create Message - Template

Add the following line to an object template in order to provide a button for messaging a user associated with object:

<a href="{% url "pinax_messages:message_user_create" user_id=object.user.id %}" class="btn btn-default">Message this user</a>

Create Message - Code

Use the following code to create a new message programmatically. Note that to_users (message recipients) is a list, allowing messages sent to multiple users.

from pinax.messages.models import Message

Message.new_message(from_user=self.request.user, to_users=[user], subject=subject, content=content)

Template Context Variables

pinax-messages provides two context variables using a template context processor. In order to access these in your templates, add user_messages to your TEMPLATES settings:

TEMPLATES = [
    {
        # ...
        "OPTIONS": {
            # other options
            "context_processors": [
                # other processors
                "pinax.messages.context_processors.user_messages"
            ],
        },
    },
]

The following context variables are available, and work with the current authenticated user:

  • inbox_threads β€” all message threads for current user
  • unread_threads β€” unread message threads for current user

Template Tags and Filters

unread

Determines if a message thread has unread messages for a user.

Argument: user

For instance if there are unread messages in a thread, change the CSS class accordingly:

{% load pinax_messages_tags %}

    <div class="thread {% if thread|unread:user %}unread{% endif %}">
    ...
    </div>

unread_thread_count

Returns the number of unread threads for the user. Use for notifying a user of new messages, for example in account_bar.html

Argument: user

For instance if there are unread messages in a thread, change the CSS class accordingly:

{% load pinax_messages_tags %}

    {% with user|unread_thread_count as user_unread %}
    <li class="{% if user_unread %}unread{% endif %}">
        <a href="{% url 'pinax_messages:inbox' %}"><i class="fa fa-envelope"></i> {% trans "Messages" %}
            {% if user_unread %}<sup>{{ user_unread }}</sup>{% endif %}
        </a>
    </li>        
    {% endwith %}

Reference Guide

URL–View–Template Matrix

URL Name View Template
pinax-messages:inbox InboxView() inbox.html
pinax-messages:message_create MessageCreateView() message_create.html
pinax-messages:message_user_create MessageCreateView() message_create.html
pinax-messages:thread_detail ThreadView() thread_detail.html
pinax-messages:thread_delete ThreadDeleteView() N/A

URL Names

These URL names are available when using pinax-messages urls.py:

pinax-messages:inbox β€” Inbox view

pinax-messages:message_create β€” Create new message

pinax-messages:message_user_create β€” Create new message to specific user

pinax-messages:thread_detail β€” View message thread, requires thread PK

pinax-messages:thread_delete β€” Delete message thread, requires thread PK

Views

InboxView - Display all message threads

MessageCreateView β€” Create a new message thread

ThreadView β€” View specific message thread

ThreadDeleteView β€” Delete specific message thread

Forms

NewMessageForm β€” creates a new message thread to a single user

NewMessageFormMultiple β€” creates a new message thread to multiple users

MessageReplyForm - creates a reply to a message thread

Templates

Default templates are provided by the pinax-templates app in the messages section of that project.

Reference pinax-templates installation instructions to include these templates in your project.

View live pinax-templates examples and source at Pinax Templates!

Customizing Templates

Override the default pinax-templates templates by copying them into your project subdirectory pinax/messages/ on the template path and modifying as needed.

For example if your project doesn't use Bootstrap, copy the desired templates then remove Bootstrap and Font Awesome class names from your copies. Remove class references like class="btn btn-success" and class="icon icon-pencil" as well as bootstrap from the {% load i18n bootstrap %} statement. Since bootstrap template tags and filters are no longer loaded, you'll also need to update {{ form|bootstrap }} to {{ form }} since the "bootstrap" filter is no longer available.

inbox.html

Displays inbox message threads.

thread_detail.html

Show message thread and allow response.

message_create.html

New message form.

Signals

message_sent β€” providing_args = ["message", "thread", "reply"]

Change Log

3.0.0

  • Drop Django 1.11, 2.0, and 2.1, and Python 2,7, 3.4, and 3.5 support
  • Add Django 2.2 and 3.0, and Python 3.6, 3.7, and 3.8 support
  • Update packaging configs
  • Direct users to community resources

2.0.2

  • Update CI config
  • Update MANIFEST.in
  • Add sorting guidance for 3rd-party app imports
  • Improve documentation markup
  • Remove pinax-theme-bootstrap from test requirements

2.0.1

  • Update test config
  • Update documentation

2.0.0

  • Standardize documentation layout
  • Drop Django v1.8, v1.10 support

1.2.0

  • Add unread_thread_count template filter

1.1.0

  • Add Django 2.0 compatibility testing
  • Drop Django 1.9 and Python 3.3 support
  • Move documentation into README
  • Convert CI and coverage to CircleCi and CodeCov
  • Add PyPi-compatible long description

1.0.1

  • Fix thread delete view with correct template path and success URL

1.0.0

  • add documentation

0.3

  • convert to Django generic CBVs
  • various fixes and cleanup

0.1

  • initial release

History

This app was formerly named user-messages but was renamed after being donated to Pinax from Eldarion.

Contribute

Contributing information can be found in the Pinax community health file repo.

Code of Conduct

In order to foster a kind, inclusive, and harassment-free community, the Pinax Project has a Code of Conduct. We ask you to treat everyone as a smart human programmer that shares an interest in Python, Django, and Pinax with you.

Connect with Pinax

For updates and news regarding the Pinax Project, please follow us on Twitter @pinaxproject and check out our Pinax Project blog.

License

Copyright (c) 2012-present James Tauber and contributors under the MIT license.

More Repositories

1

pinax

a Django-based platform for rapidly developing websites
Python
2,624
star
2

django-user-accounts

User accounts for Django
Python
1,109
star
3

django-mailer

mail queuing and management for the Django web framework
Python
721
star
4

pinax-stripe-light

a payments Django app for Stripe
Python
677
star
5

pinax-blog

a blog app for Django
Python
461
star
6

pinax-badges

a badges app for Django
Python
317
star
7

symposion

a Django project for conference websites
Python
300
star
8

pinax-theme-bootstrap

A theme for Pinax based on Twitter's Bootstrap
HTML
269
star
9

pinax-referrals

a referrals app for Django
Python
208
star
10

django-forms-bootstrap

Bootstrap filter and templates for use with Django forms
Python
175
star
11

pinax-likes

a liking app for Django
Python
156
star
12

pinax-webanalytics

analytics and metrics integration for Django
Python
122
star
13

pinax-project-account

a starter project that incorporates account features from django-user-accounts
119
star
14

pinax-eventlog

An event logger
Python
108
star
15

pinax-invitations

a site invitation app for Django
Python
108
star
16

pinax-comments

a comments app for Django
Python
97
star
17

pinax-models

Provide Support for Logical Deletes on Models and in the Django Admin
Python
90
star
18

pinax-ratings

a ratings app for Django
Python
88
star
19

pinax-starter-projects

Pinax Starter Projects
Shell
79
star
20

django-flag

flagging of inapproriate/spam content
Python
73
star
21

django-waitinglist

DEPRECATED - please see https://github.com/pinax/pinax-waitinglist
Python
64
star
22

pinax-points

a points, positions and levels app for Django
Python
61
star
23

pinax-calendars

Django utilities for publishing events as a calendar
Python
61
star
24

pinax-documents

a document management app for Django
Python
59
star
25

pinax-boxes

database-driven regions on webpages for Django
Python
48
star
26

pinax-teams

an app for Django sites that supports open, by invitation, and by application teams
Python
47
star
27

pinax-starter-app

A starter app template for Pinax apps
Python
36
star
28

pinax-wiki

Easily add a wiki to your Django site
Python
32
star
29

pinax-project-symposion

a starter project demonstrating a minimal symposion instance
HTML
31
star
30

code.pinaxproject.com

the site behind code.pinaxproject.com
Python
29
star
31

pinax-forums

an extensible forums app for Django and Pinax
Python
27
star
32

pinax-project-zero

the foundation for other Pinax starter projects
25
star
33

pinax-waitinglist

a Django waiting list app
Python
25
star
34

pinax-testimonials

a testimonials app for Django
Python
24
star
35

pinax-project-teams

a starter project that has account management, profiles, teams and basic collaborative content.
18
star
36

pinax-images

an app for managing collections of images associated with a content object
Python
17
star
37

pinax-templates

semantic templates for pinax apps
HTML
15
star
38

pinax-phone-confirmation

An app to provide phone confirmation via Twilio
Python
15
star
39

pinax-project-socialauth

a starter project that supports social authentication
CSS
15
star
40

pinax-api

RESTful API adhering to the JSON:API specification
Python
13
star
41

pinax-submissions

an app for proposing and reviewing submissions
Python
12
star
42

pinax-project-blog

a blog starter project
10
star
43

pinax-project-forums

an out-of-the-box Pinax starter project implementing forums
HTML
10
star
44

pinax-images-panel

a React component for uploading and managing images with the pinax-images Django reusable app
JavaScript
9
star
45

pinax-cohorts

Create cohorts to invite to join your private beta site. Depends on pinax-waitinglist.
Python
9
star
46

pinax-pages

A light weight CMS born out of Symposion
Python
8
star
47

pinax-project-lms

A starter project to bring together components of the Pinax Learning Management System
CSS
7
star
48

pinax-cli

a tool for easily instantiating Pinax starter projects (django templates)
Python
7
star
49

django-site-access

an app to provide utilities via middleware to control access to your django site
Python
7
star
50

cloudspotting

a starter project allowing you to create collections of cloud images, view other people’s collections, β€œlike” a collection, etc.
CSS
7
star
51

pinax-calendars-demo

a demo project for pinax-calendars
Python
7
star
52

pinax-lms-activities

framework and base learning activities for Pinax LMS
Python
7
star
53

atom-format

Python
6
star
54

PinaxCon

PinaxCon is a project that demonstrates how Symposion can be hooked up for a conference site
HTML
6
star
55

pinax-events

a simple app for publishing events on your site
Python
5
star
56

pinax-news

a simple app for publishing links to news articles on your site
Python
5
star
57

pinax-utils

an app for Pinax utilities
Python
5
star
58

blog.pinaxproject.com

Python
5
star
59

pinax-types

Python
4
star
60

cloudspotting2

Pinax demo application showing many Pinax apps
CSS
4
star
61

pinax-project-static

3
star
62

pinax-cart

Python
3
star
63

pinax-identity

OpenID Connect with pinax-api helpers
Python
3
star
64

pinax-theme-classic

the original Pinax theme
HTML
3
star
65

pinax_theme_tester

a project based on the zero starter project used to test and build the pinax theme
Python
3
star
66

screencasts

2
star
67

pinax-project-wiki

a demo starter project for a single wiki site, featuring integration of pinax-wiki
2
star
68

lms-activities-demo

a Django site for demoing Pinax LMS Activities
Python
1
star
69

dashboard.pinaxproject.com

a collection of metrics and information about how the Pinax Project is going
Python
1
star
70

.github

Pinax Default Community Health Files
1
star
71

mytweets

a demo of pinax-types periods
Python
1
star
72

pinax-theme-pinaxproject

a Pinax theme for pinaxproject.com website
HTML
1
star
73

patch-game

guess the Pinax patch
CSS
1
star