Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trademark Search API #1858

Merged
merged 13 commits into from
Mar 1, 2024
4 changes: 4 additions & 0 deletions blt/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,3 +519,7 @@
APP_KEY_SECRET = os.environ.get("APP_KEY_SECRET")
ACCESS_TOKEN = os.environ.get("ACCESS_TOKEN")
ACCESS_TOKEN_SECRET = os.environ.get("ACCESS_TOKEN_SECRET")

# USPTO

USPTO_API = os.environ.get("USPTO_API")
7 changes: 6 additions & 1 deletion blt/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@
re_path(r"^projects/$", TemplateView.as_view(template_name="projects.html"), name="projects"),
re_path(r"^apps/$", TemplateView.as_view(template_name="apps.html"), name="apps"),
re_path(r"^deletions/$", TemplateView.as_view(template_name="deletions.html"), name="deletions"),
re_path(r"^trademarks/$", TemplateView.as_view(template_name="trademarks.html"), name="trademarks"),
re_path(r"^bacon/$", TemplateView.as_view(template_name="bacon.html"), name="bacon"),
re_path(r"^bltv/$", TemplateView.as_view(template_name="bltv.html"), name="bltv"),
re_path(r"^privacypolicy/$", TemplateView.as_view(template_name="privacy.html"), name="privacy"),
Expand Down Expand Up @@ -416,6 +415,12 @@
path("company/", include("company.urls")),
path("sponsor/", website.views.sponsor_view, name="sponsor"),
path("companies/", DomainListView.as_view(), name="domain_lists"),
path("trademarks/", website.views.trademark_search, name="trademark_search"),
re_path(
r"^trademarks/query=(?P<slug>[\w\s]+)",
website.views.trademark_detailview,
name="trademark_detailview",
),
]

if settings.DEBUG:
Expand Down
Binary file added website/static/img/TM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/static/img/tm-search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion website/templates/includes/sidenav.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<div class="w-8 mr-4">
<i class="fa fa-trademark" id="icon"></i>
</div>
<a href="{% url 'trademarks' %}"><span class="text">Trademarks</span></a>
<a href="{% url 'trademark_search' %}"><span class="text">Trademarks</span></a>
</li>
<li class="flex items-center p-2">
<div class="w-8 mr-4">
Expand Down
139 changes: 139 additions & 0 deletions website/templates/trademark_detailview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{% extends "base.html" %}
{% load static %}
{% block content %}
{% include "includes/sidenav.html" %}
<style>
.table-auto{
margin-right:70px ;
}
.status_label {
border-radius: 30px;
text-align: center;
color: white;
}
.type_label{
color: blueviolet;
}
.tm-wrapper{
position: relative;
left : 350px;
top : 80px;
height: 470px;
width: 500px;
background-color: #FFFFFF;
border-radius: 30px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
font-weight: 400;
font-style: normal;
}
#tm-logo{
height: 175px;
width: 196px;
position: absolute;
left: 152px;
top: 71px;
}
.tm-wrapper p{
position: absolute;
left: 194px;
top: 252px;
font-size: 30px;
font-weight: 1000;
}
#tm-text{
position: absolute;
left: 88px;
top: 313px;
font-size: 20px;
opacity: 80%;
text-align: center;
}
#back-button{
background-color: #FF9191;
height: 70px;
width: 250px;
border-radius: 0px 0px 0px 30px;
position: absolute;
left: 0px;
top: 400px;
font-weight: 1000;
}
#more-button{
background-color: #D92D2D;
height: 70px;
width: 250px;
border-radius: 0px 0px 30px 0px;
position: absolute;
right: 0px;
top: 400px;
font-weight: 1000;
}

</style>
{% if available %}
<div class="tm-wrapper">
<img id="tm-logo"
height="175px"
width="196px"
alt="Trademark available Image"
src="{% static 'img/TM.png' %}">
<p>Available !</p>
<div id="tm-text">Trademark is available for Registration</div>
<button id="back-button">
<a href="{% url 'index' %}">Back</a>
</button>
<button id="more-button">
<a href="{% url 'trademark_search' %}">Search More</a>
</button>
</div>
{% else %}
<p class="text-gray-300 my-6 font-satoshi font-bold text-[25px]">{{ count }} results found for {{ query }}</p>
<table class="table-auto border-collapse w-full">
<thead class="font-bold italic text-opacity-25 bg-gray-200">
<tr>
<th class="px-4 py-2">Name</th>
<th class="px-4 py-2">Registration No</th>
<th class="px-4 py-2">Serial No</th>
<th class="px-4 py-2">Filing Date</th>
<th class="px-4 py-2">Registration Date</th>
<th class="px-4 py-2">Expiry Date</th>
<th class="px-4 py-2">Owner Label</th>
<th class="px-4 py-2">Owner Name</th>
<th class="px-4 py-2">Owner Address</th>
<th class="px-4 py-2">Labels</th>
</tr>
</thead>
<tbody>
{% for item in items %}
{% for owner in item.owners %}
<tr class="border">
<td class="px-4 py-2 font-bold ">{{ item.keyword }}</td>
<td class="px-4 py-2">{{ item.registration_number }}</td>
<td class="px-4 py-2">{{ item.serial_number }}</td>
<td class="px-4 py-2 min-h-2">{{ item.filing_date }}</td>
<td class="px-4 py-2">{{ item.registration_date }}</td>
<td class="px-4 py-2">{{ item.expiration_date }}</td>
<td class="px-4 py-2">{{ owner.owner_label }}</td>
<td class="px-4 py-2">{{ owner.name }}</td>
<td class="px-4 py-2">
{{ owner.address1 }}
{{ owner.address2 }},
{{ owner.city }},
{{ owner.state }},
{{ owner.country }},
{{ owner.postcode }}
</td>
<td class="px-4 py-2">
<div class="status_label {% if item.status_label == 'Live/Pending' %} bg-yellow-600 {% elif item.status_label == 'Live/Registered' %} bg-green-600 {% elif item.status_label == 'Dead/Abandoned' %} bg-red-600 {% else %} bg-sky-600 {% endif %} ">
{{ item.status_label }}
</div>
<br>
<div class="type_label">{{ owner.legal_entity_type_label }}</div>
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
{% endif %}
{% endblock content %}
107 changes: 107 additions & 0 deletions website/templates/trademark_search.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{% extends "base.html" %}
{% load static %}
{% block title %}
trademarks
{% endblock title %}
{% block content %}
{% include "includes/sidenav.html" %}
<style>
#query{
position: relative;
top: 40px;
left: 172px;
background-color: #E4E4E4;
border-style: outset;
border-radius: 40px;
width: 659px;
height: 44px;
}
.search_input{
width: 100%;
padding: 10px;
border-radius: 5px;
font-size: 16px;
}
.search_input:focus{
outline: none;
border-color: #f2f2f2; /* Change border color on focus */
}
#search_button{
width: 231px;
height: 53px;
background-color: #FF4D4D;
position: relative;
border-radius: 30px;
top: 118px;
right: 260px;
font-size: medium;
font-weight: bold;
color: #f2f2f2;
}
#search_button:hover{
outline: none;
border-color: #f2f2f2; /* Change border color on focus */
box-shadow: 0 0 5px #e93232; /* Add a shadow on focus */
}

.trademark-logo{
position: relative;
margin-top: 100px;
left: 184px;
top: 37px;
width: 663px;
height: 185px;
}
.tm-wrapper{
position: relative;
left: 181px;
top: 0px;
height: 446px;
width: 961px;
background-color: #FFFFFF;
border-radius: 30px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
font-weight: 200;
font-style: normal;
}
.tm-wrapper p{
font-size: 13px;
position: absolute;
left: 292px;
top: 374px;
opacity: 60%;
}

</style>
<div class="tm-wrapper">
<img class="trademark-logo"
alt="Trademark Search Image"
height="185px"
width="663px"
src="{% static 'img/tm-search.png' %}">
<form method="post" class="search-container" role="search" id="form">
{% csrf_token %}
<input class="search_input"
type="search"
id="query"
name="query"
placeholder="Search...">
<button id="search_button" type="submit">Search</button>
</form>
<p>This data is fetched from United States Patent and Trademark Office</p>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
var form = document.getElementById('form');
var searchInput = document.getElementById('query'); // Corrected ID
var searchButton = document.getElementById('search_button');

form.addEventListener('submit', function(event) {
if (searchInput.value.trim() === '') {
event.preventDefault(); // Prevent the form from submitting
}
});
});

</script>
{% endblock content %}
1 change: 0 additions & 1 deletion website/templates/trademarks.html

This file was deleted.

33 changes: 33 additions & 0 deletions website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3711,6 +3711,39 @@ def invite_friend(request):
}
return render(request, "invite_friend.html", context)

def trademark_search(request, **kwargs):
if request.method == "POST":
slug = request.POST.get("query")
return redirect("trademark_detailview", slug=slug)
return render(request, "trademark_search.html")


def trademark_detailview(request, slug):
if settings.USPTO_API is None:
return HttpResponse("API KEY NOT SETUP")

trademark_available_url = "https://uspto-trademark.p.rapidapi.com/v1/trademarkAvailable/%s" % (
slug
)
headers = {
"x-rapidapi-host": "uspto-trademark.p.rapidapi.com",
"x-rapidapi-key": settings.USPTO_API,
}
trademark_available_response = requests.get(trademark_available_url, headers=headers)
ta_data = trademark_available_response.json()

if ta_data[0]["available"] == "no":
trademark_search_url = (
"https://uspto-trademark.p.rapidapi.com/v1/trademarkSearch/%s/active" % (slug)
)
trademark_search_response = requests.get(trademark_search_url, headers=headers)
ts_data = trademark_search_response.json()
context = {"count": ts_data["count"], "items": ts_data["items"], "query": slug}

else:
context = {"available": ta_data[0]["available"]}

return render(request, "trademark_detailview.html", context)

# class CreateIssue(CronJobBase):
# RUN_EVERY_MINS = 1
Expand Down
Loading