Skip to content

Commit

Permalink
update api for post request processing
Browse files Browse the repository at this point in the history
  • Loading branch information
4darsh-Dev committed Feb 13, 2024
1 parent 1326812 commit 8d8306f
Show file tree
Hide file tree
Showing 8 changed files with 2,847 additions and 534 deletions.
2 changes: 1 addition & 1 deletion api/cogniguard/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

urlpatterns = [
path('admin/', admin.site.urls),
path("logout/", RedirectView.as_view(url="/admin/logout/")),
# path("logout/", RedirectView.as_view(url="/admin/logout/")),
path("", include("home.urls")),
path("api/", include("mlApi.urls")),
]
4 changes: 3 additions & 1 deletion api/home/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
from django.urls import path,include
from home import views

from django.views.generic import RedirectView

urlpatterns = [
path("", views.index, name="home"),
path("faqs/", views.faqs, name="faqs"),
path("report-dp/", views.reportDp, name="report-dp"),
path("about/", views.about, name="about"),
path("terms-conditions/", views.termsConditions, name="terms-conditions"),
path("know-dp/", views.knowDp, name="knowDp"),

]


Expand Down
2 changes: 1 addition & 1 deletion api/home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def reportDp(request):
# On successful submission
success_msg = "Your response has been recorded successfully!"
messages.success(request, success_msg)
return render(request, "report.html", {error_msg: success_msg}) # Redirect to a success page or another URL
return render(request, "report.html", {"error_message": success_msg}) # Redirect to a success page or another URL

return render(request, "report.html")

8 changes: 6 additions & 2 deletions api/mlApi/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class MessageCreateView(generics.CreateAPIView):
http_method_names = ['post']



def tpScore(request):
tScore = transparencyCalc(request)
return JsonResponse({"transparency_score": tScore})
Expand All @@ -52,8 +51,13 @@ def dpData(url):

if existing_data:
# If the URL already exists, do nothing
return "Data already exists in the model"
# checking the result
print(dp_data)

dp_data = DarkPatternsData.objects.filter(website_url=url).values()
return JsonResponse({"message": "Data already exists for this URL","data": list(dp_data)})


else:
# Perform some operations
# For example, scrape data from the URL using get_scrape_data function
Expand Down
3,355 changes: 2,830 additions & 525 deletions api/sentences.csv

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions api/static/css/report.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
border-radius: 6px;
border: 1px solid gray;
padding: 0 6px;

}
::placeholder {
font-family: monospace;

}

4 changes: 1 addition & 3 deletions api/templates/report.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

{% load static %}



{% block title %}Report Dark Pattern{% endblock title %}

{% block head %}
<link rel="stylesheet" href="{% static " css/report.css"%}">
<link rel="stylesheet" href="{% static "css/report.css" %}">
{% endblock head %}

{% block content %}
Expand Down
3 changes: 2 additions & 1 deletion api/templates/termsConditions.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
{% block content %}

<p> Welcome to terms and conditions page!</p>




{% endblock %}

Expand Down

0 comments on commit 8d8306f

Please sign in to comment.