From 94dd1dd7a30046626d87e055a42b6d6b263a03ad Mon Sep 17 00:00:00 2001 From: MG Date: Thu, 16 May 2019 20:01:27 +0200 Subject: [PATCH 1/5] Add migrations, Removed migrations from ignore --- .gitignore | 2 +- src/account_helper/migrations/0001_initial.py | 27 +++++++++++++++++++ .../migrations/0002_deleteduser.py | 24 +++++++++++++++++ src/account_helper/migrations/__init__.py | 0 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/account_helper/migrations/0001_initial.py create mode 100644 src/account_helper/migrations/0002_deleteduser.py create mode 100644 src/account_helper/migrations/__init__.py diff --git a/.gitignore b/.gitignore index 5840c7e..f9d5a58 100644 --- a/.gitignore +++ b/.gitignore @@ -115,7 +115,7 @@ dmypy.json .pyre/ .idea/ -migrations/ +#migrations/ logs/ db/ !docker/ldap/data/var/ diff --git a/src/account_helper/migrations/0001_initial.py b/src/account_helper/migrations/0001_initial.py new file mode 100644 index 0000000..a7bd275 --- /dev/null +++ b/src/account_helper/migrations/0001_initial.py @@ -0,0 +1,27 @@ +# Generated by Django 2.1.7 on 2019-05-14 21:38 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('auth', '0009_alter_user_last_name_max_length'), + ] + + operations = [ + migrations.CreateModel( + name='Realm', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=200, unique=True)), + ('email', models.CharField(max_length=200)), + ('ldap_base_dn', models.CharField(max_length=400, unique=True)), + ('admin_group', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='admin_groups', to='auth.Group')), + ('default_group', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='default_groups', to='auth.Group')), + ], + ), + ] diff --git a/src/account_helper/migrations/0002_deleteduser.py b/src/account_helper/migrations/0002_deleteduser.py new file mode 100644 index 0000000..27c79c9 --- /dev/null +++ b/src/account_helper/migrations/0002_deleteduser.py @@ -0,0 +1,24 @@ +# Generated by Django 2.1.7 on 2019-05-15 01:07 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('account_helper', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='DeletedUser', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('deletion_date', models.DateField(auto_now=True)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/src/account_helper/migrations/__init__.py b/src/account_helper/migrations/__init__.py new file mode 100644 index 0000000..e69de29 From fb960855f054d9fa6943baee627ea609b135f1e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20G=C3=B6tz?= Date: Fri, 17 May 2019 13:39:29 +0200 Subject: [PATCH 2/5] Ignore migrations and external data --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f9d5a58..0793861 100644 --- a/.gitignore +++ b/.gitignore @@ -115,8 +115,9 @@ dmypy.json .pyre/ .idea/ -#migrations/ +migrations/ logs/ db/ +data/ !docker/ldap/data/var/ *.mdb From 16722682aa6459aaee3e8be7634960ed2536a0ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20G=C3=B6tz?= Date: Fri, 17 May 2019 13:41:41 +0200 Subject: [PATCH 3/5] Remove now ignored migrations --- src/account_helper/migrations/0001_initial.py | 27 ------------------- .../migrations/0002_deleteduser.py | 24 ----------------- src/account_helper/migrations/__init__.py | 0 3 files changed, 51 deletions(-) delete mode 100644 src/account_helper/migrations/0001_initial.py delete mode 100644 src/account_helper/migrations/0002_deleteduser.py delete mode 100644 src/account_helper/migrations/__init__.py diff --git a/src/account_helper/migrations/0001_initial.py b/src/account_helper/migrations/0001_initial.py deleted file mode 100644 index a7bd275..0000000 --- a/src/account_helper/migrations/0001_initial.py +++ /dev/null @@ -1,27 +0,0 @@ -# Generated by Django 2.1.7 on 2019-05-14 21:38 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ('auth', '0009_alter_user_last_name_max_length'), - ] - - operations = [ - migrations.CreateModel( - name='Realm', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=200, unique=True)), - ('email', models.CharField(max_length=200)), - ('ldap_base_dn', models.CharField(max_length=400, unique=True)), - ('admin_group', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='admin_groups', to='auth.Group')), - ('default_group', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='default_groups', to='auth.Group')), - ], - ), - ] diff --git a/src/account_helper/migrations/0002_deleteduser.py b/src/account_helper/migrations/0002_deleteduser.py deleted file mode 100644 index 27c79c9..0000000 --- a/src/account_helper/migrations/0002_deleteduser.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 2.1.7 on 2019-05-15 01:07 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('account_helper', '0001_initial'), - ] - - operations = [ - migrations.CreateModel( - name='DeletedUser', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('deletion_date', models.DateField(auto_now=True)), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - ), - ] diff --git a/src/account_helper/migrations/__init__.py b/src/account_helper/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 From ee67e23e5fde2b5204097c762b2d0b4b4e13a2a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20G=C3=B6tz?= Date: Fri, 17 May 2019 13:59:56 +0200 Subject: [PATCH 4/5] Fix wrong env setting for DELETION_WAIT_DAYS --- docker/lama/dev.env | 2 ++ src/core/docker_settings.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/lama/dev.env b/docker/lama/dev.env index 939367e..1f640cd 100644 --- a/docker/lama/dev.env +++ b/docker/lama/dev.env @@ -28,3 +28,5 @@ LDAP_GROUP_NAME_ATTR=cn EMAIL_BACKEND=file DEFAULT_FROM_EMAIL= SERVER_EMAIL= + +DELETION_WAIT_DAYS=14 diff --git a/src/core/docker_settings.py b/src/core/docker_settings.py index 59a58e3..6783c79 100644 --- a/src/core/docker_settings.py +++ b/src/core/docker_settings.py @@ -20,7 +20,7 @@ SITE_NAME = os.environ['SITE_NAME'] SECRET_KEY = os.environ['SECRET_KEY'] DEBUG = os.environ.get('DEBUG', 'False') == 'True' ALLOWED_HOSTS = os.environ['ALLOWED_HOSTS'].split() -DELETION_WAIT_DAYS = os.environ.get('DELETION_WAIT_DAYS', 14) +DELETION_WAIT_DAYS = int(os.environ.get('DELETION_WAIT_DAYS', "14")) # Application definition INSTALLED_APPS = [ From fac000e39c9c0a1f0ba111bf8d006827a9f6edb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20G=C3=B6tz?= Date: Fri, 17 May 2019 14:14:35 +0200 Subject: [PATCH 5/5] Add aktive user count --- src/templates/realm/realm_detailed.jinja2 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/templates/realm/realm_detailed.jinja2 b/src/templates/realm/realm_detailed.jinja2 index 3e88bb8..760b402 100644 --- a/src/templates/realm/realm_detailed.jinja2 +++ b/src/templates/realm/realm_detailed.jinja2 @@ -21,11 +21,14 @@ {% block detail_content %}
  • LDAP Organisationseinheit: {{ realm.ldap_base_dn }}
  • -
  • Nutzeranzahl: {{ users_count }}
  • -
  • Inaktive Nutzer: {{ inactive_user_count }} - Inaktive Nutzer löschen
  • +
  • Nutzeranzahl (Aktive/Inaktive): {{ users_count }} + ({{ users_count-inactive_user_count }}/{{ inactive_user_count }}) + + Inaktive Nutzer löschen + +
  • {% if realm.email %}
  • Email: {{ realm.email }}
  • {% else %}