diff --git a/myproject/myapp/templates/_base.html b/myproject/myapp/templates/_base.html index c7cc36d4c38097ecd5f55efe699670f5a1234528..c9ba99447417747816a0cae5ea852a483fb51abb 100644 --- a/myproject/myapp/templates/_base.html +++ b/myproject/myapp/templates/_base.html @@ -56,34 +56,46 @@ >Home</a > </li> + + {% if user.is_authenticated %} <li> <a - href="{% url 'user_login' %}" + href="{% url 'pricing' %}" class="block py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent" - >Login</a + >Pricing</a > </li> <li> <a - href="{% url 'register' %}" + href="{% url 'users' %}" class="block py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent" - >Register</a + >Dashboard</a > </li> + <li> <a - href="{% url 'pricing' %}" + href="#" class="block py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent" - >Pricing</a + >Logout</a > </li> + {% else %} <li> <a - href="{% url 'users' %}" + href="{% url 'user_login' %}" class="block py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent" - >Dashboard</a + >Login</a + > + </li> + <li> + <a + href="{% url 'register' %}" + class="block py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent" + >Register</a > </li> + {% endif %} </ul> </div> </div> diff --git a/myproject/myapp/templates/index2.html b/myproject/myapp/templates/index2.html index 7cf84cd548c3d740ac54daec2b96a4fb952fd440..443f7f2facfa2d50b4caa32a95239ded042cfbad 100644 --- a/myproject/myapp/templates/index2.html +++ b/myproject/myapp/templates/index2.html @@ -24,7 +24,7 @@ </h2> <p class="mb-8 font-light text-gray-500 lg:mb-16 sm:text-xl dark:text-gray-400"> <a href="{% url 'register' %}" class="inline-flex items-center font-medium text-primary-600 hover:text-primary-800 dark:text-primary-500 dark:hover:text-primary-700">Sign up</a> - or <a href="{% url 'login' %}" class="inline-flex items-center font-medium text-primary-600 hover:text-primary-800 dark:text-primary-500 dark:hover:text-primary-700">Login!</a> + or <a href="{% url 'user_login' %}" class="inline-flex items-center font-medium text-primary-600 hover:text-primary-800 dark:text-primary-500 dark:hover:text-primary-700">Login!</a> Choose one of our exceptionally well priced payment offers and enjoy our service to it's fullest! </p> </div> diff --git a/myproject/myapp/urls.py b/myproject/myapp/urls.py index 304d04754e37a9ff8a612df67e74b5cda123ecac..a900d2ed46d91ad662e40957d66d97cda47105e8 100644 --- a/myproject/myapp/urls.py +++ b/myproject/myapp/urls.py @@ -22,5 +22,6 @@ urlpatterns = [ path('admin_table/', admin_table, name='admin_table'), path('instrument_detection/', InstrumentDetectionView.as_view(), name='instrument_detection'), path('password_change/', auth_views.PasswordChangeView.as_view(template_name='password_change_form.html'), name='password_change'), - path('password_change/done/', auth_views.PasswordChangeDoneView.as_view(template_name='password_change_done.html'), name='password_change_done') + path('password_change/done/', auth_views.PasswordChangeDoneView.as_view(template_name='password_change_done.html'), name='password_change_done'), + path('logout/', auth_views.LogoutView.as_view(next_page=index), name='logout') ] diff --git a/myproject/myapp/views.py b/myproject/myapp/views.py index b90b29a1e030d1559ec66b614a9ebbb4cbe8ae02..f4b3cd10c0849f4b727bc9bf7fa626a257d8922e 100644 --- a/myproject/myapp/views.py +++ b/myproject/myapp/views.py @@ -104,18 +104,6 @@ def index(request): # Handle authenticated users if request.user.is_authenticated: - if request.method == 'POST': - # Assuming you want to do something specific with the file if it's uploaded - uploaded_file = request.FILES.get('audio_file') - if uploaded_file: - # Process the uploaded file as needed - pass - # For now, just render the main page again, potentially after handling the uploaded file - # For GET requests or if POST doesn't involve a file, just show the main page - return render(request, 'index1.html') - - # Handle unauthenticated users - else: if request.method == 'POST': form = InstrumentDetectionForm(request.POST, request.FILES) if form.is_valid() and 'audio_file' in request.FILES: @@ -130,7 +118,22 @@ def index(request): else: context['form'] = form # For GET requests or if form is not valid, render the page with the default or updated context - return render(request, 'index1.html', context) + return render(request, 'index1.html', context) + + # Handle unauthenticated users + else: + if request.method == 'POST': + # Assuming you want to do something specific with the file if it's uploaded + uploaded_file = request.FILES.get('audio_file') + if uploaded_file: + # Process the uploaded file as needed + pass + # For now, just render the main page again, potentially after handling the uploaded file + # For GET requests or if POST doesn't involve a file, just show the main page + return render(request, 'index2.html') + + + def users(request): @@ -270,3 +273,11 @@ class InstrumentDetectionView(APIView): formatted_scores = "<br>".join([f"{instruments[i]} - {score:.2f}" for i, score in enumerate(prediction)]) formatted_predictions.append(f"{formatted_window}{formatted_scores}") return formatted_predictions + + +def user_has_credits(): + has_credits = False + + + + return has_credits \ No newline at end of file