Created
April 13, 2011 21:24
-
-
Save Ell/918453 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cat_tag(request): | |
if request.is_ajax(): | |
if request.method == 'GET': | |
id = request.GET['id'] | |
tagging = Images.objects.get(id=id) | |
tags = Tag.objects.usage_for_model(tagging, counts=True) | |
usageNum = [{"tag": tagfreq.name, "count": tagfreq.count} for tagfreq in tags] | |
dump = simplejson.dumps(usageNum) | |
message = dump | |
elif request.method == 'POST': | |
id = request.POST['id'] | |
tags = request.POST['tags'] | |
tagging = Images.objects.get(id=id) | |
tagarray = parse_tag_input(tags) | |
for dicks in tagarray: | |
Tag.objects.add_tag(tagging, dicks) | |
message = "Ok!" | |
else: | |
message = "not validated." | |
return HttpResponse(message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment