Mercurial > personas_backend
changeset 84:5029082ee13f
Added a popularity field to the Persona model; the popularity of a persona is now incremented whenever a Persona is set as a user's current persona.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Thu, 13 Mar 2008 18:01:45 -0500 |
parents | 9f1e14a8c86d |
children | c6dc5b79a07a |
files | PersonasBackend/personas/ajax.py PersonasBackend/personas/forms.py PersonasBackend/personas/models.py |
diffstat | 3 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/PersonasBackend/personas/ajax.py Thu Mar 13 17:48:31 2008 -0500 +++ b/PersonasBackend/personas/ajax.py Thu Mar 13 18:01:45 2008 -0500 @@ -1,5 +1,10 @@ from django.http import HttpResponse +from django.shortcuts import get_object_or_404 + +from PersonasBackend.personas import models def report_selection( request, persona_id ): - # TODO: Increment the popularity count of the persona. + persona = get_object_or_404( models.Persona, id=persona_id ) + persona.popularity += 1 + persona.save() return HttpResponse()
--- a/PersonasBackend/personas/forms.py Thu Mar 13 17:48:31 2008 -0500 +++ b/PersonasBackend/personas/forms.py Thu Mar 13 18:01:45 2008 -0500 @@ -9,7 +9,7 @@ class Meta: model = models.Persona - exclude = ["owner", "status"] + exclude = ["owner", "popularity", "status"] def clean( self ): try:
--- a/PersonasBackend/personas/models.py Thu Mar 13 17:48:31 2008 -0500 +++ b/PersonasBackend/personas/models.py Thu Mar 13 18:01:45 2008 -0500 @@ -322,6 +322,14 @@ editable=False, ) + popularity = models.PositiveIntegerField( + "Popularity", + help_text=("A number indicating how popular the Persona is; the " + "higher this value, the better."), + default=0, + null=False, + ) + MAX_STATUS_LENGTH = 10 status = models.CharField(