From 0eee43550897b58c092491d4f5acc0f6208d363e Mon Sep 17 00:00:00 2001 From: miguelzinh3 Date: Fri, 30 Aug 2024 20:19:29 -0300 Subject: [PATCH 1/2] feature(votepeloclima): add partners app to footer in base.html --- app/contrib/partners/__init__.py | 0 app/contrib/partners/admin.py | 7 +++++ app/contrib/partners/apps.py | 6 ++++ .../partners/migrations/0001_initial.py | 29 +++++++++++++++++++ app/contrib/partners/migrations/__init__.py | 0 app/contrib/partners/models.py | 16 ++++++++++ .../templates/partners/partners_list.html | 9 ++++++ .../partners/templatetags/partners_tags.py | 9 ++++++ .../votepeloclima/settings/base.py | 1 + .../votepeloclima/static/scss/custom.scss | 5 ++++ .../templates/votepeloclima/base.html | 7 ++++- app/project/settings/django_settings.py | 1 + 12 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 app/contrib/partners/__init__.py create mode 100644 app/contrib/partners/admin.py create mode 100644 app/contrib/partners/apps.py create mode 100644 app/contrib/partners/migrations/0001_initial.py create mode 100644 app/contrib/partners/migrations/__init__.py create mode 100644 app/contrib/partners/models.py create mode 100644 app/contrib/partners/templates/partners/partners_list.html create mode 100644 app/contrib/partners/templatetags/partners_tags.py diff --git a/app/contrib/partners/__init__.py b/app/contrib/partners/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/app/contrib/partners/admin.py b/app/contrib/partners/admin.py new file mode 100644 index 00000000..0962a594 --- /dev/null +++ b/app/contrib/partners/admin.py @@ -0,0 +1,7 @@ +from django.contrib import admin +from .models import Partner + + +@admin.register(Partner) +class PartnerAdmin(admin.ModelAdmin): + list_display = ("name", "link") diff --git a/app/contrib/partners/apps.py b/app/contrib/partners/apps.py new file mode 100644 index 00000000..15856d96 --- /dev/null +++ b/app/contrib/partners/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class PartnersConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "contrib.partners" diff --git a/app/contrib/partners/migrations/0001_initial.py b/app/contrib/partners/migrations/0001_initial.py new file mode 100644 index 00000000..4a52ce20 --- /dev/null +++ b/app/contrib/partners/migrations/0001_initial.py @@ -0,0 +1,29 @@ +# Generated by Django 4.2 on 2024-08-30 23:17 + +from django.db import migrations, models +import django.db.models.deletion +import filer.fields.file + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('filer', '0017_image__transparent'), + ] + + operations = [ + migrations.CreateModel( + name='Partner', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100, verbose_name='Nome da Parceria')), + ('link', models.URLField(blank=True, null=True, verbose_name='Link da Parceria')), + ('logo', filer.fields.file.FilerFileField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='filer.file', verbose_name='Imagem')), + ], + options={ + 'verbose_name': 'Parceiro', + }, + ), + ] diff --git a/app/contrib/partners/migrations/__init__.py b/app/contrib/partners/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/app/contrib/partners/models.py b/app/contrib/partners/models.py new file mode 100644 index 00000000..aa757046 --- /dev/null +++ b/app/contrib/partners/models.py @@ -0,0 +1,16 @@ +from django.db import models +from django.utils.translation import gettext_lazy as _ + +from filer.fields.file import FilerFileField + + +class Partner(models.Model): + name = models.CharField(max_length=100, verbose_name="Nome da Parceria") + logo = FilerFileField(verbose_name=_("Imagem"), on_delete=models.SET_NULL, null=True, blank=True) + link = models.URLField(blank=True, null=True, verbose_name="Link da Parceria") + + def __str__(self): + return self.name + + class Meta: + verbose_name = "Parceiro" diff --git a/app/contrib/partners/templates/partners/partners_list.html b/app/contrib/partners/templates/partners/partners_list.html new file mode 100644 index 00000000..7a5da75f --- /dev/null +++ b/app/contrib/partners/templates/partners/partners_list.html @@ -0,0 +1,9 @@ +
+ {% for partner in partners %} +
+ + + +
+ {% endfor %} +
diff --git a/app/contrib/partners/templatetags/partners_tags.py b/app/contrib/partners/templatetags/partners_tags.py new file mode 100644 index 00000000..b87d7dc9 --- /dev/null +++ b/app/contrib/partners/templatetags/partners_tags.py @@ -0,0 +1,9 @@ +from django import template +from ..models import Partner + +register = template.Library() + +@register.inclusion_tag("partners/partners_list.html") +def show_partners(): + partners = Partner.objects.all() + return {'partners': partners} diff --git a/app/org_eleicoes/votepeloclima/settings/base.py b/app/org_eleicoes/votepeloclima/settings/base.py index 44ae6dc0..670e89f8 100644 --- a/app/org_eleicoes/votepeloclima/settings/base.py +++ b/app/org_eleicoes/votepeloclima/settings/base.py @@ -74,6 +74,7 @@ "contrib.ds.picture", "contrib.ds.tooltip", # Project Apps + "contrib.partners", "contrib.oauth", "org_eleicoes.votepeloclima", "org_eleicoes.votepeloclima.candidature", diff --git a/app/org_eleicoes/votepeloclima/static/scss/custom.scss b/app/org_eleicoes/votepeloclima/static/scss/custom.scss index 1c6ddcca..f9e1770a 100644 --- a/app/org_eleicoes/votepeloclima/static/scss/custom.scss +++ b/app/org_eleicoes/votepeloclima/static/scss/custom.scss @@ -195,3 +195,8 @@ legend.form-label { min-height: 230px; } } + +// Partner Tag +.partner-logo { + max-width: 120px; +} \ No newline at end of file diff --git a/app/org_eleicoes/votepeloclima/templates/votepeloclima/base.html b/app/org_eleicoes/votepeloclima/templates/votepeloclima/base.html index 984a4f39..9b90f53f 100644 --- a/app/org_eleicoes/votepeloclima/templates/votepeloclima/base.html +++ b/app/org_eleicoes/votepeloclima/templates/votepeloclima/base.html @@ -1,5 +1,5 @@ {% extends "ds/base.html" %} -{% load static cms_tags menu_tags compress %} +{% load static cms_tags menu_tags compress partners_tags %} {% block head_css %} {{block.super}} @@ -83,6 +83,11 @@
Realização

© 2024. Nossas e Clima de Eleição. Direitos reservados.

+
+
+
Quem assina
+ {% show_partners %} +
diff --git a/app/project/settings/django_settings.py b/app/project/settings/django_settings.py index 8aeb74a4..ea4b77f3 100644 --- a/app/project/settings/django_settings.py +++ b/app/project/settings/django_settings.py @@ -91,6 +91,7 @@ "contrib.frontend.grid", "contrib.frontend.maps", "contrib.ga", + "contrib.partners", # # "contrib.domains.route53", # "contrib.domains.traefik", From fa2c2f8da46ef8596198c53a0c0d207a273f2b46 Mon Sep 17 00:00:00 2001 From: miguelzinh3 Date: Mon, 2 Sep 2024 15:57:31 -0300 Subject: [PATCH 2/2] hotfix(votepeloclima): change styles from partners-list template tag --- .../templates/partners/partners_list.html | 6 +----- .../votepeloclima/static/scss/custom.scss | 15 +++++++++++++-- .../templates/votepeloclima/base.html | 4 +++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/contrib/partners/templates/partners/partners_list.html b/app/contrib/partners/templates/partners/partners_list.html index 7a5da75f..a8382d82 100644 --- a/app/contrib/partners/templates/partners/partners_list.html +++ b/app/contrib/partners/templates/partners/partners_list.html @@ -1,9 +1,5 @@ -
{% for partner in partners %} - {% endfor %} -
diff --git a/app/org_eleicoes/votepeloclima/static/scss/custom.scss b/app/org_eleicoes/votepeloclima/static/scss/custom.scss index f9e1770a..c41a009d 100644 --- a/app/org_eleicoes/votepeloclima/static/scss/custom.scss +++ b/app/org_eleicoes/votepeloclima/static/scss/custom.scss @@ -197,6 +197,17 @@ legend.form-label { } // Partner Tag -.partner-logo { - max-width: 120px; +.partners-list { + a { + display: flex; + justify-content: center; + align-items: center; + } + + img { + width: 125px; + height: 70px; + object-fit: contain; + object-position: center; + } } \ No newline at end of file diff --git a/app/org_eleicoes/votepeloclima/templates/votepeloclima/base.html b/app/org_eleicoes/votepeloclima/templates/votepeloclima/base.html index 9b90f53f..cf098ed4 100644 --- a/app/org_eleicoes/votepeloclima/templates/votepeloclima/base.html +++ b/app/org_eleicoes/votepeloclima/templates/votepeloclima/base.html @@ -86,7 +86,9 @@
Realização

Quem assina
- {% show_partners %} +
+ {% show_partners %} +