Changeset 7895
- Timestamp:
- 08/29/08 10:51:02 (3 months ago)
- Files:
-
- project/gallery.openlayers.org/openlayers/faq/models.py (modified) (3 diffs)
- project/gallery.openlayers.org/openlayers/faq/templates/question.html (modified) (2 diffs)
- project/gallery.openlayers.org/openlayers/faq/urls.py (modified) (1 diff)
- project/gallery.openlayers.org/openlayers/faq/views.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
project/gallery.openlayers.org/openlayers/faq/models.py
r7891 r7895 2 2 from django.template.defaultfilters import slugify 3 3 from openlayers.faq.render import render_text 4 from djangoratings import RatingField 4 5 5 6 # Create your models here. … … 29 30 modified = models.DateTimeField(auto_now=True) 30 31 32 RATING_CHOICES = ( 33 (1, 'Up'), 34 (0, 'Down'), 35 ) 36 31 37 class Question(models.Model): 32 38 class Admin: pass … … 55 61 created = models.DateTimeField(auto_now_add=True) 56 62 modified = models.DateTimeField(auto_now=True) 63 rating = RatingField(choices=RATING_CHOICES, allow_anonymous=True, can_change_vote=True) 57 64 58 65 class QLink(models.Model): project/gallery.openlayers.org/openlayers/faq/templates/question.html
r7891 r7895 7 7 {{ question.rendered_answer|safe }} 8 8 9 <form action="/vote/question/" method="POST" target="form_out"> 10 <input type="hidden" name="question" value="{{question.id}}" /> 11 <input type="hidden" name="score" value="0" /> 12 </form> 13 <iframe name="form_out" style="display:none"></iframe> 14 <p> 15 {{ question.rating.score }} out of {{ question.rating.votes }} people found the above answer helpful. 16 Did you find it helpful? 17 <a href="#" onclick='document.forms[0].score.value=1; document.forms[0].submit();return false'>Yes</a> or 18 <a href="#" onclick='document.forms[0].score.value=0;document.forms[0].submit();return false;'>No</a> 19 </p> 9 20 <hr /> 10 21 {% for link in question.qlink_set.all %} … … 12 23 {{ link.description }} 13 24 </p> 14 {% endfor %} 25 {% endfor %} 15 26 <a href="#" onclick="document.forms[0].style.display='block'; this.style.display='none'">Add a link</a> 16 27 <form action="/add/qlink/" method="POST" style="display:none"> project/gallery.openlayers.org/openlayers/faq/urls.py
r7891 r7895 5 5 (r'^$', 'list'), 6 6 (r'^(?P<all>all)/$', 'list'), 7 (r'^vote/question/', 'question_vote'), 7 8 (r'^add/qlink/', 'qlink_upload'), 8 9 (r'^add/(?P<type>category|question)/$', 'add_item'), project/gallery.openlayers.org/openlayers/faq/views.py
r7891 r7895 3 3 import openlayers.faq.models 4 4 5 from django.http import HttpResponse Redirect5 from django.http import HttpResponse, HttpResponseRedirect 6 6 from django.shortcuts import render_to_response, get_object_or_404 7 7 … … 69 69 else: 70 70 return render_to_response("form.html", {'form': form}) 71 71 72 def question_vote(request): 73 q = get_object_or_404(Question, pk=request.POST['question']) 74 q.rating.add(score=int(request.POST['score']), user=request.user, ip_address=request.META['REMOTE_ADDR']) 75 return HttpResponse(q.rating.score) 72 76 73 77 def question(request, cat, q):
