zzm88 / django-voting Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/django-voting
License: Other
Automatically exported from code.google.com/p/django-voting
License: Other
What steps will reproduce the problem?
1. Define a url pointing to vote_on_object
2. Use kwargs={'queryset': SomeModel.objects.all()}
3. Try to vote
What is the expected output? What do you see instead?
The view should vote and redirect to the sucess page but it gives the
exception:
TypeError: vote_on_object() got an unexpected keyword argument
'queryset'
What version of the product are you using? On what operating system?
Trunk (r73) on Ubuntu Jaunty (9.04)
Please provide any additional information below.
Django's generic-views uses a queryset to lookup for objects, it's more
flexible than using the default manager of a model.
I'm providing a patch to match this behaviour.
Original issue reported on code.google.com by rico.bl
on 27 Aug 2009 at 8:50
Attachments:
line 33 in voting.managers seems to be redundant.
http://code.google.com/p/django-voting/source/browse/trunk/voting/managers.py
Original issue reported on code.google.com by [email protected]
on 14 Jul 2009 at 3:18
Since get_top returns a list of object, score tuples, it cannot be used
with generic views as generic views require querysets. Is there a way that
there can be a get_top_qs method created which returns the top objects as a
queryset? The other benefit is that then ObjectPaginator would work on
these, as well as all of the other things that one gets by having a queryset.
Original issue reported on code.google.com by [email protected]
on 29 May 2007 at 4:23
hi jonathan!
thank you for adding the example so quickly.
i think the js has a typo:
"Event.observer is not a Function"
bye,
jeff
Original issue reported on code.google.com by [email protected]
on 16 Mar 2007 at 2:56
in managers.py line 34 (get_scores_in_bulk function) ctype is assigned twice:
ctype = ContentType.objects.get_for_model(objects[0])
ctype = ContentType.objects.get_for_model(objects[0])
Original issue reported on code.google.com by [email protected]
on 11 Nov 2008 at 10:56
Would you be kind enough to create an NewForms-Admin branch with the following
patch applied,
or something similar to your liking? We're trying to move projects over to
NewForms-Admin for
testing.
Original issue reported on code.google.com by [email protected]
on 24 Jun 2008 at 1:51
Attachments:
I've found it quite useful to not only provide score and num_votes, but
also the numbers of up and down votes which are easily calculated from the
former two; see attached patch.
Original issue reported on code.google.com by [email protected]
on 3 Mar 2010 at 7:08
Attachments:
The attached patch contains some fixes that make django-voting work with Django
1.4 again.
Original issue reported on code.google.com by [email protected]
on 22 Jun 2012 at 12:34
Attachments:
Because of deprecation limit_offset_sql in django svn
Original issue reported on code.google.com by [email protected]
on 25 Aug 2008 at 6:23
With recent django SVN, get_scores_in_bulk explodes when it calls
queryset.query.group_by.append(). group_by is apparently now None by default.
I tried briefly to repair that by setting group_by to [] if it was None,
but that didn't work, and rather than attempting to continue to debug this
particular code path, I decided to use django's new aggregate functions
instead where they were available.
The attached patch seems to work -- at least it doesn't explode -- but I
haven't run much data through it. Note that it should continue to work as
before in Django 1.0.X.
(Also, this fixes the largely cosmetic problem in issue 18.)
Original issue reported on code.google.com by [email protected]
on 31 Mar 2009 at 5:46
Attachments:
Hi,
the unicode branch merged in trunk for django causes problems in voting:
The usage of get(**lookup_kwargs) (in views.py) does not work correctly
lookup_kwargs['%s__exact' % slug_field] = slug
causes the problem here ... because of the unicode strings in django it
will translate in something like:
{u'slug__exact': u'eatthis'} which definitely won't work with ** in the
get() function because unicode strings are not allowed as key names. What
we need here should look like this:
{'slug__exact': u'eatthis'}
So ..... the quick fix would be:
lookup_kwargs['%s__exact' % str(slug_field)] = slug
but it does not look very nice ....
The long term alternative would be to wait for Python 3000 ... but this
might take a bit longer ;-)
Cheers
Alex
Original issue reported on code.google.com by [email protected]
on 10 Jul 2007 at 1:38
The middleware of Django-logging will append log history html markup to any
response of content-type text/html. Currently, no mimetype is specified in
the HttpResponse() obj returned by xmlhttprequest_vote_on_object() or by
json_error_response(). This causes the djangologging middleware to append
html junk to the json responses of these methods, breaking many json parsers.
The very simple (two line) solution is to add the
mimetype="application/json" argument to the HttpResponse() constructor
called at the end of these two methods (lines 102 and 152 of views.py in
trunc). Doing so will cause the djangologging middleware to ignore the
json responses of these methods (leaving clean json). This is also more
correct behavior and in compliance with standards.
What steps will reproduce the problem?
1. Using Pinax's default installation "complete project" (to use an example
of an implementation where xmlhttprequest_vote_on_object is used when
djangologging is also turned on) upvote a "bookmark" object.
2. Observe that the number of points/votes does not change. This is in
spite of the request hitting the server and having the view execute without
error.
3. A reload of the page demonstrates that the upvote was recorded to the
database. Calling the RESTful ajax URL directly from firebug demonstrates
that the URL returns data that contains extensive HTML and is not parsable
by the javascript code in use by Pinax.
Original issue reported on code.google.com by [email protected]
on 25 Feb 2009 at 9:22
Enhancement Request.
1. The ability to track a vote with a timestamp for computing the score at
any given time.
Please provide any additional information below.
I'm going to start some work on this but help is greatly appreciated.
Hopefully this can be committed so that others can use it.
Original issue reported on code.google.com by [email protected]
on 16 Jan 2009 at 9:24
overview.txt says:
<blockquote>
Votes are recorded using the ``record_vote`` helper function::
>>> from django.contrib.auth.models import User
>>> from shop.apps.products.models import Widget
>>> from voting.models import Vote
>>> user = User.objects.get(pk=1)
>>> widget = Widget.objects.get(pk=1)
>>> Vote.objects.record_vote(user, widget, +1)
</blockquote>
last line should be:
>>> Vote.objects.record_vote(widget, user, +1)
Original issue reported on code.google.com by [email protected]
on 27 Aug 2007 at 1:25
This manager was realized by me. I think it is more flexible alternative
for get_top.
Original issue reported on code.google.com by [email protected]
on 7 Feb 2008 at 12:41
Attachments:
A few of us at PyCon are working on a Django community site, and one thing
that we'd like to do is dilate the votes based on the age of the vote.
This would only be possible if there were some sort of a date_submitted
field on the Vote object.
Would that be possible to add?
Original issue reported on code.google.com by [email protected]
on 16 Mar 2008 at 5:53
hi jonathan!
the query in get_top is missing a whitespace:
sql
'\nSELECT object_id, SUM(vote)\nFROM "votes"\nWHERE content_type_id =
%s\nGROUP BY object_idHAVING
it would be very nice if you add a get_top_for_objects function. so that it
would be possible to show "fresh" and "hot" tags.
bye
Original issue reported on code.google.com by [email protected]
on 20 Mar 2007 at 10:16
The API for XMLHttpRequests to the voting app returns a JSON response with
a boolean "success" property and a description of the error.
A superior approach might be to embrace http status codes and use different
http responses to represent different error types.
For example (I'm referencing Django's HttpRequest subclasses below):
HttpResponseForbidden() could be used in place of json_error_response('Not
authenticated.') when a user is not authenticated.
HttpResponseNotAllowed() could be used in place of
json_error_response('XMLHttpRequest votes can only be made using POST.')
HttpResponseNotFound() could be used when the object does not exists.
etc.
The advantage of this approach is that it obviates the need for a "success"
property (you can just pass single text string or a JSON object if more
structure is required). It's also very easy to handle these responses in
frameworks like jQuery, which as an example, fires an error() callback when
a status code like 403 or 404 is received but a success() call back on 200.
If you're interested I could submit a patch.
(LOVE django-voting btw, implementing it for an application i'm developing
right now.)
Original issue reported on code.google.com by [email protected]
on 10 Feb 2009 at 10:01
Attached.
Original issue reported on code.google.com by [email protected]
on 28 Sep 2010 at 1:31
Attachments:
Hi. I have downloaded your django app, I like it very much.
I would like to see it translated in more languages, if it is possible.
If you want, I can help you by adding the i18n infrastructure to the code and
the first translations (english and italian).
Please contact me via email [email protected] if you want me to patch the
app.
Original issue reported on code.google.com by facconi
on 29 Jul 2010 at 10:31
Right now, there is no simple way of passing extra options to get_top, in
order to get the top voted items from a selection.
Example case:
I have an Article model, which has a featured boolean field, and it's
manager has get_featured() and get_not_featured() methods.
I want to be able to show the top voted items for both the featured and not
featured items, separately.
Original issue reported on code.google.com by [email protected]
on 1 Feb 2008 at 9:57
views.xmlhttprequest_vote_on_object() returns HttpResponse with invalid MIME
type. The default 'text/html' is not changed there.
The following fix should do this:
return HttpResponse(simplejson.dumps({
'success': True,
'score': Vote.objects.get_score(obj),
}),
content_type='application/json'
)
Original issue reported on code.google.com by [email protected]
on 10 Jan 2011 at 2:25
Hi, I've just made a patch for using get_top function passing a custom manager
like this:
### models.py ###
from django.db import models
class MyManager(models.Manager):
def get_query_set(self):
return super(MyManager, self).get_query_set().filter(published=True)
class MyModel(models.Model):
published = models.BooleanField()
objects = models.Manager()
published_objects = MyManager()
### views.py ####
from voting.models import Vote
from models import *
def view_best(request):
my = Votes.objects.get_top(MyModel.published_objects)
return my
I hope this will be useful ;)
Original issue reported on code.google.com by [email protected]
on 30 Dec 2009 at 10:48
hi jonathan!
thank you for putting up the great examples.
would you please add an urls.py to the example?
greets,
jeff
Original issue reported on code.google.com by [email protected]
on 16 Mar 2007 at 11:43
Is there a way we can use django-voting with anonymous users?
Original issue reported on code.google.com by maggon
on 8 Nov 2009 at 3:05
What steps will reproduce the problem?
1. Vote up on something
2. Login to Django site admin and click to the Vote
3. Vote field is --- instead of 1
What is the expected output? What do you see instead?
The field is not prepopulated with the value.
What version of the product are you using? On what operating system?
Using r69 pulled with Pinax svn. Django svn r9460.
Please provide any additional information below.
Original issue reported on code.google.com by stryderjzw
on 19 Dec 2008 at 7:03
What steps will reproduce the problem?
>>> from voting.models import Vote
>>> Vote.objects.get_scores_in_bulk([])
What is the expected output? What do you see instead?
Expected:
{}
Actual:
IndexError: list index out of range
What version of the product are you using? On what operating system?
trunk
Please provide any additional information below.
On line 43 of managers.py, the code assumes that there's an object at index
0, which isn't necessarily true. I've attached a patch which rewrites the
get_scores_in_bulk method in the model of the get_for_user_in_bulk model.
Original issue reported on code.google.com by [email protected]
on 5 Nov 2007 at 9:44
Attachments:
I have an enhancement idea. What if you were to add the following field to
your model:
http://dpaste.com/35787/
this would allow for a rating system to be implemented suchas a five star
rating system. ex - 4.75/5.0, 8.0/10, etc...
Original issue reported on code.google.com by [email protected]
on 18 Feb 2008 at 7:28
[deleted issue]
Guess that's intended but if I use GET to vote with the vote_on_object
function, I see a success
page. GET requests should return a message that nothing happened.
Original issue reported on code.google.com by [email protected]
on 9 Aug 2009 at 11:29
According to
http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Genericrelations
havemoved
GenericForeignKey has been moved to into the django.contrib.contenttypes
module ...
Which means that this patch is need for the latest trunk version (May 2007):
===================================================================
--- voting/models.py (revision 41)
+++ voting/models.py (working copy)
@@ -1,4 +1,5 @@
from django.db import backend, connection, models
+from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import User
@@ -138,7 +139,7 @@
user = models.ForeignKey(User)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
- object = models.GenericForeignKey('content_type', 'object_id')
+ object = generic.GenericForeignKey('content_type', 'object_id')
vote = models.SmallIntegerField(choices=SCORES)
objects = VoteManager()
Beste regards
Alex
Original issue reported on code.google.com by [email protected]
on 16 May 2007 at 9:22
http://django-voting.googlecode.com/svn/trunk/docs/overview.txt
on the section "Generic Views":
<code>
widget_dict = {
'model': Widget,
'template_object_name': 'widget',
'allow_xmlhttprequest': true,
}
</code>
"true" should be replaced with "True".
Original issue reported on code.google.com by [email protected]
on 29 Sep 2008 at 1:06
What steps will reproduce the problem?
1. Click on any page that has {% scores_for_objects bookmarks as score_dict
%} or somethings similar with default social_project in pinax.
What is the expected output? What do you see instead?
Exppected that the page would load, instead traceback saying NoneType has
no append method.
There is a simple patch to managers.py here:
http://code.pinaxproject.com/tasks/task/253/
There might be something more granular or robust that you could do but that
patch fixes the problem for me so far.
Well, actually I'll we just upload it right here. Line 42, added
conditional to avoid traceback with nonetype object.
Original issue reported on code.google.com by [email protected]
on 26 May 2009 at 12:02
Attachments:
django.po file
Original issue reported on code.google.com by [email protected]
on 10 Aug 2008 at 8:10
Attachments:
I want to prevent people from voting on an object that they themselves
created.
Currently, the cleanest way is to listen for Vote's post_save signal and
delete the just-saved vote if it's illegal, but it's ugly to make two
round-trips to the DB when I'd prefer to make none at all. I fiddled with
listening to pre_save, but it provides no way to stop the save-in-progress.
It would be really nice if django-voting fired off a "vote_will_be_saved"
signal that allowed receivers to veto the saving of the vote. (The name
could be changed, I chose this to parallel newcomments'
comment_will_be_posted signal that does something similar.)
Attached patch accomplishes this.
Original issue reported on code.google.com by carl.j.meyer
on 21 Sep 2008 at 2:53
Attachments:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.