comparison forums/views/main.py @ 789:9e803323a0d0

Removing AUTH_PROFILE_MODULE and get_profile().
author Brian Neal <bgneal@gmail.com>
date Fri, 23 May 2014 15:10:11 -0500
parents 91de9b15b410
children 0ca691cccf8d
comparison
equal deleted inserted replaced
788:84aa49497718 789:9e803323a0d0
360 if antispam.utils.spam_check(request, form.cleaned_data['body']): 360 if antispam.utils.spam_check(request, form.cleaned_data['body']):
361 return HttpResponseForbidden(antispam.BUSTED_MESSAGE) 361 return HttpResponseForbidden(antispam.BUSTED_MESSAGE)
362 362
363 post = form.save(request.user, request.META.get("REMOTE_ADDR", "")) 363 post = form.save(request.user, request.META.get("REMOTE_ADDR", ""))
364 post.unread = True 364 post.unread = True
365 post.user.user_profile = request.user.get_profile()
366 post.attach_list = post.attachments.all() 365 post.attach_list = post.attachments.all()
367 _bump_post_count(request.user) 366 _bump_post_count(request.user)
368 _update_last_visit(request.user, form.topic, datetime.datetime.now()) 367 _update_last_visit(request.user, form.topic, datetime.datetime.now())
369 368
370 return render_to_response('forums/display_post.html', { 369 return render_to_response('forums/display_post.html', {
467 466
468 return HttpResponseRedirect(post.get_absolute_url()) 467 return HttpResponseRedirect(post.get_absolute_url())
469 else: 468 else:
470 form = PostForm(instance=post, topic_name=topic_name) 469 form = PostForm(instance=post, topic_name=topic_name)
471 470
472 post.user.user_profile = post.user.get_profile() 471 post.user.user_profile = post.user.profile
473 472
474 return render_to_response('forums/edit_post.html', { 473 return render_to_response('forums/edit_post.html', {
475 'forum': post.topic.forum, 474 'forum': post.topic.forum,
476 'topic': post.topic, 475 'topic': post.topic,
477 'post': post, 476 'post': post,
521 Internal function to delete a single post object. 520 Internal function to delete a single post object.
522 Decrements the post author's post count. 521 Decrements the post author's post count.
523 Adjusts the parent topic and forum's last_post as needed. 522 Adjusts the parent topic and forum's last_post as needed.
524 """ 523 """
525 # Adjust post creator's post count 524 # Adjust post creator's post count
526 profile = post.user.get_profile() 525 profile = post.user.profile
527 if profile.forum_post_count > 0: 526 if profile.forum_post_count > 0:
528 profile.forum_post_count -= 1 527 profile.forum_post_count -= 1
529 profile.save(content_update=False) 528 profile.save(content_update=False)
530 529
531 # If this post is the last_post in a topic, we need to update 530 # If this post is the last_post in a topic, we need to update
994 993
995 def _bump_post_count(user): 994 def _bump_post_count(user):
996 """ 995 """
997 Increments the forum_post_count for the given user. 996 Increments the forum_post_count for the given user.
998 """ 997 """
999 profile = user.get_profile() 998 profile = user.profile
1000 profile.forum_post_count += 1 999 profile.forum_post_count += 1
1001 profile.save(content_update=False) 1000 profile.save(content_update=False)
1002 1001
1003 1002
1004 def _move_topic(topic, old_forum, new_forum): 1003 def _move_topic(topic, old_forum, new_forum):