]> git.parisson.com Git - django-notes.git/commitdiff
Adding files for a pypi package.
authorColin Powell <colin@onecardinal.com>
Tue, 10 May 2011 15:29:21 +0000 (11:29 -0400)
committerColin Powell <colin@onecardinal.com>
Tue, 10 May 2011 15:29:21 +0000 (11:29 -0400)
MANIFEST.in [new file with mode: 0644]
notes/__init__.py
notes/templatetags/__init__.py [new file with mode: 0644]
notes/templatetags/note_tags.py [new file with mode: 0644]
setup.py [new file with mode: 0644]

diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644 (file)
index 0000000..5cd6f0c
--- /dev/null
@@ -0,0 +1,2 @@
+include README.rst
+recursive-include notes/templatetags * 
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3dc1f76bc69e3f559bee6253b24fc93acee9e1f9 100644 (file)
@@ -0,0 +1 @@
+__version__ = "0.1.0"
diff --git a/notes/templatetags/__init__.py b/notes/templatetags/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/notes/templatetags/note_tags.py b/notes/templatetags/note_tags.py
new file mode 100644 (file)
index 0000000..96eab23
--- /dev/null
@@ -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 (file)
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',
+    ]
+)