Mercurial > public > sg101
comparison gpp/forums/views/main.py @ 469:3b30286adba5
Smarter search index updating for forums. This work is for #227.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 17 Aug 2011 01:02:08 +0000 |
parents | 2ff5f4c1476d |
children | 82b97697312e |
comparison
equal
deleted
inserted
replaced
468:ad4b63fbc584 | 469:3b30286adba5 |
---|---|
34 from forums.unread import (get_forum_unread_status, get_topic_unread_status, | 34 from forums.unread import (get_forum_unread_status, get_topic_unread_status, |
35 get_post_unread_status, get_unread_topics) | 35 get_post_unread_status, get_unread_topics) |
36 | 36 |
37 from forums.attachments import AttachmentProcessor | 37 from forums.attachments import AttachmentProcessor |
38 import forums.permissions as perms | 38 import forums.permissions as perms |
39 from forums.signals import (notify_new_topic, notify_updated_topic, | |
40 notify_new_post, notify_updated_post) | |
39 | 41 |
40 ####################################################################### | 42 ####################################################################### |
41 | 43 |
42 TOPICS_PER_PAGE = 50 | 44 TOPICS_PER_PAGE = 50 |
43 POSTS_PER_PAGE = 20 | 45 POSTS_PER_PAGE = 20 |
438 if antispam.utils.spam_check(request, form.cleaned_data['body']): | 440 if antispam.utils.spam_check(request, form.cleaned_data['body']): |
439 return HttpResponseRedirect(reverse('antispam-suspended')) | 441 return HttpResponseRedirect(reverse('antispam-suspended')) |
440 post = form.save(commit=False) | 442 post = form.save(commit=False) |
441 post.touch() | 443 post.touch() |
442 post.save() | 444 post.save() |
445 notify_updated_post(post) | |
443 | 446 |
444 # if we are editing a first post, save the parent topic as well | 447 # if we are editing a first post, save the parent topic as well |
445 if topic_name: | 448 if topic_name: |
446 post.topic.save() | 449 post.topic.save() |
450 notify_updated_topic(post.topic) | |
447 | 451 |
448 # Save any attachments | 452 # Save any attachments |
449 form.attach_proc.save_attachments(post) | 453 form.attach_proc.save_attachments(post) |
450 | 454 |
451 return HttpResponseRedirect(post.get_absolute_url()) | 455 return HttpResponseRedirect(post.get_absolute_url()) |
588 post = form.save(commit=False) | 592 post = form.save(commit=False) |
589 post.topic = topic | 593 post.topic = topic |
590 post.user = request.user | 594 post.user = request.user |
591 post.user_ip = request.META.get("REMOTE_ADDR", "") | 595 post.user_ip = request.META.get("REMOTE_ADDR", "") |
592 post.save() | 596 post.save() |
597 notify_new_post(post) | |
593 | 598 |
594 # Save any attachments | 599 # Save any attachments |
595 form.attach_proc.save_attachments(post) | 600 form.attach_proc.save_attachments(post) |
596 | 601 |
597 _bump_post_count(request.user) | 602 _bump_post_count(request.user) |
1100 """ | 1105 """ |
1101 posts = Post.objects.filter(topic=topic, id__in=post_ids) | 1106 posts = Post.objects.filter(topic=topic, id__in=post_ids) |
1102 if len(posts) > 0: | 1107 if len(posts) > 0: |
1103 new_topic = Topic(forum=new_forum, name=new_name, user=posts[0].user) | 1108 new_topic = Topic(forum=new_forum, name=new_name, user=posts[0].user) |
1104 new_topic.save() | 1109 new_topic.save() |
1110 notify_new_topic(new_topic) | |
1105 for post in posts: | 1111 for post in posts: |
1106 post.topic = new_topic | 1112 post.topic = new_topic |
1107 post.save() | 1113 post.save() |
1108 | 1114 |
1109 topic.post_count_update() | 1115 topic.post_count_update() |