Mitja Nikolaus | d6907dd | 2018-10-17 14:13:06 +0200 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| 3 | """Migrations for creating the Fairphone staff authentication group.""" |
| 4 | # pylint: disable=invalid-name |
| 5 | |
| 6 | from django.contrib.auth.models import Group |
| 7 | from django.db import migrations |
| 8 | |
| 9 | from hiccup.allauth_adapters import FP_STAFF_GROUP_NAME |
| 10 | |
| 11 | |
| 12 | def add_fp_staff_group(apps, schema_editor): |
| 13 | """Create the Fairphone staff group if it does not exist.""" |
| 14 | # pylint: disable=unused-argument |
| 15 | |
| 16 | if not Group.objects.filter(name=FP_STAFF_GROUP_NAME).exists(): |
| 17 | Group.objects.create(name=FP_STAFF_GROUP_NAME) |
| 18 | |
| 19 | |
| 20 | class Migration(migrations.Migration): |
| 21 | """Run the migration script.""" |
| 22 | |
| 23 | dependencies = [("crashreports", "0004_update_logfile_paths")] |
| 24 | |
| 25 | operations = [migrations.RunPython(add_fp_staff_group)] |