# Path: depot/models.py
# class Organization(models.Model):
#     """
#     Representation of an organization,
#     such as FSMPI, FSMB or ASTA.
# 
#     An organization is defined by a list of user groups,
#     in our case LDAP groups. It is managed by a list of
#     users and has a list of depots.
# 
#     :author: Leo Tappe
#     :author: Benedikt Seidl
#     """
# 
#     name = models.CharField(max_length=32)
#     groups = models.ManyToManyField(Group, blank=True)
#     managers = models.ManyToManyField(User, blank=True)
# 
#     def managed_by(self, user):
#         """
#         Organizations are managed by superusers and organization managers.
#         """
# 
#         return user.is_superuser or self.managers.filter(id=user.id).exists()
# 
#     def is_member(self, user):
#         """
#         Checks if the user is in one of the groups defined in this organization.
#         """
# 
#         return self.groups.filter(id__in=user.groups.all()).exists()
# 
#     @property
#     def active_depots(self):
#         """
#         Returns all depots in this organization which have the active flag set.
#         """
# 
#         return self.depot_set.filter(active=True)
# 
#     @staticmethod
#     def filter_by_user(user):
#         """
#         Filter for organizations managed by the given user
#         """
# 
#         return models.Q(managers__id=user.id)
# 
#     def __str__(self):
#         return self.name


from django.shortcuts import render
from django.views import View
from depot.models import Organization


class DepotIndexView(View):
    """
    Show an index page of all organizations and their depots

    Only organization managers get a link to the admin interface of their
    organization so that they can change the name and add new depots.

    :author: Florian Stamer
    :author: Benedikt Seidl
    """

    def get(self, request):
        organization_depots = []


# Path: depot/models.py
# class Organization(models.Model):
#     """
#     Representation of an organization,
#     such as FSMPI, FSMB or ASTA.
# 
#     An organization is defined by a list of user groups,
#     in our case LDAP groups. It is managed by a list of
#     users and has a list of depots.
# 
#     :author: Leo Tappe
#     :author: Benedikt Seidl
#     """
# 
#     name = models.CharField(max_length=32)
#     groups = models.ManyToManyField(Group, blank=True)
#     managers = models.ManyToManyField(User, blank=True)
# 
#     def managed_by(self, user):
#         """
#         Organizations are managed by superusers and organization managers.
#         """
# 
#         return user.is_superuser or self.managers.filter(id=user.id).exists()
# 
#     def is_member(self, user):
#         """
#         Checks if the user is in one of the groups defined in this organization.
#         """
# 
#         return self.groups.filter(id__in=user.groups.all()).exists()
# 
#     @property
#     def active_depots(self):
#         """
#         Returns all depots in this organization which have the active flag set.
#         """
# 
#         return self.depot_set.filter(active=True)
# 
#     @staticmethod
#     def filter_by_user(user):
#         """
#         Filter for organizations managed by the given user
#         """
# 
#         return models.Q(managers__id=user.id)
# 
#     def __str__(self):
#         return self.name


# Path: depot/views/depot_index_view.py
from django.shortcuts import render
from django.views import View
from depot.models import Organization



class DepotIndexView(View):
    """
    Show an index page of all organizations and their depots

    Only organization managers get a link to the admin interface of their
    organization so that they can change the name and add new depots.

    :author: Florian Stamer
    :author: Benedikt Seidl
    """

    def get(self, request):
        organization_depots = []


        for organization in Organization.objects.all():