-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from Kandeel4411/support-multiple-assigned-groups
Add support for multiple groups and users
- Loading branch information
Showing
13 changed files
with
413 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2021-09-14 10:02+0000\n" | ||
"POT-Creation-Date: 2024-01-16 01:07+0000\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
@@ -72,6 +72,12 @@ msgstr "Ausgeblendet bis" | |
msgid "Acknowledge reason" | ||
msgstr "Ausblendungsgrund" | ||
|
||
msgid "Assigned users" | ||
msgstr "Zugewiesene Benutzer" | ||
|
||
msgid "Assigned groups" | ||
msgstr "Zugewiesene Gruppen" | ||
|
||
msgid "Result" | ||
msgstr "Ergebnis" | ||
|
||
|
@@ -84,6 +90,27 @@ msgstr "Zu Status" | |
msgid "Result status history" | ||
msgstr "Ergebnis-Status-Historie" | ||
|
||
msgid "Group" | ||
msgstr "Gruppe" | ||
|
||
msgid "Result assigned group" | ||
msgstr "Zugewiesene Gruppe" | ||
|
||
msgid "Result assigned groups" | ||
msgstr "Zugewiesene Gruppen" | ||
|
||
msgid "Group must be unique across the result" | ||
msgstr "Gruppen müssen je Ergebnis eindeutig sein" | ||
|
||
msgid "Result assigned user" | ||
msgstr "Zugewiesener Benutzer" | ||
|
||
msgid "Result assigned users" | ||
msgstr "Zugewiesene Benutzer" | ||
|
||
msgid "User must be unique across the result" | ||
msgstr "Benutzer müssen je Ergebnis eindeutig sein" | ||
|
||
msgid "Check module slug" | ||
msgstr "Modul-Bezeichner" | ||
|
||
|
@@ -136,6 +163,9 @@ msgstr "Nicht zugewiesen" | |
msgid "Config form class" | ||
msgstr "Formular-Klasse für Konfiguration" | ||
|
||
msgid "Config" | ||
msgstr "Konfiguration" | ||
|
||
msgid "Run every" | ||
msgstr "Periodisches Ausführen" | ||
|
||
|
@@ -152,12 +182,6 @@ msgstr "Maximale Ausblendezeit" | |
msgid "%(days)s day(s)" | ||
msgstr "%(days)s Tag(e)" | ||
|
||
msgid "Assigned group" | ||
msgstr "Zugewiesene Gruppe" | ||
|
||
msgid "Assigned user" | ||
msgstr "Zugewiesener Benutzer" | ||
|
||
#, python-format | ||
msgid "Acknowledged until %(date)s by %(user)s" | ||
msgstr "Ausgeblendet bis %(date)s durch %(user)s" | ||
|
59 changes: 59 additions & 0 deletions
59
django_datawatch/migrations/0004_resultassigneduser_resultassignedgroup_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Generated by Django 4.2.9 on 2024-01-16 00:05 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('auth', '0012_alter_user_first_name_max_length'), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('django_datawatch', '0003_resultstatushistory'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='ResultAssignedUser', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('result', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_datawatch.result', verbose_name='Result')), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User')), | ||
], | ||
options={ | ||
'verbose_name': 'Result assigned user', | ||
'verbose_name_plural': 'Result assigned users', | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='ResultAssignedGroup', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.group', verbose_name='Group')), | ||
('result', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_datawatch.result', verbose_name='Result')), | ||
], | ||
options={ | ||
'verbose_name': 'Result assigned group', | ||
'verbose_name_plural': 'Result assigned groups', | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name='result', | ||
name='assigned_groups', | ||
field=models.ManyToManyField(blank=True, related_name='assigned_groups', through='django_datawatch.ResultAssignedGroup', to='auth.group', verbose_name='Assigned groups'), | ||
), | ||
migrations.AddField( | ||
model_name='result', | ||
name='assigned_users', | ||
field=models.ManyToManyField(blank=True, related_name='assigned_results', through='django_datawatch.ResultAssignedUser', to=settings.AUTH_USER_MODEL, verbose_name='Assigned users'), | ||
), | ||
migrations.AddConstraint( | ||
model_name='resultassigneduser', | ||
constraint=models.UniqueConstraint(fields=('result', 'user'), name='unique_result_assigned_user'), | ||
), | ||
migrations.AddConstraint( | ||
model_name='resultassignedgroup', | ||
constraint=models.UniqueConstraint(fields=('result', 'group'), name='unique_result_assigned_group'), | ||
), | ||
] |
47 changes: 47 additions & 0 deletions
47
django_datawatch/migrations/0005_migrate_new_assigned_fields.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Generated by Django 4.2.9 on 2024-01-16 00:06 | ||
|
||
from django.db import migrations | ||
|
||
from django.core.paginator import Paginator | ||
|
||
def migrate_new_assigned_fields(apps, schema_editor): | ||
Result = apps.get_model('django_datawatch', 'Result') | ||
ResultAssignedGroup = apps.get_model('django_datawatch', 'ResultAssignedGroup') | ||
ResultAssignedUser = apps.get_model('django_datawatch', 'ResultAssignedUser') | ||
|
||
# Paginate the queryset to avoid memory issues | ||
paginator = Paginator( | ||
Result.objects.order_by('pk').only('assigned_to_user', 'assigned_to_group'), | ||
5000, | ||
) | ||
|
||
for page_number in paginator.page_range: | ||
page = paginator.page(page_number) | ||
group_instances = [] | ||
user_instances = [] | ||
|
||
for result in page.object_list: | ||
if result.assigned_to_group: | ||
group_instances.append(ResultAssignedGroup( | ||
result_id=result.pk, | ||
group_id=result.assigned_to_group.pk, | ||
)) | ||
if result.assigned_to_user: | ||
user_instances.append(ResultAssignedUser( | ||
result_id=result.pk, | ||
user_id=result.assigned_to_user.pk, | ||
)) | ||
|
||
ResultAssignedGroup.objects.bulk_create(group_instances) | ||
ResultAssignedUser.objects.bulk_create(user_instances) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('django_datawatch', '0004_resultassigneduser_resultassignedgroup_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(migrate_new_assigned_fields), | ||
] |
21 changes: 21 additions & 0 deletions
21
django_datawatch/migrations/0006_remove_result_assigned_to_group_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 4.2.9 on 2024-01-16 00:07 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('django_datawatch', '0005_migrate_new_assigned_fields'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='result', | ||
name='assigned_to_group', | ||
), | ||
migrations.RemoveField( | ||
model_name='result', | ||
name='assigned_to_user', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.