forked from shaba/openuds
Fixed migration tree
This commit is contained in:
parent
2eff59908a
commit
7ab6d439cb
@ -1,29 +0,0 @@
|
||||
# Generated by Django 3.2.4 on 2021-06-28 15:33
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('uds', '0041_auto_20210624_1233'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='TunnelToken',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('username', models.CharField(max_length=128)),
|
||||
('ip_from', models.CharField(max_length=16)),
|
||||
('ip', models.CharField(max_length=16)),
|
||||
('hostname', models.CharField(max_length=128)),
|
||||
('token', models.CharField(db_index=True, max_length=48, unique=True)),
|
||||
('stamp', models.DateTimeField()),
|
||||
],
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='tunneltoken',
|
||||
constraint=models.UniqueConstraint(fields=('ip', 'hostname'), name='tt_ip_hostname'),
|
||||
),
|
||||
]
|
@ -39,7 +39,7 @@ def clean_config(apps, schema_editor):
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('uds', '0042_auto_20210628_1533'),
|
||||
('uds', '0001_squashed_0042_auto_20210628_1533'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
@ -137,3 +137,28 @@ class Notifier(ManagedObjectModel, TaggingMixin):
|
||||
return typing.cast('NotificationProviderModule', super().getInstance(values=values))
|
||||
|
||||
|
||||
@staticmethod
|
||||
def beforeDelete(sender, **kwargs) -> None:
|
||||
"""
|
||||
Used to invoke the Service class "Destroy" before deleting it from database.
|
||||
|
||||
The main purpuse of this hook is to call the "destroy" method of the object to delete and
|
||||
to clear related data of the object (environment data such as own storage, cache, etc...
|
||||
|
||||
:note: If destroy raises an exception, the deletion is not taken.
|
||||
"""
|
||||
toDelete: 'Notifier' = kwargs['instance']
|
||||
# Only tries to get instance if data is not empty
|
||||
if toDelete.data:
|
||||
try:
|
||||
s = toDelete.getInstance()
|
||||
s.destroy()
|
||||
s.env.clearRelatedData()
|
||||
except Exception as e:
|
||||
logger.error('Error processing deletion of notifier %s: %s (forced deletion)', toDelete.name, e)
|
||||
|
||||
logger.debug('Before delete mfa provider %s', toDelete)
|
||||
|
||||
|
||||
# : Connects a pre deletion signal to OS Manager
|
||||
models.signals.pre_delete.connect(Notifier.beforeDelete, sender=Notifier)
|
||||
|
Loading…
Reference in New Issue
Block a user