from django_digest.decorators import *
from casexml.apps.phone import xml
from casexml.apps.case.models import CommCareCase
from casexml.apps.phone.restore import generate_restore_response
from casexml.apps.phone.models import User
from casexml.apps.case import const



@httpdigest
def restore(request):
    user = User.from_django_user(request.user)
    restore_id = request.GET.get('since')
    return generate_restore_response(user, restore_id)
    

def xml_for_case(request, case_id, version="1.0"):
    """
    Test view to get the xml for a particular case
    """
    from django.http import HttpResponse
    case = CommCareCase.get(case_id)
    return HttpResponse(xml.get_case_xml(case, [const.CASE_ACTION_CREATE,
                                                const.CASE_ACTION_UPDATE],
                                         version), mimetype="text/xml")
    
from django.http import HttpResponse
from django_digest.decorators import *
from casexml.apps.phone import xml
from casexml.apps.case.models import CommCareCase
from casexml.apps.phone.restore import generate_restore_response
from casexml.apps.phone.models import User
from casexml.apps.case import const



@httpdigest
def restore(request):
    user = User.from_django_user(request.user)
    restore_id = request.GET.get('since')
    return generate_restore_response(user, restore_id)
    

def xml_for_case(request, case_id, version="1.0"):
    """
    Test view to get the xml for a particular case
    """
    case = CommCareCase.get(case_id)
    return HttpResponse(xml.get_case_xml(case, [const.CASE_ACTION_CREATE,
                                                const.CASE_ACTION_UPDATE],
                                         version), mimetype="text/xml")
    
Revert "moving httpresponse to view"
Revert "moving httpresponse to view"

This reverts commit a6f501bb9de6382e35372996851916adac067fa0.

+ from django.http import HttpResponse
  from django_digest.decorators import *
  from casexml.apps.phone import xml
  from casexml.apps.case.models import CommCareCase
  from casexml.apps.phone.restore import generate_restore_response
  from casexml.apps.phone.models import User
  from casexml.apps.case import const
  
  
  
  @httpdigest
  def restore(request):
      user = User.from_django_user(request.user)
      restore_id = request.GET.get('since')
      return generate_restore_response(user, restore_id)
      
  
  def xml_for_case(request, case_id, version="1.0"):
      """
      Test view to get the xml for a particular case
      """
-     from django.http import HttpResponse
      case = CommCareCase.get(case_id)
      return HttpResponse(xml.get_case_xml(case, [const.CASE_ACTION_CREATE,
                                                  const.CASE_ACTION_UPDATE],
                                           version), mimetype="text/xml")
      
Revert "moving httpresponse to view"
## Code Before:
from django_digest.decorators import *
from casexml.apps.phone import xml
from casexml.apps.case.models import CommCareCase
from casexml.apps.phone.restore import generate_restore_response
from casexml.apps.phone.models import User
from casexml.apps.case import const



@httpdigest
def restore(request):
    user = User.from_django_user(request.user)
    restore_id = request.GET.get('since')
    return generate_restore_response(user, restore_id)
    

def xml_for_case(request, case_id, version="1.0"):
    """
    Test view to get the xml for a particular case
    """
    from django.http import HttpResponse
    case = CommCareCase.get(case_id)
    return HttpResponse(xml.get_case_xml(case, [const.CASE_ACTION_CREATE,
                                                const.CASE_ACTION_UPDATE],
                                         version), mimetype="text/xml")
    
## Instruction:
Revert "moving httpresponse to view"
## Code After:
from django.http import HttpResponse
from django_digest.decorators import *
from casexml.apps.phone import xml
from casexml.apps.case.models import CommCareCase
from casexml.apps.phone.restore import generate_restore_response
from casexml.apps.phone.models import User
from casexml.apps.case import const



@httpdigest
def restore(request):
    user = User.from_django_user(request.user)
    restore_id = request.GET.get('since')
    return generate_restore_response(user, restore_id)
    

def xml_for_case(request, case_id, version="1.0"):
    """
    Test view to get the xml for a particular case
    """
    case = CommCareCase.get(case_id)
    return HttpResponse(xml.get_case_xml(case, [const.CASE_ACTION_CREATE,
                                                const.CASE_ACTION_UPDATE],
                                         version), mimetype="text/xml")
    