Skip to content

Commit

Permalink
Remove ColorThief and related color generation functionality
Browse files Browse the repository at this point in the history
This commit removes the ColorThief dependency and the associated color generation method from the Domain model. The changes include:
- Removing ColorThief from pyproject.toml dependencies
- Deleting the get_color method in the Domain model
- Updating the search.html template to remove the domain color display
  • Loading branch information
DonnieBLT committed Jan 28, 2025
1 parent 52ad502 commit 8e4eee1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 50 deletions.
29 changes: 1 addition & 28 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ license = "AGPLv3"
[tool.poetry.dependencies]
python = "3.11.2"
python-dotenv = "^1.0.1"
toml = "^0.10.2"
Django = "^5.1.5"
dj-database-url = "^2.3.0"
django-allauth = "^0.61.1"
beautifulsoup4 = "^4.12.3"
colorthief = "^0.2.1"
django-email-obfuscator = "^0.1.5"
django-gravatar2 = "^1.4.5"
django-import-export = "^4.3.4"
Expand All @@ -36,7 +34,6 @@ python-openid = "^2.2.5"
pytz = "^2024.1"
requests = "^2.32.3"
requests-oauthlib = "^1.3.1"
six = "^1.16.0"
tablib = "^3.8.0"
ua-parser = "^1.0.0"
djangorestframework = "^3.15.2"
Expand Down
22 changes: 5 additions & 17 deletions website/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import requests
from annoying.fields import AutoOneToOneField
from captcha.fields import CaptchaField
from colorthief import ColorThief
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
Expand Down Expand Up @@ -208,21 +207,6 @@ def get_logo(self):
favicon_url = self.url + "/favicon.ico"
return favicon_url

@property
def get_color(self):
if self.color:
return self.color
else:
if not self.logo:
self.get_logo()
try:
color_thief = ColorThief(self.logo)
self.color = "#%02x%02x%02x" % color_thief.get_color(quality=1)
except:
self.color = "#0000ff"
self.save()
return self.color

@property
def hostname_domain(self):
parsed_url = urlparse(self.url)
Expand Down Expand Up @@ -288,7 +272,11 @@ class Trademark(models.Model):
description = models.TextField(blank=True, null=True)
owners = models.ManyToManyField(TrademarkOwner, related_name="trademarks")
organization = models.ForeignKey(
Organization, null=True, blank=True, on_delete=models.CASCADE, related_name="trademarks"
Organization,
null=True,
blank=True,
on_delete=models.CASCADE,
related_name="trademarks",
)

def __str__(self):
Expand Down
3 changes: 1 addition & 2 deletions website/templates/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ <h2 class="text-4xl font-bold text-gray-800">
<div class="mt-4 ml-4">
<div class="flex items-center space-x-2">
<span class="text-md font-semibold">Domain Color:</span>
<div class="w-6 h-6 rounded-full border border-gray-300"
style="background-color: {{ domain.get_color }}"></div>
<div class="w-6 h-6 rounded-full border border-gray-300"></div>
</div>
</div>
</div>
Expand Down

0 comments on commit 8e4eee1

Please sign in to comment.