diff --git a/myproject/Dockerfile b/myproject/Dockerfile index df224fd4642531451d3ac39cce7c01c76ba2a682..4cbaea85267235eca29698c99a7118a1b3b7d238 100644 --- a/myproject/Dockerfile +++ b/myproject/Dockerfile @@ -50,3 +50,4 @@ RUN python manage.py collectstatic --noinput COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh + diff --git a/myproject/debug.log b/myproject/debug.log index 421ec9ac1d067eede71ab39bffb1425409eb0a17..3e46aa6baf526c0043882a227bff4b43e19dacfa 100644 --- a/myproject/debug.log +++ b/myproject/debug.log @@ -1158,3 +1158,6 @@ Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/django/template/base.py", line 555, in invalid_block_tag raise self.error( django.template.exceptions.TemplateSyntaxError: Invalid block tag on line 262: 'endblock', expected 'elif', 'else' or 'endif'. Did you forget to register or load this tag? +Watching for file changes with StatReloader +Not Found: /favicon.ico +Watching for file changes with StatReloader diff --git a/myproject/docker-compose.yml b/myproject/docker-compose.yml index f7530257616880e6d6b942cdc11bea8572e5829a..cbfb0f2593a106dc407dfbdb3693a716d18d82c9 100644 --- a/myproject/docker-compose.yml +++ b/myproject/docker-compose.yml @@ -41,8 +41,6 @@ services: tensorflow_serving: image: tensorflow/serving - ports: - - "8501:8501" volumes: - ./models:/models environment: diff --git a/myproject/entrypoint.sh b/myproject/entrypoint.sh index e882418b2b601205cd56943e47d2b40e728ddc55..40cb5fee645e054045827ef695e8d1709e2f4d3a 100644 --- a/myproject/entrypoint.sh +++ b/myproject/entrypoint.sh @@ -6,5 +6,6 @@ python manage.py makemigrations echo "Applying migrations" python manage.py migrate +python manage.py make_users python manage.py runserver 0.0.0.0:8000 \ No newline at end of file diff --git a/myproject/myapp/management/commands/__init__.py b/myproject/myapp/management/commands/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..203562bfa077a16fadd91e30a5a288cbf09feb6f --- /dev/null +++ b/myproject/myapp/management/commands/__init__.py @@ -0,0 +1 @@ +# __init__.py \ No newline at end of file diff --git a/myproject/myapp/management/commands/make_users.py b/myproject/myapp/management/commands/make_users.py new file mode 100644 index 0000000000000000000000000000000000000000..8ab8b98cff9bf462822d7a2a5e7501d81ddbfaf0 --- /dev/null +++ b/myproject/myapp/management/commands/make_users.py @@ -0,0 +1,22 @@ +# app/management/commands/create_users.py +from django.core.management.base import BaseCommand +from django.contrib.auth.hashers import make_password +from django.contrib.auth import get_user_model + +class Command(BaseCommand): + def handle(self, *args, **options): + Profile = get_user_model() + if not Profile.objects.filter(username="superuser").exists(): + Profile.objects.create_superuser("superuser", password="placeholder") + + if not Profile.objects.filter(username="admin").exists(): + Profile.objects.create_user("admin", password="placeholder") + + if not Profile.objects.filter(username="base_user").exists(): + Profile.objects.create_user("base_user", password="placeholder") + + if not Profile.objects.filter(username="ml_engineer").exists(): + Profile.objects.create_user("ml_engineer", password="placeholder") + + if not Profile.objects.filter(username="accountant").exists(): + Profile.objects.create_user("accountant", password="placeholder") \ No newline at end of file diff --git a/myproject/myapp/views.py b/myproject/myapp/views.py index b42e991bb1ee45c467616ea2ca3a360a4d405d24..ed4c7d9b3753121ba80244da0635f48d0a33846d 100644 --- a/myproject/myapp/views.py +++ b/myproject/myapp/views.py @@ -262,6 +262,17 @@ def generate_pdf(request): # Running the audio file through the model class InstrumentDetectionView(APIView): def post(self, request): + # Get the user's token count + user_token_count = UserTokenCount.objects.get(user=request.user) + + # Check if the user has more than one token + if user_token_count.token_count < 1: + return Response({'error': 'Insufficient tokens'}, status=status.HTTP_403_FORBIDDEN) + + # Decrease the user's token count by one + user_token_count.token_count -= 1 + user_token_count.save() + serializer = InstrumentDetectionSerializer(data=request.data) if serializer.is_valid(): audio_file = serializer.validated_data['audio_file']