Coder Social home page Coder Social logo

django-flaggit's Introduction

django-flaggit

django-flaggit enables content flagging.

Installation

pip install django-flaggit

Usage:

  • Add flaggit to your INSTALLED_APPS

  • Include flaggit.urls into your URLs if you plan on using the view and template tag:

      urlpatterns = patterns('',
      	url('^', include('flaggit.urls')),
      )
    

Test

Follow above steps and run

python manage.py test flaggit

API

Models

  • flaggit.models.Flag
  • flaggit.models.FlagInstance

Utils

  • flaggit.utils.flag(obj, user=None, ip=None, comment=None):
    Flag an obj, returns a FlagInstance

Signals

  • flaggit.signals.flagged(flag):
    Sent when something is flagged. Can be used to notify moderators.

  • flaggit.signals.review(flag):
    Sent when something is in review.

  • flaggit.signals.rejected(flag):
    Sent when some content was rejected.

  • flaggit.signals.approved(flag):
    Sent when some content was approved.

Here's a template you can copy paste:

import flaggit

def handle_flagged(sender, flag, created = False, **kwargs):
	if created:
		# send emails
		pass
	else:
		pass

def handle_review(sender, flag, **kwargs):
	pass
	
def handle_rejected(sender, flag, **kwargs):
	flag.content_object.delete()
	flag.delete()

def handle_approved(sender, flag, **kwargs):
	pass

flaggit.signals.flagged.connect(handle_flagged)
flaggit.signals.review.connect(handle_review)
flaggit.signals.rejected.connect(handle_rejected)
flaggit.signals.approved.connect(handle_approved)

Template tags

{% load flaggit_tags %}
{% flag_form object %}
{% flag_form object "your/custom/template.html" %}
  • {% flag_form object %}:
    Renders a form to flag object-

  • `{% flag_form object "your/custom/template.html" %}:
    Renders the form with a custom template.


@flashingpumpkin

django-flaggit's People

Contributors

flashingpumpkin avatar

Watchers

James Cloos avatar  avatar

Forkers

slashking

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.