Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Flag is a flexible flagging system for Django
Python
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
flag
.gitignore
README.md
setup.py

README.md

Flag for Django

Flag is a flexible flagging system

Using this app, one can provide flags to any object, just on the basis of template tags. No configuration of existing models and views required.

Some possibilities include bookmarks, marking important, friends, or flag as offensive. Flags may be per-user, meaning that each user can mark an item individually, or global, meaning that the item is either marked or it is not marked, and any user who changes that, changes it for everyone.

Installation

Usage

Create a flag type from admin site, for example "bookmark"

Available settings

DEFAULT_FLAG_TYPE_ID: The ID of default flag type to be used in the project

Available tags

Save a flag object to variable

{% flag [type] user=user obj=obj as flag %}

Renders a a flag for the provided arguments. Override template: 'flag/flag.html' for modifying the look.

{% render_flag [type] user=user obj=obj %}

Flag URL tgat that returns the endpoint url for a flag

<a href="{% flag_url [type] [obj]  %}">I want this game for christmas</a>

Tag to reveive flags based on given variables. [object] and [user] variables are optional

{% get_flag flags for flag_type of [object] user [user] as variable %}

Available endpoints

You can also create your own form or link and point it to: "/flag/[action]/[ftype_slug]/?content_type=[content_type]&object_pk=[object_pk]"

example:

http://127.0.0.1:8000/flag/flag/wishlist/?content_type=38&object_pk=1

Or to unflag:

http://127.0.0.1:8000/flag/unflag/wishlist/?content_type=38&object_pk=1

The endpoint supports AJAX request and will return a succes variable in JSON set to True or False. I also passes along the serialized Flag type object.

TODO

  • Base flag submit on django url function instead of object arguments?
  • Prevent link/object spoofing (maybe add a selection to flagtype for wich models it should be active?)

Author: Sjoerd Arendsen HUB online

Something went wrong with that request. Please try again.