Skip to content

Commit

Permalink
Gebruikers zullen nu standaard 2 templates krijgen
Browse files Browse the repository at this point in the history
  • Loading branch information
LGDTimtou committed May 21, 2024
1 parent 441bc87 commit 734c285
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
12 changes: 12 additions & 0 deletions api/base_templates/file_name.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

#@param
# Vul hieronder de namen van de bestanden in die je in de gezipte folder wilt vinden.
file_name="verslag.pdf"


if [ -e "$file_name" ]; then
echo "$file_name present: OK"
else
echo "$file_name not present: FAIL"
fi
20 changes: 20 additions & 0 deletions api/base_templates/zip_contains_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

#@param
# Vul hieronder de namen van de bestanden in die je in de gezipte folder wilt vinden.
file_names=( "testfile1.txt" "testfile2.txt" )

#@param
# Vul hieronder de naam van het zip bestand waarin je de files wil vinden
zip_file_name="file.zip"


for file_name in "${file_names[@]}"; do
unzip -l $zip_file_name | grep -q $file_name;
if [ "$?" == "0" ]
then
echo "$file_name present: OK"
else
echo "$file_name not present: FAIL"
fi;
done
16 changes: 16 additions & 0 deletions api/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from django.contrib.auth.models import User
from api.models.gebruiker import Gebruiker
from api.serializers.gebruiker import GebruikerSerializer
from api.serializers.template import TemplateSerializer
from django.core.files import File
import requests
import os

URL = "https://graph.microsoft.com/v1.0/me"

Expand Down Expand Up @@ -59,6 +62,19 @@ def __call__(self, request):
try:
Gebruiker.objects.get(pk=request.user.id)
except Gebruiker.DoesNotExist:
directory_path = 'api/base_templates'
for filename in os.listdir(directory_path):
file_path = os.path.join(directory_path, filename)
with open(file_path, 'rb') as f:
django_file = File(f)
template_data = {
"user": request.user.id,
"bestand": django_file
}
serializer = TemplateSerializer(data=template_data)
if serializer.is_valid():
serializer.save()

gebruiker_post_data = {
"user": request.user.id,
"subjects": [],
Expand Down

0 comments on commit 734c285

Please sign in to comment.