debian/0000755000000000000000000000000012177527072007200 5ustar debian/compat0000644000000000000000000000000211374046130010363 0ustar 7 debian/watch0000644000000000000000000000014511544156227010226 0ustar version=3 http://pypi.python.org/packages/source/d/django-voting/django-voting-([0-9a-z.]*)\.tar\.gz debian/copyright0000644000000000000000000000616212177522270011133 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: django-voting Upstream-Contact: Jonathan Buchanan Source: http://django-voting.googlecode.com/svn/trunk/ Files: * Copyright: 2007, Jonathan Buchanan 2007, Jacob Kaplan-Moss 2012, Jannis Leidel License: Expat and BSD-3-clause Comment: Jacob Kaplan-Moss's code is licensed under the BSD-3-clause license, while the rest is licensed under the Expat license. Files: debian/* Copyright: 2010-2013, Bernhard Reiter License: Expat License: Expat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: . The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. . THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. License: BSD-3-clause All rights reserved. . Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: . 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. . 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. . 3. Neither the name of FileBrowser nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. . THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. debian/docs0000644000000000000000000000003511374046130010036 0ustar README.txt docs/overview.txt debian/patches/0000755000000000000000000000000012177527072010627 5ustar debian/patches/series0000644000000000000000000000006111770742054012036 0ustar test_settings django14 num_up_down_votes_and_doc debian/patches/django140000644000000000000000000000270611770742054012163 0ustar # Description: Fix some incompatibilities with Django 1.4. # Author: Bernhard Reiter # Forwarded: http://code.google.com/p/django-voting/issues/detail?id=35 --- a/voting/tests/settings.py +++ b/voting/tests/settings.py @@ -2,8 +2,12 @@ DIRNAME = os.path.dirname(__file__) -DATABASE_ENGINE = 'sqlite3' -DATABASE_NAME = os.path.join(DIRNAME, 'database.db') +DATABASES = { + 'default' : { + 'ENGINE' : 'django.db.backends.sqlite3', + 'NAME' : os.path.join(DIRNAME, 'database.db'), + } +} #DATABASE_ENGINE = 'mysql' #DATABASE_NAME = 'tagging_test' --- a/voting/tests/runtests.py +++ b/voting/tests/runtests.py @@ -1,8 +1,9 @@ import os, sys os.environ['DJANGO_SETTINGS_MODULE'] = 'voting.tests.settings' -from django.test.simple import run_tests +from django.test.simple import DjangoTestSuiteRunner -failures = run_tests(None, verbosity=9) +runner = DjangoTestSuiteRunner(verbosity=9) +failures = runner.run_tests(None) if failures: sys.exit(failures) --- a/voting/managers.py +++ b/voting/managers.py @@ -138,7 +138,7 @@ # MySQL has issues with re-using the aggregate function in the # HAVING clause, so we alias the score and use this alias for # its benefit. - if settings.DATABASE_ENGINE == 'mysql': + if settings.DATABASES['default']['ENGINE'] == 'mysql': having_score = connection.ops.quote_name('score') else: having_score = 'SUM(vote)' debian/patches/num_up_down_votes_and_doc0000644000000000000000000001407112053450215015761 0ustar # Description: Add functions for the numbers of up and down votes; update docs # and tests # Author: Bernhard Reiter # Forwarded: http://code.google.com/p/django-voting/issues/detail?id=31 --- a/docs/overview.txt +++ b/docs/overview.txt @@ -76,13 +76,16 @@ ``0`` (remove vote). * ``get_score(obj)`` -- Gets the total score for ``obj`` and the - total number of votes it's received. + total number of votes it's received, as well as the numbers of + up and down votes. - Returns a dictionary with ``score`` and ``num_votes`` keys. + Returns a dictionary with ``score``, ``num_votes``, + ``num_up_votes``, and ``num_down_votes`` keys. * ``get_scores_in_bulk(objects)`` -- Gets score and vote count details for all the given objects. Score details consist of a - dictionary which has ``score`` and ``num_vote`` keys. + dictionary which has ``score``, ``num_votes``, ``num_up_votes``, + and ``num_down_votes`` keys. Returns a dictionary mapping object ids to score details. @@ -130,17 +133,17 @@ helper function:: >>> Vote.objects.get_score(widget) - {'score': 1, 'num_votes': 1} + {'score': 1, 'num_votes': 1, 'num_up_votes': 1, 'num_down_votes': 0} If the same user makes another vote on the same object, their vote is either modified or deleted, as appropriate:: >>> Vote.objects.record_vote(widget, user, -1) >>> Vote.objects.get_score(widget) - {'score': -1, 'num_votes': 1} + {'score': -1, 'num_votes': 1, 'num_up_votes': 0, 'num_down_votes': 1} >>> Vote.objects.record_vote(widget, user, 0) >>> Vote.objects.get_score(widget) - {'score': 0, 'num_votes': 0} + {'score': 0, 'num_votes': 0, 'num_up_votes': 0, 'num_down_votes': 0} Generic Views @@ -289,7 +292,9 @@ * ``score``: an object containing a ``score`` property, which holds the object's updated score, and a ``num_votes`` property, - which holds the total number of votes cast for the object. + which holds the total number of votes cast for the object, as well + as a ``num_up_votes`` and a ``num_down_votes`` property holding + the numbers of up and down votes cast for the object, respectively. * ``error_message``: if the vote was not successfully processed, this property will contain an error message. @@ -308,9 +313,10 @@ score_for_object ~~~~~~~~~~~~~~~~ -Retrieves the total score for an object and the number of votes -it's received, storing them in a context variable which has ``score`` -and ``num_votes`` properties. +Retrieves the total score for an object and the numbers of total, +up, and down votes it's received, storing them in a context variable +which has ``score``, ``num_votes``, ``num_up_votes``, and +``num_down_votes`` properties. Example usage:: @@ -322,9 +328,9 @@ scores_for_objects ~~~~~~~~~~~~~~~~~~ -Retrieves the total scores and number of votes cast for a list of -objects as a dictionary keyed with the objects' ids and stores it in a -context variable. +Retrieves the total scores and numbers of total, up and down votes cast +for a list of objects as a dictionary keyed with the objects' ids and +stores it in a context variable. Example usage:: --- a/voting/managers.py +++ b/voting/managers.py @@ -52,6 +52,8 @@ return { 'score': int(result[0]), 'num_votes': int(result[1]), + 'num_up_votes': (int(result[1])+int(result[0]))/2, + 'num_down_votes': (int(result[1])-int(result[0]))/2, } def get_scores_in_bulk(self, objects): @@ -92,6 +94,8 @@ vote_dict[row['object_id']] = { 'score': int(row['score']), 'num_votes': int(row['num_votes']), + 'num_up_votes': (int(row['num_votes'])+int(row['score']))/2, + 'num_down_votes': (int(row['num_votes'])-int(row['score']))/2, } return vote_dict --- a/voting/tests/tests.py +++ b/voting/tests/tests.py @@ -14,28 +14,28 @@ >>> for username in ['u1', 'u2', 'u3', 'u4']: ... users.append(User.objects.create_user(username, '%s@test.com' % username, 'test')) >>> Vote.objects.get_score(i1) -{'score': 0, 'num_votes': 0} +{'num_up_votes': 0, 'score': 0, 'num_down_votes': 0, 'num_votes': 0} >>> Vote.objects.record_vote(i1, users[0], +1) >>> Vote.objects.get_score(i1) -{'score': 1, 'num_votes': 1} +{'num_up_votes': 1, 'score': 1, 'num_down_votes': 0, 'num_votes': 1} >>> Vote.objects.record_vote(i1, users[0], -1) >>> Vote.objects.get_score(i1) -{'score': -1, 'num_votes': 1} +{'num_up_votes': 0, 'score': -1, 'num_down_votes': 1, 'num_votes': 1} >>> Vote.objects.record_vote(i1, users[0], 0) >>> Vote.objects.get_score(i1) -{'score': 0, 'num_votes': 0} +{'num_up_votes': 0, 'score': 0, 'num_down_votes': 0, 'num_votes': 0} >>> for user in users: ... Vote.objects.record_vote(i1, user, +1) >>> Vote.objects.get_score(i1) -{'score': 4, 'num_votes': 4} +{'num_up_votes': 4, 'score': 4, 'num_down_votes': 0, 'num_votes': 4} >>> for user in users[:2]: ... Vote.objects.record_vote(i1, user, 0) >>> Vote.objects.get_score(i1) -{'score': 2, 'num_votes': 2} +{'num_up_votes': 2, 'score': 2, 'num_down_votes': 0, 'num_votes': 2} >>> for user in users[:2]: ... Vote.objects.record_vote(i1, user, -1) >>> Vote.objects.get_score(i1) -{'score': 0, 'num_votes': 4} +{'num_up_votes': 2, 'score': 0, 'num_down_votes': 2, 'num_votes': 4} >>> Vote.objects.record_vote(i1, user, -2) Traceback (most recent call last): @@ -80,7 +80,7 @@ [(, -4), (, -3), (, -2)] >>> Vote.objects.get_scores_in_bulk([i1, i2, i3, i4]) -{1: {'score': 0, 'num_votes': 4}, 2: {'score': -2, 'num_votes': 4}, 3: {'score': -4, 'num_votes': 4}, 4: {'score': -3, 'num_votes': 3}} +{1: {'num_up_votes': 2, 'score': 0, 'num_down_votes': 2, 'num_votes': 4}, 2: {'num_up_votes': 1, 'score': -2, 'num_down_votes': 3, 'num_votes': 4}, 3: {'num_up_votes': 0, 'score': -4, 'num_down_votes': 4, 'num_votes': 4}, 4: {'num_up_votes': 0, 'score': -3, 'num_down_votes': 3, 'num_votes': 3}} >>> Vote.objects.get_scores_in_bulk([]) {} """ debian/patches/test_settings0000644000000000000000000000104612177502554013450 0ustar # Description: Add some apps and settings that are required for the tests. # Author: Bernhard Reiter # Forwarded: http://code.google.com/p/django-voting/issues/detail?id=33 --- a/voting/tests/settings.py +++ b/voting/tests/settings.py @@ -22,6 +22,13 @@ INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', + 'django.contrib.admin', + 'django.contrib.sessions', + 'django.contrib.sites', 'voting', 'voting.tests', ) + +ROOT_URLCONF = 'settings' +SITE_ID = 1 +SECRET_KEY = 'test' debian/changelog0000644000000000000000000000346412177526763011067 0ustar python-django-voting (0.2-1) unstable; urgency=low [ Bernhard Reiter ] * New upstream release * debian/control: - Bump Standards-Version to 3.9.4. - Bump debhelper Build-Depends to >= 8.1. - Add Suggests: python-django-south. * debian/copyright: - Add Jannis Leidel to copyright holders. - Improve structure. * debian/patches/django14: Whitespace fix. * debian/patches/test_settings: Add a SECRET_KEY setting. (Closes: #711371, LP: #1193942) * debian/NEWS.Debian: Add. [ Jakub Wilk ] * Use canonical URIs for Vcs-* fields. -- Bernhard Reiter Sun, 04 Aug 2013 21:38:01 +0200 python-django-voting (0.1-2) unstable; urgency=medium * debian/patches/django14, debian/patches/series: Fix for Django 1.4 compatibility (Closes: #669488) * debian/control: Bump Standards-Version to 3.9.2. * debian/copyright: Update to comply with copyright-format 1.0. -- Bernhard Reiter Fri, 22 Jun 2012 02:21:19 +0200 python-django-voting (0.1-1) unstable; urgency=low * First actual upstream release; no changes from svn revision 73. * debian/rules: Remove get-orig-source chunk that pulled source from svn. * debian/watch: Point to PyPi release. * debian/control: Bump Standards-Version to 3.9.2 (no changes needed) * Migrate from python-support to dh_python2. debian/control: - Remove python-support from Build-Depends. - Build-Depend on python-all (>= 2.6.6-3~) instead of (>= 2.3) - s/XS-Python-Version/X-Python-Version/ debian/rules: - Add '--with python2' after 'dh $@' -- Bernhard Reiter Mon, 24 Jul 2011 18:07:21 +0200 python-django-voting (0+svn73-1) unstable; urgency=low * Initial release (Closes: #581833, LP: #575481) -- Bernhard Reiter Tue, 21 Sep 2010 19:00:27 +0200 debian/NEWS.Debian0000644000000000000000000000041012177526302011046 0ustar python-django-voting (0.2-1) unstable; urgency=low To update the database from the layout generated by version 0.1 of this package, use the python-django-south migrations framework. -- Bernhard Reiter Sun, 04 Aug 2013 16:34:27 +0200 debian/rules0000755000000000000000000000040411613041303010234 0ustar #!/usr/bin/make -f %: dh $@ --with python2 override_dh_auto_test: ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),) set -e; \ cd voting/tests; \ for python in $(shell pyversions -r); do \ PYTHONPATH=${PYTHONPATH}:../.. $$python runtests.py; \ done endif debian/control0000644000000000000000000000265112177526167010613 0ustar Source: python-django-voting Section: python Priority: optional Maintainer: Debian Python Modules Team Uploaders: Bernhard Reiter Build-Depends: debhelper (>= 8.1), python-all (>= 2.6.6-3~), python-django (>= 1.0) Standards-Version: 3.9.4 X-Python-Version: >= 2.3 Homepage: http://code.google.com/p/django-voting Vcs-Svn: svn://anonscm.debian.org/python-modules/packages/python-django-voting/trunk/ Vcs-Browser: http://anonscm.debian.org/viewvc/python-modules/packages/python-django-voting/trunk/ Package: python-django-voting Architecture: all Depends: ${misc:Depends}, ${python:Depends}, python-django (>= 1.0) Suggests: python-django-south Description: generic voting application for Django This voting app for Django allows registering votes against any Model instance, retrieval of the score for an object, retrieval of top and bottom-rated objects for a particular Model. Also features the ability to clear votes, a template tag library, a generic view for wiring up voting for a Model (GET requests result in a confirmation page, POST requests submit votes), a generic view for voting using XMLHttpRequest (as a bonus, if the non-XMLHttpRequest generic view detects that a request was made via XMLHttpRequest, it will automatically use this view to process the request, which makes it trivial to progressively enhance your project with XMLHttpRequest-based voting). debian/source/0000755000000000000000000000000012177527072010500 5ustar debian/source/format0000644000000000000000000000001411374046130011673 0ustar 3.0 (quilt)