Code Monkey home page Code Monkey logo

pinax-comments's Introduction

Pinax Comments

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-comments

Overview

pinax-comments is a comments app for Django.

Supported Django and Python Versions

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

Documentation

Installation

To install pinax-comments:

    $ pip install pinax-comments

Add pinax.comments to your INSTALLED_APPS setting:

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

Add pinax.comments.urls to your project urlpatterns:

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

Usage

Common usage involves wiring up template tags as seen in this example, which presents a form for adding a new comment on wall_user, as well as showing existing comments.

Three template tags are used here: comment_target, which returns a URL for posting a comment on wall_user; comment_form, which returns a comment form for wall_user; and comments, which returns all comments on wall_user.

    <div class="list-group">
        <div class="list-group-item">
            {% comment_target wall_user as post_url %}
            {% comment_form wall_user as comment_form %}
            <form class="form" method="post" action="{{ post_url }}">
                {% csrf_token %}
                {{ comment_form|bootstrap }}
                <button class="btn btn-primary">Post Message</button>
            </form>
        </div>
        
        {% comments wall_user as wall_comments %}
        {% for comment in wall_comments %}
        <div class="list-group-item">
            {{ comment.comment|linebreaks }}
            <div class="meta">
                <small class="text-muted pull-right">{{ comment.submit_date }}</small>
                <small class="text-muted">
                    <a href="{% url "wall" comment.author.username %}">
                        {{ comment.author }}
                    </a>
                </small>
            </div>
        </div>
        {% endfor %}
    </div>

Template Tags

can_delete_comment

Returns True if user can delete comment.

    {% if comment|can_delete_comment:user %}

can_edit_comment

Returns True if user can edit comment.

    {% if comment|can_edit_comment:user %}

comment_count

Returns number of comments on obj.

Usage:

    {% comment_count obj %}

or

    {% comment_count obj as var %}

comment_form

Returns a comment form for obj. Checks context user to determine if the comment should be from an authenticated or anonymous user.

Usage:

    {% comment_form obj as comment_form %}

comment_target

Returns the URL for posting a comment on obj

    {% comment_target obj %}

or

    {% comment_target obj as var %}

comments

Returns iterable of comments on obj as context variable var.

    {% comments obj as var %}

Signals

Both signals provide two keyword arguments: comment, the relevant Comment instance, and request.

commented

Sent when a comment is added.

comment_updated

Sent when a comment is updated.

Hookset Methods

load_can_delete(self, user, comment)

Override this method to specify if user can delete comment. By default only comment authors can edit comments.

load_can_edit(self, user, comment)

Override this method to specify if user can edit comment. By default, Django superusers and comment authors can delete comments.

This example hooks.py overrides default load_can_edit() with a silly alternative:

# myapp.hooks.py

from pinax.comments.hooks import CommentsDefaultHookSet

class CommentsHookSet(CommentsDefaultHookSet):

    def load_can_edit(self, user, comment):
        return user.username in ["funk", "wagnalls"]

Settings

PINAX_COMMENTS_HOOKSET

Used to provide your own custom hookset methods, as described above. Value is a dotted path to your own hookset class:

PINAX_COMMENTS_HOOKSET = "myapp.hooks.CommentsHookSet"

Change Log

2.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

1.0.3

  • Remove django-user-accounts from test requirements

1.0.2

  • Replace deprecated render_to_string() context_instance kwarg
  • Add view tests
  • Add templatetag tests

1.0.1

  • add django>=1.11 requirement
  • update testing requirements
  • improve documentation markup
  • remove "static" and "templates" dirs from MANIFEST.in

1.0.0

  • Add Django 2.0 compatibility testing
  • Drop Django 1.9, 1.9, 1.10 and Python 3.3 support
  • Move documentation into README, standardize documentation layout
  • Convert CI and coverage to CircleCi and CodeCov
  • Add PyPi-compatible long description
  • Add documentation for templatetags and signals
  • Add usage example

0.1

  • initial release

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.

pinax-comments's People

Contributors

alex avatar arthur-wsw avatar brosner avatar grahamu avatar jtauber avatar katherinemichel avatar khchine5 avatar lukeman avatar paltman avatar rizumu 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pinax-comments's Issues

Needs usage documentation

Explain usage.
Template tags need documentation.
Hookset needs documentation.
Signals need documentation.

Update against latest pinax-starter-app standards

Take a look at pinax-starter-app and update this repo with the updates there.

Since this is a template project you can't easily do a computed diff but will have to manually compare. For instance there isn't a makemigrations.py script, so you need to add one by copying in the one from the starter app and updating it to work with pinax-comments.

Others might be more of a diff, like just copying tox.ini and .travis.yml files in and over the existing ones and modifying as needed for pinax-comments.

Call for Maintainers

Looking for maintainers!

There is a lot of pull requests and open issues that the current maintainers, myself included, are just not finding the time to properly get to.

Maybe you've submitted some PRs and are frustrated with the lack of attention. Maybe you use this project in one or more of your projects and want to see that it is properly carried forward.

Whatever you reasons may be, let me know if you have interest and I'll add you to the repo and to PyPI (will need your PyPI name).

Preference will go to those who have commits on this repo and/or have shown an active interest in the issues.

Thanks!
Patrick

How to deal with model clashes in wagtail?

How can I deal with clashes like below?

pinax_comments.Comment.author: (fields.E304) Reverse accessor for 'pinax_comments.Comment.author' clashes with reverse accessor for 'wagtailcore.Comment.user'.
HINT: Add or change a related_name argument to the definition for 'pinax_comments.Comment.author' or 'wagtailcore.Comment.user'.

pinax_comments.Comment.author: (fields.E305) Reverse query name for 'pinax_comments.Comment.author' clashes with reverse query name for 'wagtailcore.Comment.user'.
HINT: Add or change a related_name argument to the definition for 'pinax_comments.Comment.author' or 'wagtailcore.Comment.user'.

wagtailcore.Comment.user: (fields.E304) Reverse accessor for 'wagtailcore.Comment.user' clashes with reverse accessor for 'pinax_comments.Comment.author'.
HINT: Add or change a related_name argument to the definition for 'wagtailcore.Comment.user' or 'pinax_comments.Comment.author'.

wagtailcore.Comment.user: (fields.E305) Reverse query name for 'wagtailcore.Comment.user' clashes with reverse query name for 'pinax_comments.Comment.author'.
HINT: Add or change a related_name argument to the definition for 'wagtailcore.Comment.user' or 'pinax_comments.Comment.author'.

Are you planning to support wagtail > 2.13.0 ?

AttributeError: 'str' object has no attribute '_meta'

I'm already following the tutorial instruction, but when I run via npm run dev, I have this error:

File "/home/mavis/.virtualenvs/pinax_project/lib/python3.6/site-packages/django/contrib/contenttypes/models.py", line 27, in _get_opts
model = model._meta.concrete_model
AttributeError: 'str' object has no attribute '_meta'

Does anyone know?

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.