From d6228bf5b36bc77f55b10f024baf8f93e4409736 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Tue, 10 May 2011 11:29:21 -0400 Subject: [PATCH] Adding files for a pypi package. --- MANIFEST.in | 2 ++ notes/__init__.py | 1 + notes/templatetags/__init__.py | 0 notes/templatetags/note_tags.py | 25 +++++++++++++++++++++++++ setup.py | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 61 insertions(+) create mode 100644 MANIFEST.in create mode 100644 notes/templatetags/__init__.py create mode 100644 notes/templatetags/note_tags.py create mode 100644 setup.py diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..5cd6f0c --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include README.rst +recursive-include notes/templatetags * diff --git a/notes/__init__.py b/notes/__init__.py index e69de29..3dc1f76 100644 --- a/notes/__init__.py +++ b/notes/__init__.py @@ -0,0 +1 @@ +__version__ = "0.1.0" diff --git a/notes/templatetags/__init__.py b/notes/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/notes/templatetags/note_tags.py b/notes/templatetags/note_tags.py new file mode 100644 index 0000000..96eab23 --- /dev/null +++ b/notes/templatetags/note_tags.py @@ -0,0 +1,25 @@ +from django import template +from django.core.cache import cache +from django.contrib.contenttypes.models import ContentType +from notes.models import Note + +register = template.Library() + +def note_list_for(obj): + """Provides the tags with a "weight" attribute to build a tag cloud""" + + cache_key = 'note_list_for' + notes = cache.get(cache_key) + if notes is None: + # Get all the notes for the specified object + obj_type=ContentType.objects.get_for_model(obj) + notes=Note.objects.filter(content_type__pk=obj_type.id, object_id=obj.id) + + if len(notes) == 0: + # go no further + return {} + cache.set(cache_key, notes) + + return {'notes': notes} + +register.inclusion_tag('notes/_note_list.html')(note_list_for) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..a13a7c5 --- /dev/null +++ b/setup.py @@ -0,0 +1,33 @@ +from setuptools import setup, find_packages + +setup( + name='django-notes', + version=__import__('notes').__version__, + license="BSD", + + install_requires = [], + + description='A reusable applicaton to add arbitrary notes to a model.', + long_description=open('README.md').read(), + + author='Colin Powell', + author_email='colin@onecardinal.com', + + url='http://github.com/powellc/django-notes', + download_url='http://github.com/powellc/django-notes/downloads', + + include_package_data=True, + + packages=['notes'], + + zip_safe=True, + classifiers=[ + 'Development Status :: 4 - Beta', + 'Environment :: Web Environment', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: BSD License', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Framework :: Django', + ] +) -- 2.39.5