Skip to content

Commit

Permalink
Merge pull request #280 from nossas/feature/footer-partners-app
Browse files Browse the repository at this point in the history
[Feature] Adiciona "Partners" app e insere dentro do footer do Vote pelo Clima
  • Loading branch information
igr-santos authored Sep 2, 2024
2 parents ef68013 + fa2c2f8 commit 148daf8
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 1 deletion.
Empty file.
7 changes: 7 additions & 0 deletions app/contrib/partners/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib import admin
from .models import Partner


@admin.register(Partner)
class PartnerAdmin(admin.ModelAdmin):
list_display = ("name", "link")
6 changes: 6 additions & 0 deletions app/contrib/partners/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class PartnersConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "contrib.partners"
29 changes: 29 additions & 0 deletions app/contrib/partners/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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',
},
),
]
Empty file.
16 changes: 16 additions & 0 deletions app/contrib/partners/models.py
Original file line number Diff line number Diff line change
@@ -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"
5 changes: 5 additions & 0 deletions app/contrib/partners/templates/partners/partners_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% for partner in partners %}
<a href="{{ partner.link }}" target="_blank" rel="noopener noreferrer">
<img src="{{ partner.logo.url }}" alt="{{ partner.name }}">
</a>
{% endfor %}
9 changes: 9 additions & 0 deletions app/contrib/partners/templatetags/partners_tags.py
Original file line number Diff line number Diff line change
@@ -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}
1 change: 1 addition & 0 deletions app/org_eleicoes/votepeloclima/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"contrib.ds.picture",
"contrib.ds.tooltip",
# Project Apps
"contrib.partners",
"contrib.oauth",
"org_eleicoes.votepeloclima",
"org_eleicoes.votepeloclima.candidature",
Expand Down
16 changes: 16 additions & 0 deletions app/org_eleicoes/votepeloclima/static/scss/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,19 @@ legend.form-label {
min-height: 230px;
}
}

// Partner Tag
.partners-list {
a {
display: flex;
justify-content: center;
align-items: center;
}

img {
width: 125px;
height: 70px;
object-fit: contain;
object-position: center;
}
}
Original file line number Diff line number Diff line change
@@ -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}}
Expand Down Expand Up @@ -83,6 +83,13 @@ <h5 class="fw-bold text-uppercase text-white">Realização</h5>
<div class="g-col-12">
<p>© 2024. Nossas e Clima de Eleição. Direitos reservados.</p>
</div>
<hr class="g-col-12" />
<div class="g-col-12">
<h5 class="text-uppercase text-white">Quem assina</h5>
<div class="partners-list d-flex flex-wrap gap-2">
{% show_partners %}
</div>
</div>
</div>
</div>
</footer>
Expand Down
1 change: 1 addition & 0 deletions app/project/settings/django_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"contrib.frontend.grid",
"contrib.frontend.maps",
"contrib.ga",
"contrib.partners",
#
# "contrib.domains.route53",
# "contrib.domains.traefik",
Expand Down

0 comments on commit 148daf8

Please sign in to comment.