# HG changeset patch # User Brian Neal # Date 1254271333 0 # Node ID d1b0b86441c07aad34194bd028792c078874dc7f # Parent e5faf9f0c11aff556f2aa743b531e4fa4a95e68a Forums: added a sync() function on the forum model. Created javascript for the moderate forum function to drive the master topic select checkbox. diff -r e5faf9f0c11a -r d1b0b86441c0 gpp/forums/forms.py --- a/gpp/forums/forms.py Mon Sep 28 03:57:09 2009 +0000 +++ b/gpp/forums/forms.py Wed Sep 30 00:42:13 2009 +0000 @@ -124,5 +124,4 @@ if hide_label: self.fields['forums'].label = '' self.fields['forums'].required = required - print '#############', required diff -r e5faf9f0c11a -r d1b0b86441c0 gpp/forums/models.py --- a/gpp/forums/models.py Mon Sep 28 03:57:09 2009 +0000 +++ b/gpp/forums/models.py Wed Sep 30 00:42:13 2009 +0000 @@ -108,6 +108,14 @@ else: self.last_post = None + def sync(self): + """ + Call to notify the forum that it needs to recompute its + denormalized fields. + """ + self.topic_count_update() + self.post_count_update() + def last_post_pre_delete(self): """ Call this function prior to deleting the last post in the forum. diff -r e5faf9f0c11a -r d1b0b86441c0 gpp/forums/views.py --- a/gpp/forums/views.py Mon Sep 28 03:57:09 2009 +0000 +++ b/gpp/forums/views.py Wed Sep 30 00:42:13 2009 +0000 @@ -558,11 +558,9 @@ topic.forum = new_forum topic.save() # Have to adjust foreign keys to last_post, denormalized counts, etc.: - old_forum.topic_count_update() - old_forum.post_count_update() + old_forum.sync() old_forum.save() - new_forum.topic_count_update() - new_forum.post_count_update() + new_forum.sync() new_forum.save() diff -r e5faf9f0c11a -r d1b0b86441c0 gpp/templates/forums/mod_forum.html --- a/gpp/templates/forums/mod_forum.html Mon Sep 28 03:57:09 2009 +0000 +++ b/gpp/templates/forums/mod_forum.html Wed Sep 30 00:42:13 2009 +0000 @@ -1,6 +1,9 @@ {% extends 'base.html' %} {% load forum_tags %} {% block title %}Moderate Forum: {{ forum.name }}{% endblock %} +{% block custom_js %} + +{% endblock %} {% block content %}

Moderate Forum: {{ forum.name }}

@@ -34,7 +37,7 @@ {% last_post_info topic.last_post MEDIA_URL %} - + {% empty %} diff -r e5faf9f0c11a -r d1b0b86441c0 media/js/forums_mod.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/media/js/forums_mod.js Wed Sep 30 00:42:13 2009 +0000 @@ -0,0 +1,15 @@ +$(document).ready(function() { + var master = $('#forums-master-topic'); + var topics = $('.forums-topic_check'); + master.click(function() { + var state = this.checked; + topics.each(function() { + this.checked = state; + }); + }); + topics.click(function() { + if (master[0].checked && !this.checked) { + master[0].checked = false; + } + }); +});