1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- from health_view.models import *
- import health_view.views
- from health_view.crypto_functions import *
- import requests
- import json
-
-
- loginname_restapi = 'gabi'
- passwort_restapi = 'Lolo7138'
-
-
- def check_exp_date():
- licenses = License.objects.all()
- print("did it")
- for lic in licenses:
- if health_view.views.check_expiration_date(lic):
- continue
- filter_license_and_delete(lic)
-
-
- def filter_license_and_delete(lic):
- print(lic.justified)
- licenses_same_owner = License.objects.filter(justified=lic.justified, patient=lic.patient).exclude(id=lic.id)
- folderparts = lic.folder_parts.all().values_list()
- parts_to_delete = list()
- for part in folderparts:
- delete = True
- for license in licenses_same_owner:
- if not health_view.views.check_expiration_date(license):
- continue
- for check_part in license.folder_parts.all().values_list():
- if check_part == part:
- delete = False
- if delete is True:
- parts_to_delete.append(part[2])
- if not parts_to_delete:
- lic.delete()
- return
- new_total_key = make_encrypted_key_content_server()
- post_content = {
- 'patient': lic.patient.username,
- 'justified': lic.justified.username,
- 'new_total_key': new_total_key,
- 'old_total_key': lic.patient.folderinfo.content_key,
- 'folder_parts': parts_to_delete,
- }
- lic.patient.folderinfo.content_key = new_total_key
- lic.patient.folderinfo.save()
- lic.delete()
- request = requests.post('http://192.168.192.75:8000/manage/delete/', json=post_content, auth=(loginname_restapi, passwort_restapi))
- return
-
|