Add functionality to show news_letter #1

Merged
mravi merged 1 commit from allow-newsletter into master 2022-02-07 07:07:43 +00:00
4 changed files with 28 additions and 0 deletions

View file

@ -97,6 +97,15 @@ class Contact(models.Model):
on_delete=models.SET_NULL, on_delete=models.SET_NULL,
related_name='+', related_name='+',
) )
news_letter_url = models.URLField(default='', blank=True)
news_letter_text = models.CharField(default='', blank=True, max_length=256)
news_letter_text_fr = models.CharField(max_length=255, blank=True, default="")
news_letter_text_en = models.CharField(max_length=255, blank=True, default="")
trans_news_letter_text = TranslatedField(
'news_letter_text',
'news_letter_text_fr',
'news_letter_text_en',
)
panels = Page.content_panels + [ panels = Page.content_panels + [
FieldPanel('title_fr'), FieldPanel('title_fr'),
@ -114,6 +123,13 @@ class Contact(models.Model):
PageChooserPanel('contact_form', 'home.ContactForm'), PageChooserPanel('contact_form', 'home.ContactForm'),
] ]
panels = panels + [
FieldPanel('news_letter_url', classname="full"),
FieldPanel('news_letter_text'),
FieldPanel('news_letter_text_fr'),
FieldPanel('news_letter_text_en'),
]
def phone_link(self): def phone_link(self):
return 'tel:%s' % self.phone.replace(' ', '') return 'tel:%s' % self.phone.replace(' ', '')
def email_link(self): def email_link(self):

View file

@ -0,0 +1,3 @@
{% if contact.trans_news_letter_text %}
<a href="{{ contact.news_letter_url }}">{{ contact.trans_news_letter_text }}</a>
{% endif %}

View file

@ -35,11 +35,19 @@ def get_contacts(the_site):
'socials': social_contacts 'socials': social_contacts
} }
# Contact information (footer) # Contact information (footer)
@register.inclusion_tag('tags/contact_info.html') @register.inclusion_tag('tags/contact_info.html')
def contact_info(the_site): def contact_info(the_site):
return get_contacts(the_site) return get_contacts(the_site)
# Newsletter (footer)
@register.inclusion_tag('tags/news_letter.html')
def news_letter(the_site):
return get_contacts(the_site)
# Contact form (footer) # Contact form (footer)
@register.inclusion_tag('tags/footer_form.html') @register.inclusion_tag('tags/footer_form.html')
def footer_form(the_site): def footer_form(the_site):

View file

@ -24,6 +24,7 @@
</div> </div>
<div class="col-md-4" id="contact-form"> <div class="col-md-4" id="contact-form">
{% footer_form the_site=the_site %} {% footer_form the_site=the_site %}
{% news_letter the_site=the_site %}
</div> </div>
</div><!-- /row --> </div><!-- /row -->
</div><!-- /container --> </div><!-- /container -->