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.

cron.py 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. from health_view.models import *
  2. import health_view.views
  3. from health_view.crypto_functions import *
  4. import requests
  5. import json
  6. loginname_restapi = 'gabi'
  7. passwort_restapi = 'Lolo7138'
  8. def check_exp_date():
  9. licenses = License.objects.all()
  10. print("did it")
  11. for lic in licenses:
  12. if health_view.views.check_expiration_date(lic):
  13. continue
  14. filter_license_and_delete(lic)
  15. def filter_license_and_delete(lic):
  16. print(lic.justified)
  17. licenses_same_owner = License.objects.filter(justified=lic.justified, patient=lic.patient).exclude(id=lic.id)
  18. folderparts = lic.folder_parts.all().values_list()
  19. parts_to_delete = list()
  20. for part in folderparts:
  21. delete = True
  22. for license in licenses_same_owner:
  23. if not health_view.views.check_expiration_date(license):
  24. continue
  25. for check_part in license.folder_parts.all().values_list():
  26. if check_part == part:
  27. delete = False
  28. if delete is True:
  29. parts_to_delete.append(part[2])
  30. if not parts_to_delete:
  31. lic.delete()
  32. return
  33. new_total_key = make_encrypted_key_content_server()
  34. post_content = {
  35. 'patient': lic.patient.username,
  36. 'justified': lic.justified.username,
  37. 'new_total_key': new_total_key,
  38. 'old_total_key': lic.patient.folderinfo.content_key,
  39. 'folder_parts': parts_to_delete,
  40. }
  41. lic.patient.folderinfo.content_key = new_total_key
  42. lic.patient.folderinfo.save()
  43. lic.delete()
  44. request = requests.post('http://192.168.192.75:8000/manage/delete/', json=post_content, auth=(loginname_restapi, passwort_restapi))
  45. return