diff options
Diffstat (limited to '')
-rw-r--r-- | client/migrations/0015_hidegroup.py | 23 | ||||
-rw-r--r-- | client/models.py | 5 | ||||
-rw-r--r-- | client/views.py | 3 |
3 files changed, 30 insertions, 1 deletions
diff --git a/client/migrations/0015_hidegroup.py b/client/migrations/0015_hidegroup.py new file mode 100644 index 0000000..5e054c2 --- /dev/null +++ b/client/migrations/0015_hidegroup.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.9 on 2022-09-26 17:20 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('auth', '0012_alter_user_first_name_max_length'), + ('client', '0014_auto_20220111_1503'), + ] + + operations = [ + migrations.CreateModel( + name='HideGroup', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('doc_type', models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to='client.documenttype')), + ('group', models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to='auth.group')), + ], + ), + ] diff --git a/client/models.py b/client/models.py index e01fe1f..20c8fa1 100644 --- a/client/models.py +++ b/client/models.py @@ -21,6 +21,11 @@ class DocumentType(models.Model): name = models.CharField(default="", max_length=250)
+class HideGroup(models.Model):
+ group = models.ForeignKey(Group, default=None, on_delete=models.CASCADE)
+ doc_type = models.ForeignKey(DocumentType, default=None, on_delete=models.CASCADE)
+
+
class PersonalData(models.Model):
parent_name = models.CharField(default="", max_length=250)
via = models.CharField(default="", max_length=250)
diff --git a/client/views.py b/client/views.py index bf2a641..d4e9709 100644 --- a/client/views.py +++ b/client/views.py @@ -1,7 +1,7 @@ from django.db.models.expressions import OuterRef, Subquery from django.template.loader import get_template from django.urls import reverse -from client.models import UserCode, Keys, DocumentType, Document, PersonalData, KeyVal, MedicalData +from client.models import HideGroup, UserCode, Keys, DocumentType, Document, PersonalData, KeyVal, MedicalData from django.db.models import Q from django.http import HttpResponseRedirect, FileResponse from django.contrib.auth.decorators import login_required @@ -130,6 +130,7 @@ def create(request): # remove from the list documents from already used types doctypes = DocumentType.objects.filter(filter).values_list("id", flat=True).difference(Document.objects.filter(Q(user=request.user) & ~Q(status="archive")).select_related("document_type").values_list("document_type", flat=True)) + doctypes = doctypes.difference(HideGroup.objects.filter(group__name__in=parent_groups).select_related("doc_type").values_list("doc_type", flat=True)) context['docs'] = DocumentType.objects.filter(id__in=doctypes) if request.method == "POST": |