from django.template.response import TemplateResponse

from ..products.models import Product
from ..static import testcyclestatus
from ..users.decorators import login_required

from .models import TestCycleList



@login_required
def cycles(request, product_id):
    product = Product.get("products/%s" % product_id, auth=request.auth)

    # @@@ should be auth=request.auth - API permissions broken here?
    from ..core.api import admin
    cycles = TestCycleList.get(auth=admin).filter(
        productId=product_id, testCycleStatusId=testcyclestatus.ACTIVE)

    return TemplateResponse(
        request, "test/cycles.html", {"product": product, "cycles": cycles})

from django.template.response import TemplateResponse

from ..products.models import Product
from ..static import testcyclestatus
from ..users.decorators import login_required

from .models import TestCycleList



@login_required
def cycles(request, product_id):
    product = Product.get("products/%s" % product_id, auth=request.auth)

    cycles = TestCycleList.get(auth=request.auth).filter(
        productId=product_id, testCycleStatusId=testcyclestatus.ACTIVE)

    return TemplateResponse(
        request, "test/cycles.html", {"product": product, "cycles": cycles})

Use correct auth in cycles view, now that API permissions are fixed.
Use correct auth in cycles view, now that API permissions are fixed.

  from django.template.response import TemplateResponse
  
  from ..products.models import Product
  from ..static import testcyclestatus
  from ..users.decorators import login_required
  
  from .models import TestCycleList
  
  
  
  @login_required
  def cycles(request, product_id):
      product = Product.get("products/%s" % product_id, auth=request.auth)
  
-     # @@@ should be auth=request.auth - API permissions broken here?
-     from ..core.api import admin
-     cycles = TestCycleList.get(auth=admin).filter(
+     cycles = TestCycleList.get(auth=request.auth).filter(
          productId=product_id, testCycleStatusId=testcyclestatus.ACTIVE)
  
      return TemplateResponse(
          request, "test/cycles.html", {"product": product, "cycles": cycles})
  
Use correct auth in cycles view, now that API permissions are fixed.
## Code Before:
from django.template.response import TemplateResponse

from ..products.models import Product
from ..static import testcyclestatus
from ..users.decorators import login_required

from .models import TestCycleList



@login_required
def cycles(request, product_id):
    product = Product.get("products/%s" % product_id, auth=request.auth)

    # @@@ should be auth=request.auth - API permissions broken here?
    from ..core.api import admin
    cycles = TestCycleList.get(auth=admin).filter(
        productId=product_id, testCycleStatusId=testcyclestatus.ACTIVE)

    return TemplateResponse(
        request, "test/cycles.html", {"product": product, "cycles": cycles})

## Instruction:
Use correct auth in cycles view, now that API permissions are fixed.
## Code After:
from django.template.response import TemplateResponse

from ..products.models import Product
from ..static import testcyclestatus
from ..users.decorators import login_required

from .models import TestCycleList



@login_required
def cycles(request, product_id):
    product = Product.get("products/%s" % product_id, auth=request.auth)

    cycles = TestCycleList.get(auth=request.auth).filter(
        productId=product_id, testCycleStatusId=testcyclestatus.ACTIVE)

    return TemplateResponse(
        request, "test/cycles.html", {"product": product, "cycles": cycles})
