diff --git a/bullet/bullet_admin/forms/content.py b/bullet/bullet_admin/forms/content.py index e03ebd77..447b8161 100644 --- a/bullet/bullet_admin/forms/content.py +++ b/bullet/bullet_admin/forms/content.py @@ -5,7 +5,7 @@ from django.utils.translation import get_language_info from django_countries import countries from django_countries.fields import Country -from web.models import ContentBlock, Logo, Menu, Page, PageBlock +from web.models import ContentBlock, Menu, Page, PageBlock class PageForm(forms.ModelForm): @@ -156,33 +156,6 @@ def clean(self): return cleaned_data -class LogoForm(forms.ModelForm): - class Meta: - model = Logo - fields = ("type", "name", "url", "image", "countries") - - widgets = { - "countries": forms.CheckboxSelectMultiple(), - } - - def __init__(self, branch: Branch, **kwargs): - super().__init__(**kwargs) - available_countries = set() - - for country in BranchCountry.objects.filter(branch=branch).all(): - available_countries.add(country.country.code) - - self.fields["countries"].choices = list( - sorted( - filter( - lambda x: x[0] in available_countries, - self.fields["countries"].choices, - ), - key=lambda x: x[1], - ) - ) - - class MenuItemForm(forms.ModelForm): class Meta: model = Menu diff --git a/bullet/bullet_admin/templates/bullet_admin/content/logo_form.html b/bullet/bullet_admin/templates/bullet_admin/content/logo_form.html deleted file mode 100644 index df20b44f..00000000 --- a/bullet/bullet_admin/templates/bullet_admin/content/logo_form.html +++ /dev/null @@ -1,45 +0,0 @@ -{% extends "bullet_admin/base.html" %} -{% load bform %} -{% load static %} -{% block title %} - {% if not object %} - Create - {% else %} - Edit - {% endif %} - logo -{% endblock title %} -{% block content %} -
-
-

- {% if not object %} - Create - {% else %} - Edit - {% endif %} - logo -

-
-
- {% csrf_token %} - {% bformv form %} - -
- {% if object %} -
-
- {% csrf_token %} - -
- {% endif %} -
-{% endblock content %} diff --git a/bullet/bullet_admin/templates/bullet_admin/content/logo_list.html b/bullet/bullet_admin/templates/bullet_admin/content/logo_list.html deleted file mode 100644 index 07cb77cf..00000000 --- a/bullet/bullet_admin/templates/bullet_admin/content/logo_list.html +++ /dev/null @@ -1,56 +0,0 @@ -{% extends "bullet_admin/base.html" %} -{% block title %} - Logo list -{% endblock title %} -{% block content %} -
-
-

Logo list

- New logo -
-
-
-

- These logos are currently not used anywhere. You should now use the "Logo cloud" block on your homepage. This page will be removed from the admin in the upcoming releases. -

-
- - - - - - - - - - - {% for logo in object_list %} - - - - - - - {% endfor %} - -
NameImageCountries
-
-

{{ logo.name }}

- {{ logo.url }} -
-
- {{ logo.name }} - {{ logo.countries|join:", " }} - - Edit - -
-
-
-{% endblock content %} diff --git a/bullet/bullet_admin/templatetags/badmin.py b/bullet/bullet_admin/templatetags/badmin.py index b446e371..96441098 100644 --- a/bullet/bullet_admin/templatetags/badmin.py +++ b/bullet/bullet_admin/templatetags/badmin.py @@ -69,7 +69,6 @@ def admin_sidebar(context): ( ("fa-file-text", "Pages", reverse("badmin:page_list")), ("fa-cube", "Blocks", reverse("badmin:contentblock_list")), - ("fa-handshake", "Logos", reverse("badmin:logo_list")), ("fa-bars", "Menu items", reverse("badmin:menu_list")), ("fa-folder", "File browser", reverse("badmin:file_tree")), ), diff --git a/bullet/bullet_admin/urls/__init__.py b/bullet/bullet_admin/urls/__init__.py index fc785f31..cdad3925 100644 --- a/bullet/bullet_admin/urls/__init__.py +++ b/bullet/bullet_admin/urls/__init__.py @@ -135,26 +135,6 @@ content.ContentBlockDeleteView.as_view(), name="contentblock_delete", ), - path( - "content/logos/", - content.LogoListView.as_view(), - name="logo_list", - ), - path( - "content/logos/edit//", - content.LogoEditView.as_view(), - name="logo_edit", - ), - path( - "content/logos/create/", - content.LogoCreateView.as_view(), - name="logo_create", - ), - path( - "content/logos/delete//", - content.LogoDeleteView.as_view(), - name="logo_delete", - ), path( "content/menu/", content.MenuItemListView.as_view(), diff --git a/bullet/bullet_admin/views/content.py b/bullet/bullet_admin/views/content.py index f5e0999b..069293f1 100644 --- a/bullet/bullet_admin/views/content.py +++ b/bullet/bullet_admin/views/content.py @@ -6,13 +6,12 @@ from django.urls import reverse, reverse_lazy from django.utils.functional import cached_property from django.views.generic import CreateView, DeleteView, FormView, ListView, UpdateView -from web.models import ContentBlock, Logo, Menu, Page, PageBlock +from web.models import ContentBlock, Menu, Page, PageBlock from bullet.views import FormAndFormsetMixin from bullet_admin.forms.content import ( ContentBlockForm, ContentBlockWithRefForm, - LogoForm, MenuItemForm, PageBlockCreateForm, PageBlockUpdateForm, @@ -371,57 +370,6 @@ def form_valid(self, form): ) -class LogoListView(TranslatorRequiredMixin, ListView): - template_name = "bullet_admin/content/logo_list.html" - - def get_queryset(self): - return Logo.objects.filter(branch=self.request.BRANCH) - - -class LogoEditView(TranslatorRequiredMixin, UpdateView): - template_name = "bullet_admin/content/logo_form.html" - form_class = LogoForm - - def get_form_kwargs(self): - kw = super().get_form_kwargs() - kw["branch"] = self.request.BRANCH - return kw - - def get_queryset(self): - return Logo.objects.filter(branch=self.request.BRANCH) - - def get_success_url(self): - return reverse("badmin:logo_list") - - -class LogoCreateView(TranslatorRequiredMixin, CreateView): - template_name = "bullet_admin/content/logo_form.html" - form_class = LogoForm - - def get_form_kwargs(self): - kw = super().get_form_kwargs() - kw["branch"] = self.request.BRANCH - return kw - - def get_success_url(self): - return reverse("badmin:logo_list") - - def form_valid(self, form): - obj = form.save(commit=False) - obj.branch = self.request.BRANCH.id - obj.save() - - return HttpResponseRedirect(reverse("badmin:logo_list")) - - -class LogoDeleteView(TranslatorRequiredMixin, BDeleteView): - def get_queryset(self): - return Logo.objects.filter(branch=self.request.BRANCH) - - def get_success_url(self): - return reverse("badmin:logo_list") - - class MenuItemListView(TranslatorRequiredMixin, GenericList, ListView): create_url = reverse_lazy("badmin:menu_create") fields = ["title", "url", "order", "language", "countries"] diff --git a/bullet/competitions/management/commands/generatedata.py b/bullet/competitions/management/commands/generatedata.py index 4359ad6f..a59fc88a 100644 --- a/bullet/competitions/management/commands/generatedata.py +++ b/bullet/competitions/management/commands/generatedata.py @@ -10,7 +10,7 @@ from education.factories.generate import create_education from problems.factories.generate import create_problems from users.factories.generate import create_users -from web.factories.generate import create_pages, create_partners +from web.factories.generate import create_pages from bullet import search @@ -35,6 +35,5 @@ def handle(self, *args, **options): ) create_problems(competition_physics) - create_partners() create_users(competition_physics) management.call_command("indexschools") diff --git a/bullet/web/admin.py b/bullet/web/admin.py index 3172143d..997e40f3 100644 --- a/bullet/web/admin.py +++ b/bullet/web/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from web.models import ContentBlock, Logo, Menu, Page, PageBlock +from web.models import ContentBlock, Menu, Page, PageBlock admin.site.site_title = "Bullet system administration" admin.site.site_header = "Bullet system administration" @@ -12,12 +12,6 @@ class PageAdmin(admin.ModelAdmin): list_filter = ["branch", "language", "slug"] -@admin.register(Logo) -class LogoAdmin(admin.ModelAdmin): - list_display = ["branch", "type", "name", "countries"] - list_filter = ["branch", "type"] - - @admin.register(Menu) class MenuAdmin(admin.ModelAdmin): list_display = ["title", "branch", "language", "countries", "url", "order"] diff --git a/bullet/web/factories/generate.py b/bullet/web/factories/generate.py index 8bab263f..998d689b 100644 --- a/bullet/web/factories/generate.py +++ b/bullet/web/factories/generate.py @@ -3,7 +3,6 @@ from django.db.models import QuerySet from web.factories.menu import MenuFactory from web.factories.pages import PageFactory -from web.factories.partners import LogoFactory def create_pages(branch: Branch): @@ -39,7 +38,3 @@ def create_pages(branch: Branch): countries=countries, external=True, ) - - -def create_partners(): - LogoFactory.create_batch(50) diff --git a/bullet/web/factories/partners.py b/bullet/web/factories/partners.py deleted file mode 100644 index 76d5a77c..00000000 --- a/bullet/web/factories/partners.py +++ /dev/null @@ -1,38 +0,0 @@ -import factory -from competitions.branches import Branches -from django.core.files.base import ContentFile -from django_countries import countries -from factory.django import DjangoModelFactory, ImageField -from web.models import Logo - - -class RandomImage(ImageField): - def _make_content(self, params): - data = self._make_data(params) - content = ContentFile(data) - filename = f"{params.get('filename')}.{params.get('format')}" - return filename, content - - -class LogoFactory(DjangoModelFactory): - class Meta: - model = Logo - - branch = factory.Faker( - "random_element", elements=[x[0] for x in Branches.choices()] - ) - type = factory.Faker("random_element", elements=Logo.Type.values) - countries = factory.Faker( - "random_elements", - elements=[x.code for x in countries], - unique=True, - ) - name = factory.Faker("word") - url = factory.Faker("url") - image = RandomImage( - color=factory.Faker("color"), - format=factory.Faker("random_element", elements=["jpeg", "png", "bmp", "gif"]), - height=factory.Faker("random_number", digits=3, fix_len=True), - width=factory.Faker("random_number", digits=3, fix_len=True), - filename=factory.SelfAttribute("..name"), - ) diff --git a/bullet/web/migrations/0019_logo_delete_organizer_delete_partner.py b/bullet/web/migrations/0019_logo_delete_organizer_delete_partner.py index afdae98b..3d1e5e09 100644 --- a/bullet/web/migrations/0019_logo_delete_organizer_delete_partner.py +++ b/bullet/web/migrations/0019_logo_delete_organizer_delete_partner.py @@ -42,7 +42,7 @@ class Migration(migrations.Migration): ), ("name", models.CharField(max_length=128)), ("url", models.CharField(max_length=128)), - ("image", models.FileField(upload_to=web.models.logo_upload_path)), + ("image", models.FileField()), ( "countries", web.fields.ChoiceArrayField( diff --git a/bullet/web/migrations/0024_delete_logo.py b/bullet/web/migrations/0024_delete_logo.py new file mode 100644 index 00000000..5de04879 --- /dev/null +++ b/bullet/web/migrations/0024_delete_logo.py @@ -0,0 +1,15 @@ +# Generated by Django 5.1.5 on 2025-01-23 20:08 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("web", "0023_pageblock"), + ] + + operations = [ + migrations.DeleteModel( + name="Logo", + ), + ] diff --git a/bullet/web/models.py b/bullet/web/models.py index 5ef1f2a9..232931f3 100644 --- a/bullet/web/models.py +++ b/bullet/web/models.py @@ -1,11 +1,8 @@ -import os.path - from competitions.branches import Branches from competitions.models import Competition from django.conf import settings from django.db import models from django.db.models import UniqueConstraint -from django.utils.text import slugify from django_countries.fields import CountryField from web.fields import ( @@ -43,43 +40,6 @@ def __str__(self): return self.title -def logo_upload_path(instance: "Logo", filename): - _, ext = os.path.splitext(filename) - return f"logos/{Branches[instance.branch].identifier}/{slugify(instance.name)}{ext}" - - -class LogoQuerySet(models.QuerySet): - def partners(self): - return self.filter(type=Logo.Type.PARTNER) - - def organizers(self): - return self.filter(type=Logo.Type.ORGANIZER) - - def for_branch_country(self, branch, country): - return self.filter(branch=branch, countries__contains=[country.upper()]) - - -class Logo(models.Model): - class Type(models.IntegerChoices): - ORGANIZER = 0 - PARTNER = 1 - - branch = BranchField() - type = models.IntegerField(choices=Type.choices) - name = models.CharField(max_length=128) - url = models.CharField(max_length=128) - image = models.FileField(upload_to=logo_upload_path) - countries = ChoiceArrayField(CountryField()) - - objects = LogoQuerySet.as_manager() - - class Meta: - ordering = ("name",) - - def __str__(self): - return f"{self.name} ({Branches[self.branch].name})" - - class ContentBlock(models.Model): group = models.CharField(max_length=256) reference = models.CharField(max_length=256) diff --git a/bullet/web/templates/web/snippets/home_footer.html b/bullet/web/templates/web/snippets/home_footer.html deleted file mode 100644 index 23228e2d..00000000 --- a/bullet/web/templates/web/snippets/home_footer.html +++ /dev/null @@ -1,34 +0,0 @@ -{% load i18n %} -
-
- {% if organizers %} -

{% trans "Organizers" %}

-
- {% for item in organizers %} - - {{ item.name }} - - {% endfor %} -
- {% endif %} - {% if partners %} -

- {% trans "Our partners" %} -

-
- {% for item in partners %} - - {{ item.name }} - - {% endfor %} -
- {% endif %} - {% include "web/snippets/copyright.html" %} -
-
diff --git a/bullet/web/templates/web/snippets/home_hero_buttons.html b/bullet/web/templates/web/snippets/home_hero_buttons.html deleted file mode 100644 index 4e4de9b1..00000000 --- a/bullet/web/templates/web/snippets/home_hero_buttons.html +++ /dev/null @@ -1,26 +0,0 @@ -{% load country_url %} -{% load i18n %} -{% if competition.state == competition.State.BEFORE_REGISTRATION %} -

- {% blocktrans trimmed with start=competition.registration_start|date %} - Registration starts on {{ start }}. - {% endblocktrans %} - {% blocktrans trimmed with start=competition.competition_start|date %} - The competition will take place on {{ start }}. - {% endblocktrans %} -

-{% elif competition.is_registration_open %} - {% trans "Registration" %} -

- {% blocktrans trimmed with end=competition.registration_end|date %} - Registration ends on {{ end }}. - {% endblocktrans %} - {% blocktrans trimmed with start=competition.competition_start|date %} - The competition will take place on {{ start }}. - {% endblocktrans %} -

-{% elif competition.has_started %} - {% trans "Results" %} -{% endif %} diff --git a/bullet/web/templates/web/snippets/home_timeline.html b/bullet/web/templates/web/snippets/home_timeline.html deleted file mode 100644 index 2593f320..00000000 --- a/bullet/web/templates/web/snippets/home_timeline.html +++ /dev/null @@ -1,53 +0,0 @@ -{% load i18n %} -{% load country_url %} -{% if competition %} -
-
-

{% trans "Important dates" %}

-
-
- {% now "Y-m-d" as today %} -
-
-

- {{ competition.registration_start|date }}, - {{ competition.registration_start|time }} -

-

{% trans "Registration starts" %}

-
-
- {% if competition.registration_second_round_start %} -
-
-

- {{ competition.registration_second_round_start|date }}, - {{ competition.registration_second_round_start|time }} -

-

{% trans "Second round of registration" %}

-
-
- {% endif %} -
-
-

- {{ competition.registration_end|date }}, - {{ competition.registration_end|time }} -

-

{% trans "Registration end" %}

-
-
-
-
-

{{ competition.competition_start|date }}

-

{% trans "Competition day" %}

-
-
-
-
- {% if competition.is_registration_open %} - {% trans "Register" %} - {% endif %} -
-
-{% endif %} diff --git a/bullet/web/views/__init__.py b/bullet/web/views/__init__.py index 7d0fb17d..5ba72dc5 100644 --- a/bullet/web/views/__init__.py +++ b/bullet/web/views/__init__.py @@ -3,7 +3,7 @@ from django.utils import translation from django.views.generic import RedirectView, TemplateView -from web.models import Logo, Page +from web.models import Page class BranchSpecificTemplateMixin: @@ -31,17 +31,6 @@ def get_context_data(self, **kwargs): competition ) = Competition.objects.get_current_competition(self.branch) - context["partners"] = ( - Logo.objects.partners() - .for_branch_country(self.branch, self.request.COUNTRY_CODE) - .all() - ) - context["organizers"] = ( - Logo.objects.organizers() - .for_branch_country(self.branch, self.request.COUNTRY_CODE) - .all() - ) - page = Page.objects.filter( branch=self.request.BRANCH, language=translation.get_language(),