# Path: depot/helpers.py
# def get_depot_if_allowed(depot_id, user):
#     """
#     Return the depot for the given if the user is allowed to access it
# 
#     Otherwise throws a PermissionDenied exception.
# 
#     :author: Benedikt Seidl
#     """
# 
#     depot = get_object_or_404(Depot, pk=depot_id)
# 
#     if not depot.organization.managed_by(user) and not depot.active:
#         raise PermissionDenied('Depot is not active')
# 
#     return depot


from datetime import datetime, timedelta
from depot.helpers import get_depot_if_allowed
from django.shortcuts import render
from django.views import View


class DepotDetailView(View):
    """
    Provide a detailed overview of all items in a depot

    Archived depots can only be accessed by superusers and organization managers.
    The internal items of a depot can be seen by all members of this organization.

    :author: Florian Stamer
    """

    def get(self, request, depot_id):

# Path: depot/helpers.py
# def get_depot_if_allowed(depot_id, user):
#     """
#     Return the depot for the given if the user is allowed to access it
# 
#     Otherwise throws a PermissionDenied exception.
# 
#     :author: Benedikt Seidl
#     """
# 
#     depot = get_object_or_404(Depot, pk=depot_id)
# 
#     if not depot.organization.managed_by(user) and not depot.active:
#         raise PermissionDenied('Depot is not active')
# 
#     return depot


# Path: depot/views/depot_detail_view.py
from datetime import datetime, timedelta
from depot.helpers import get_depot_if_allowed
from django.shortcuts import render
from django.views import View



class DepotDetailView(View):
    """
    Provide a detailed overview of all items in a depot

    Archived depots can only be accessed by superusers and organization managers.
    The internal items of a depot can be seen by all members of this organization.

    :author: Florian Stamer
    """

    def get(self, request, depot_id):

        depot = get_depot_if_allowed(depot_id, request.user)