old_contents: import types
  from datetime import date, datetime
  from django import template
  from django.utils.html import escape
  from casexml.apps.case.models import CommCareCase
  from django.template.loader import render_to_string
  
  register = template.Library()
  
  @register.simple_tag
  def render_case(case):
      if isinstance(case, basestring):
          # we were given an ID, fetch the case
          case = CommCareCase.get(case)
      
      return render_to_string("case/partials/single_case.html", {"case": case})
      
      
  @register.simple_tag
  def case_inline_display(case_id):
      """
      Given a case id, make a best effort at displaying it.
      """
      case = CommCareCase.get(case_id)
      if case:
          return "%s (opened: %s)" % (case.name, case.opened_on.date())
      return "unknown case: %s" % case_id
      
new_contents: import types
  from datetime import date, datetime
  from django import template
  from django.utils.html import escape
  from casexml.apps.case.models import CommCareCase
  from django.template.loader import render_to_string
  
  register = template.Library()
  
  @register.simple_tag
  def render_case(case):
      if isinstance(case, basestring):
          # we were given an ID, fetch the case
          case = CommCareCase.get(case)
      
      return render_to_string("case/partials/single_case.html", {"case": case})
      
      
  @register.simple_tag
  def case_inline_display(case_id):
      """
      Given a case id, make a best effort at displaying it.
      """
      case = CommCareCase.get(case_id)
      if case:
          if case.opened_on:
              return "%s (opened: %s)" % (case.name, case.opened_on.date())
          else:
              return case.name
      return "unknown case: %s" % case_id
      
subject: fix case rendering if opened_on happens to be null