Mercurial > public > sg101
annotate forums/views/attachments.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 | 89b240fe9297 |
children | 7e0c3cbd3cda |
rev | line source |
---|---|
bgneal@285 | 1 """ |
bgneal@285 | 2 This module contains views for working with post attachments. |
bgneal@679 | 3 |
bgneal@285 | 4 """ |
bgneal@679 | 5 import json |
bgneal@679 | 6 |
bgneal@285 | 7 from django.http import HttpResponse |
bgneal@285 | 8 from django.http import HttpResponseForbidden |
bgneal@285 | 9 from django.http import HttpResponseBadRequest |
bgneal@285 | 10 from django.http import HttpResponseNotFound |
bgneal@285 | 11 |
bgneal@285 | 12 from forums.models import Post |
bgneal@285 | 13 |
bgneal@285 | 14 |
bgneal@285 | 15 def fetch_attachments(request): |
bgneal@285 | 16 """ |
bgneal@285 | 17 This view is the target of an AJAX GET request to retrieve the |
bgneal@285 | 18 attachment embed data for a given forum post. |
bgneal@285 | 19 |
bgneal@285 | 20 """ |
bgneal@285 | 21 if not request.user.is_authenticated(): |
bgneal@285 | 22 return HttpResponseForbidden('Please login or register.') |
bgneal@285 | 23 |
bgneal@285 | 24 post_id = request.GET.get('pid') |
bgneal@285 | 25 if post_id is None: |
bgneal@285 | 26 return HttpResponseBadRequest('Missing post ID.') |
bgneal@285 | 27 |
bgneal@285 | 28 try: |
bgneal@285 | 29 post = Post.objects.get(pk=post_id) |
bgneal@285 | 30 except Post.DoesNotExist: |
bgneal@285 | 31 return HttpResponseNotFound("That post doesn't exist.") |
bgneal@286 | 32 |
bgneal@285 | 33 embeds = post.attachments.all().select_related('embed') |
bgneal@285 | 34 data = [{'id': embed.id, 'html': embed.html} for embed in embeds] |
bgneal@285 | 35 |
bgneal@285 | 36 return HttpResponse(json.dumps(data), content_type='application/json') |
bgneal@285 | 37 |