Commit 6a17098f authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Add deletion of user at rabbitmq

parent 5abcfb5f
......@@ -4,7 +4,7 @@ from django.conf import settings
from django.dispatch import receiver, Signal
from django.utils.timezone import make_aware
from rest_framework.authtoken.models import Token
from django.db.models.signals import post_save
from django.db.models.signals import post_save, pre_delete
# from django.db.models.signals import m2m_changed
from datetime import datetime
......@@ -103,6 +103,13 @@ def register_at_rabbitmq(
@receiver(pre_delete, sender=Site)
def deregister_at_rabbitmq(
sender, instance=None, **kwargs):
class Service(models.Model):
name = models.CharField(max_length=150, unique=True)
description = models.TextField(max_length=300, blank=True)
......@@ -14,6 +14,9 @@ class RabbitMQInstance:
# guest only works on the localhost
self.auth = HTTPBasicAuth('guest', 'guest')
def get_uri(self, path):
return '{}/{}'.format(self.api, path)
def set_topic_permissions(self, site):
username = site.client.username
set_topic_permission_uri = '{}/topic-permissions/{}/{}/'.format(
......@@ -89,12 +92,7 @@ class RabbitMQInstance:
# delete user at the rabbitmq instance
def delete_user(self, site):
username = site.client.username
user_creation_uri = '{}/users/{}/'.format(
print('registerring client {}'.format(site.client.username))
user_creation_uri = self.get_uri('users/{}/'.format(username))
user_creation_data = {
'password': str(site.client.auth_token.key),
......@@ -103,9 +101,12 @@ class RabbitMQInstance:
# TODO might fail
r = requests.delete(
user_creation_uri, json=user_creation_data, auth=self.auth)
print('RabbitMQ: create_user {}'.format(r.status_code))
print('RabbitMQ: delete_user {}'.format(r.status_code))
def register_site(self, site):
def deregister_site(self, site):
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