Digital Rights Management für elektronische Patientenakten
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

models.py 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from django.db import models
  2. from django.contrib.auth.models import User
  3. from django.dispatch import receiver
  4. from django.db.models.signals import post_save
  5. class FolderInfo(models.Model):
  6. """Adding attributes to default model user"""
  7. patient = models.OneToOneField(User, on_delete=models.CASCADE, null=True, blank=True, default="")
  8. pub_key = models.CharField(max_length=300, blank=True, default="")
  9. def __str__(self):
  10. """String for representing the Model object."""
  11. return str(self.id)
  12. @receiver(post_save, sender=User)
  13. def create_folderinfo(sender, instance, created, **kwargs):
  14. """Creates Folderinfo for user when he is created"""
  15. if created:
  16. FolderInfo.objects.create(patient=instance)
  17. class FolderPart_Name(models.Model):
  18. shortcut = models.CharField(max_length=3, default="x")
  19. part_name = models.CharField(max_length=40, primary_key=True, default="x")
  20. def __str__(self):
  21. """String for representing the Model object."""
  22. return str(self.part_name)
  23. class FolderPart(models.Model):
  24. part_class = models.ForeignKey(FolderPart_Name, on_delete=models.CASCADE, default="")
  25. folder_id = models.ForeignKey(FolderInfo, on_delete=models.CASCADE, default="")
  26. part_context = models.CharField(max_length=500, default="nothing for you")
  27. class Meta:
  28. unique_together = ('part_class', 'folder_id')
  29. def __str__(self):
  30. """String for representing the Model object."""
  31. return self.part_class.part_name
  32. class JustifiedKey(models.Model):
  33. part = models.ForeignKey(FolderPart, on_delete=models.CASCADE, null=True, default="")
  34. justified_name = models.ForeignKey(User, on_delete=models.CASCADE, default="")
  35. key = models.CharField(max_length=260, default="")