diff --git a/website/api/views.py b/website/api/views.py index 4006ad485..342e8749c 100644 --- a/website/api/views.py +++ b/website/api/views.py @@ -683,14 +683,6 @@ def create(self, request, *args, **kwargs): project_instance = serializer.save() project_instance.__setattr__("slug", slug) - # If the logo is not provided get the logo from the repo itself - if project_instance.logo == "": - logo = project_instance.get_github_logo_save_to_storage(project_instance.github_url) - if logo: - project_instance.logo = logo - - project_instance.save() - # Set contributors if contributors: project_instance.contributors.set(contributors) diff --git a/website/migrations/0100_remove_project_logo_project_logo_url.py b/website/migrations/0100_remove_project_logo_project_logo_url.py new file mode 100644 index 000000000..24fbc9450 --- /dev/null +++ b/website/migrations/0100_remove_project_logo_project_logo_url.py @@ -0,0 +1,22 @@ +# Generated by Django 5.0.7 on 2024-08-02 14:29 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("website", "0099_winner_prize_winner_prize_amount"), + ] + + operations = [ + migrations.RemoveField( + model_name="project", + name="logo", + ), + migrations.AddField( + model_name="project", + name="logo_url", + field=models.URLField(default=""), + preserve_default=False, + ), + ] diff --git a/website/models.py b/website/models.py index 58e970a00..26420e47d 100644 --- a/website/models.py +++ b/website/models.py @@ -701,7 +701,7 @@ class Project(models.Model): github_url = models.URLField() wiki_url = models.URLField(null=True, blank=True) homepage_url = models.URLField(null=True, blank=True) - logo = models.ImageField(upload_to="project_logos", null=True, blank=True) + logo_url = models.URLField() created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) contributors = models.ManyToManyField( @@ -711,18 +711,6 @@ class Project(models.Model): def __str__(self): return self.name - def get_github_logo_save_to_storage(self, url): - owner = url.split("/") - link = "https://avatars.githubusercontent.com/" + owner[-2] - github_logo = requests.get( - link - ) # the image there is of the owner so we will have this as the logo - if github_logo.status_code == 200: - file_name = f"{self.slug}.png" - self.logo.save(file_name, ContentFile(github_logo.content), save=False) - return self.logo - return None - def get_contributors(self, github_url): owner = github_url.split("/") url = "https://api.github.com/repos/" + owner[-2] + "/" + owner[-1] + "/contributors"