Exemple #1
0
 def search(cls, query, identity=None):
     if identity:
         base_apps = Application.objects.filter(
             # Privately owned OR public machines
             Q(private=True,
               providermachine__created_by_identity=identity)
             | Q(private=False,
                 providermachine__provider=identity.provider))
     else:
         active_providers = Provider.get_active()
         base_apps = Application.objects.filter(
             # Public machines
             private=False,
             #Providermachine's provider is active
             providermachine__provider__in=active_providers)
     # AND query matches on:
     return base_apps.filter(
         # app tag name
         Q(tags__name__icontains=query)
         # OR app tag desc
         | Q(tags__description__icontains=query)
         # OR app name
         | Q(name__icontains=query)
         # OR app desc
         | Q(description__icontains=query),
         only_active())
 def get_user_instances(self, project):
     return [InstanceSerializer(
         item,
         context={'request': self.context.get('request')}).data for item in
         project.instances.filter(only_active(),
             provider_machine__provider__active=True
             )]
 def get_user_instances(self, atmo_user):
     return [InstanceSerializer(
         item,
         context={'request': self.context.get('request')}).data for item in
         atmo_user.instance_set.filter(only_active(),
             provider_machine__provider__active=True,
             projects=None)]
Exemple #4
0
 def get_user_applications(self, project):
     return [
         ApplicationSerializer(item,
                               context={
                                   'request': self.context.get('request')
                               }).data
         for item in project.applications.filter(only_active())
     ]
Exemple #5
0
 def _current_machines(self):
     """
     Return a list of current provider machines.
     """
     pms = self.providermachine_set.filter(
         Q(provider__end_date=None)
         | Q(provider__end_date__gt=timezone.now()), only_active())
     return pms
Exemple #6
0
 def get_user_applications(self, atmo_user):
     return [
         ApplicationSerializer(item,
                               context={
                                   'request': self.context.get('request')
                               }).data
         for item in atmo_user.application_set.filter(only_active(),
                                                      projects=None)
     ]
Exemple #7
0
 def get_user_instances(self, project):
     return [
         InstanceSerializer(item,
                            context={
                                'request': self.context.get('request')
                            }).data
         for item in project.instances.filter(
             only_active(), provider_machine__provider__active=True)
     ]
Exemple #8
0
 def get_user_volumes(self, project):
     return [
         VolumeSerializer(item,
                          context={
                              'request': self.context.get('request')
                          }).data
         for item in project.volumes.filter(only_active(),
                                            provider__active=True)
     ]
Exemple #9
0
 def _current_machines(self):
     """
     Return a list of current provider machines.
     """
     pms = self.providermachine_set.filter(
         Q(provider__end_date=None)
         | Q(provider__end_date__gt=timezone.now()),
         only_active())
     return pms
Exemple #10
0
 def get_user_volumes(self, atmo_user):
     return [
         VolumeSerializer(item,
                          context={
                              'request': self.context.get('request')
                          }).data
         for item in atmo_user.volume_set.filter(
             only_active(), provider__active=True, projects=None)
     ]
Exemple #11
0
 def get_user_instances(self, atmo_user):
     return [
         InstanceSerializer(item,
                            context={
                                'request': self.context.get('request')
                            }).data
         for item in atmo_user.instance_set.filter(
             only_active(),
             provider_machine__provider__active=True,
             projects=None)
     ]
Exemple #12
0
 def search(cls, identity, query):
     return ProviderMachine.objects.filter(
         # Privately owned OR public machines
         Q(application__private=True, created_by_identity=identity)
         | Q(application__private=False, provider=identity.provider),
         # AND query matches on:
         # app tag name OR
         # app tag desc OR
         # app name OR
         # app desc
         Q(application__tags__name__icontains=query)
         | Q(application__tags__description__icontains=query)
         | Q(application__name__icontains=query)
         | Q(application__description__icontains=query),
         only_active())
 def get_user_volumes(self, project):
     return [VolumeSerializer(item,
         context={'request':self.context.get('request')}).data for item in
         project.volumes.filter(only_active())]
 def get_user_applications(self, project):
     return [ApplicationSerializer(item,
         context={'request':self.context.get('request')}).data for item in
         project.applications.filter(only_active())]
Exemple #15
0
 def get_projects(self, user):
     projects = self.projects.filter(
         only_active(),
         owner=user)
     return projects
Exemple #16
0
 def get_user_applications(self, atmo_user):
     return [ApplicationSerializer(
         item,
         context={'request': self.context.get('request')}).data for item in
         atmo_user.application_set.filter(only_active(), projects=None)]
Exemple #17
0
 def get_user_volumes(self, atmo_user):
     return [VolumeSerializer(
         item,
         context={'request': self.context.get('request')}).data for item in
         atmo_user.volume_set.filter(only_active(), projects=None)]
Exemple #18
0
 def get_projects(self, user):
     projects = self.projects.filter(only_active(), owner=user)
     return projects