from datetime import datetime from misc.models import Drawboard from utilities.dajax.core import Dajax from utilities.dajaxice.core import dajaxice_functions from utilities.internal.templatetags.utils import user_date def drawboard_save(request, new_content): drawboard, created = Drawboard.objects.get_or_create(pk=1) drawboard.last_modified_by = request.user new_content = new_content.replace('~~~~', '%s, %s' % \ (request.user, user_date(datetime.now(), request.user, human_days=False))) drawboard.content = new_content drawboard.save() dajax = Dajax() dajax.assign_lesser('#drawboard', 'innerHTML', new_content) dajax.assign('#drawboard-div', 'innerHTML', drawboard.content_html) dajax.script("finish();") return dajax.json() dajaxice_functions.register(drawboard_save)
# CREATIONS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. #---------------------------------------------------------------------- from django.utils import simplejson from utilities.dajaxice.core import dajaxice_functions def test_registered_function(request): return "" dajaxice_functions.register(test_registered_function) def test_string(request): return simplejson.dumps({'string':'hello world'}) dajaxice_functions.register(test_string) def test_ajax_exception(request): raise Exception() return dajaxice_functions.register(test_ajax_exception) def test_foo(request): return "" dajaxice_functions.register(test_foo) def test_foo_with_params(request, param1):
from django.contrib.auth.decorators import login_required from forums.models import Post from forums.views import post_vote from utilities.dajax.core import Dajax from utilities.dajaxice.core import dajaxice_functions """ The was no comment in this file until I wrote one. """ @login_required def voteup(request, post_id): return vote(request, post_id, 1) dajaxice_functions.register(voteup) @login_required def votecancel(request, post_id): return vote(request, post_id, 0) dajaxice_functions.register(votecancel) @login_required def votedown(request, post_id): return vote(request, post_id, -1) dajaxice_functions.register(votedown) CSS_CLASSES = { -1: 'negative', 0: 'neutral', 1: 'positive', }