Commit 380cc928 authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Move some functionality into a receiver

parent 1575bdc9
import logging
from rest_framework import generics, views, status
from rest_framework import generics, views
from rest_framework.authentication import TokenAuthentication
from rest_framework.response import Response
from ..models import RabbitMQInstance
from .serializers import SiteSerializer, ServiceSerializer
LOGGER = logging.getLogger(__name__)
......@@ -28,10 +27,6 @@ class ConfigurationView(generics.ListAPIView):
def get_queryset(self):
site = self.request.user.site
# we update the rabbitmq permission here, so the
# client can access all of his services, even new ones
RabbitMQInstance.load().update_site(site)
return site.services.all()
......
......@@ -681,7 +681,6 @@ class DeploymentTask(models.Model):
from .clientapi.serializers import DeploymentTaskSerializer
msg = json.dumps(DeploymentTaskSerializer(self).data)
# FIXME select the rabbitmq instance more meaningful
RabbitMQInstance.load().publish_by_service(
self.service,
msg,
......@@ -744,12 +743,18 @@ def register_at_rabbitmq(sender, instance=None, created=False, **kwargs):
if not created:
return
RabbitMQInstance().register_site(instance)
RabbitMQInstance.load().register_site(instance)
@receiver(pre_delete, sender=Site)
def deregister_at_rabbitmq(sender, instance=None, **kwargs):
RabbitMQInstance().deregister_site(instance)
RabbitMQInstance.load().deregister_site(instance)
@receiver(post_save, sender=Service)
def update_at_rabbitmq(sender, instance=None, **kwargs):
for site in instance.site.all():
RabbitMQInstance.load().update_site(site)
@receiver(post_save, sender=User)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment