pytask/taskapp/views/task.py
changeset 545 3a86d85333a3
parent 543 57b0f8f80ebf
child 550 a606a40584f7
equal deleted inserted replaced
544:17c60a9c2439 545:3a86d85333a3
    22 from django.template import RequestContext
    22 from django.template import RequestContext
    23 from django.utils import simplejson as json
    23 from django.utils import simplejson as json
    24 from django.utils.translation import ugettext
    24 from django.utils.translation import ugettext
    25 
    25 
    26 from tagging.models import Tag
    26 from tagging.models import Tag
       
    27 from tagging.models import TaggedItem
    27 
    28 
    28 from pytask.helpers import exceptions
    29 from pytask.helpers import exceptions
    29 from pytask.views import show_msg
    30 from pytask.views import show_msg
    30 
    31 
    31 from pytask.profile import models as profile_models
    32 from pytask.profile import models as profile_models
   653       tag_entities = Tag.objects.filter(name__icontains=term)
   654       tag_entities = Tag.objects.filter(name__icontains=term)
   654       response = [tag.name for tag in tag_entities]
   655       response = [tag.name for tag in tag_entities]
   655 
   656 
   656     json_response = json.dumps(response)
   657     json_response = json.dumps(response)
   657     return http.HttpResponse(json_response)
   658     return http.HttpResponse(json_response)
       
   659 
       
   660 def view_tag(request, tag_name, template='task/view_tag.html'):
       
   661     """View that displays all the tasks tagged with the given name
       
   662     """
       
   663 
       
   664     tag = Tag.objects.filter(name=tag_name)
       
   665     tasks = TaggedItem.objects.get_by_model(taskapp_models.Task, tag)
       
   666 
       
   667     context = {
       
   668       'tag_name': tag_name,
       
   669       'tasks': tasks,
       
   670       }
       
   671 
       
   672     return shortcuts.render_to_response(
       
   673       template, RequestContext(request, context))