Mercurial > public > sg101
comparison comments/views.py @ 693:ad69236e8501
For issue #52, update many 3rd party Javascript libraries.
Updated to jquery 1.10.2, jquery ui 1.10.3.
This broke a lot of stuff.
- Found a newer version of the jquery cycle all plugin (3.0.3).
- Updated JPlayer to 2.4.0.
- Updated to MarkItUp 1.1.14. This also required me to add multiline attributes
set to true on various buttons in the markdown set.
- As per a stackoverflow post, added some code to get multiline titles in
a jQuery UI dialog. They removed that functionality but allow you to put it
back.
Tweaked the MarkItUp preview CSS to show blockquotes in italic.
Did not update TinyMCE at this time. I'm not using the JQuery version and this
version appears to work ok for now.
What I should do is make a repo for MarkItUp and do a vendor branch thing so
I don't have to futz around diffing directories to figure out if I'll lose
changes when I update.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 04 Sep 2013 19:55:20 -0500 |
parents | ee87ea74d46b |
children | 4619290d171d |
comparison
equal
deleted
inserted
replaced
692:4a49d4ac319f | 693:ad69236e8501 |
---|---|
1 """ | 1 """ |
2 Views for the comments application. | 2 Views for the comments application. |
3 | |
3 """ | 4 """ |
4 from django.contrib.auth.decorators import login_required | 5 from django.contrib.auth.decorators import login_required |
5 from django.core.exceptions import ObjectDoesNotExist | 6 from django.core.exceptions import ObjectDoesNotExist |
6 from django.http import HttpResponse | 7 from django.http import HttpResponse |
7 from django.http import HttpResponseRedirect | |
8 from django.http import HttpResponseBadRequest | 8 from django.http import HttpResponseBadRequest |
9 from django.http import HttpResponseForbidden | 9 from django.http import HttpResponseForbidden |
10 from django.db.models import get_model | 10 from django.db.models import get_model |
11 from django.shortcuts import render_to_response | 11 from django.shortcuts import render_to_response |
12 from django.template import RequestContext | 12 from django.template import RequestContext |
69 if not form.is_valid(): | 69 if not form.is_valid(): |
70 return HttpResponseBadRequest('Invalid comment; missing parameters?') | 70 return HttpResponseBadRequest('Invalid comment; missing parameters?') |
71 | 71 |
72 comment = form.get_comment_object(request.user, request.META.get("REMOTE_ADDR", None)) | 72 comment = form.get_comment_object(request.user, request.META.get("REMOTE_ADDR", None)) |
73 | 73 |
74 # Check for spam | 74 # Check for spam |
75 | 75 |
76 if antispam.utils.spam_check(request, comment.comment): | 76 if antispam.utils.spam_check(request, comment.comment): |
77 return HttpResponseForbidden(antispam.BUSTED_MESSAGE) | 77 return HttpResponseForbidden(antispam.BUSTED_MESSAGE) |
78 | 78 |
79 comment.save() | 79 comment.save() |
81 # return the rendered comment | 81 # return the rendered comment |
82 return render_to_response('comments/comment.html', { | 82 return render_to_response('comments/comment.html', { |
83 'comment': comment, | 83 'comment': comment, |
84 }, | 84 }, |
85 context_instance = RequestContext(request)) | 85 context_instance = RequestContext(request)) |
86 | 86 |
87 | 87 |
88 @require_POST | 88 @require_POST |
89 def flag_comment(request): | 89 def flag_comment(request): |
90 """ | 90 """ |
91 This function handles the flagging of comments by users. This function should | 91 This function handles the flagging of comments by users. This function should |
116 @require_POST | 116 @require_POST |
117 def markdown_preview(request): | 117 def markdown_preview(request): |
118 """ | 118 """ |
119 This function should be the target of an AJAX POST. It takes the 'data' parameter | 119 This function should be the target of an AJAX POST. It takes the 'data' parameter |
120 from the POST parameters and returns a rendered HTML page from the data, which | 120 from the POST parameters and returns a rendered HTML page from the data, which |
121 is assumed to be in markdown format. The HTML page is suitable for the preview | 121 is assumed to be in markdown format. The HTML page is suitable for the preview |
122 function for a javascript editor such as markItUp. | 122 function for a javascript editor such as markItUp. |
123 """ | 123 """ |
124 if not request.user.is_authenticated(): | 124 if not request.user.is_authenticated(): |
125 return HttpResponseForbidden('This service is only available to logged in users.') | 125 return HttpResponseForbidden('This service is only available to logged in users.') |
126 | 126 |