コード例 #1
0
ファイル: ajax.py プロジェクト: chi1/trinitee
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()
コード例 #2
0
ファイル: ajax.py プロジェクト: chi1/trinitee
def vote(request, post_id, vote_value):
	result = post_vote(request, post_id, vote_value)
	dajax = Dajax()
	if isinstance(result, Post):
		dajax.remove_css_class('#post-%s .karma' % (post_id), 'current')
		dajax.add_css_class('#post-%s .karma_%s' % (post_id, CSS_CLASSES[vote_value]), 'current')
		dajax.assign('#post-%s .karma-voted' % post_id, 'innerHTML', 'Saved.')
		dajax.assign('#post-%s .karma-count' % post_id, 'innerHTML',
			result.get_karma())
	else:
		dajax.assign('#post-%s .karma-voted' % post_id, 'innerHTML', result[0])
	return dajax.json()