Merge pull request #8 from datalets/contact-form-78

Contact form 78
This commit is contained in:
datalets 2017-05-10 16:59:04 +02:00 committed by GitHub
commit 7c4715844f
9 changed files with 112 additions and 18 deletions

View file

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-05-10 14:27
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0016_socialcontact'),
]
operations = [
migrations.AddField(
model_name='contact',
name='analytics',
field=models.CharField(blank=True, default='', help_text='Optional web analytics property code', max_length=60),
),
migrations.AddField(
model_name='contact',
name='map_url',
field=models.URLField(blank=True, help_text='Optional link of address to mapping provider', null=True),
),
migrations.AlterField(
model_name='socialcontact',
name='profile',
field=models.CharField(default='', help_text='Name of the account, e.g. @myaccount, or full URL', max_length=255),
),
]

View file

@ -59,6 +59,10 @@ class Contact(models.Model):
phone = models.CharField(max_length=40, default="")
email = models.EmailField(max_length=100, default="")
www = models.URLField(null=True, blank=True)
map_url = models.URLField(null=True, blank=True,
help_text="Optional link of address to mapping provider")
analytics = models.CharField(max_length=60, default="", blank=True,
help_text="Optional web analytics property code")
panels = Page.content_panels + [
FieldPanel('title_fr'),
@ -66,6 +70,8 @@ class Contact(models.Model):
FieldPanel('phone'),
FieldPanel('email'),
FieldPanel('www'),
FieldPanel('map_url'),
FieldPanel('analytics'),
]
def phone_link(self):
@ -74,6 +80,13 @@ class Contact(models.Model):
return 'mailto:%s' % self.email
def www_domain(self):
return self.www.replace('http://', '').replace('https://', '')
def is_google_analytics(self):
return self.analytics.startswith('UA-')
def get_piwik_analytics(self):
# When formatted as "server|site_id", assume Piwik
if not '|' in self.analytics: return False
sa = self.analytics.split('|')
return { 'server': sa[0], 'site': sa[1] }
def trans_title_styled(self):
v = self.trans_title.split(' ')
if len(v) != 3: return v

View file

@ -43,12 +43,12 @@
{% for block in subcategories %}
<article class="col-md-4">
<a href="{% pageurl block %}">
<header>
<h4>{{ block.trans_title }}</h4>
</header>
<div class="image">
{% image block.feed_image fill-300x300 %}
</div>
<header>
<h3>{{ block.trans_title }}</h3>
</header>
</a>
</article>
{% endfor %}

View file

@ -5,16 +5,20 @@
<div class="row infoblocks">
{% for block in page.trans_infos %}
<article class="col-md-4">
<div class="image">
{% image block.value.photo fill-300x300 %}
</div>
<header>
<h3>{{ block.value.title }}</h3>
</header>
<a href="{{ block.value.url }}">
<div class="image">
{% image block.value.photo fill-300x300 %}
</div>
<header>
<h3>{{ block.value.title }}</h3>
</header>
</a>
{{ block.value.summary|richtext }}
{% if block.value.action %}
<footer>
<a href="{{ block.value.url }}" class="btn btn-default">{{ block.value.action }}</a>
</footer>
{% endif %}
</article>
{% endfor %}
</div>

View file

@ -1,12 +1,12 @@
<form action="mailto:{{ contact.email }}" enctype="text/plain" method="GET">
<form action="https://formspree.io/{{ contact.email }}" method="POST">
<div class="form-group">
<input name="name" id="name" type="text" placeholder="Name / Nom" class="form-control">
</div>
<!--<div class="form-group">
<input name="_replyto" id="email" type="email" placeholder="E-Mail" class="form-control">
</div>-->
<div class="form-group">
<textarea name="message" id="message" rows="3" placeholder="" class="form-control"></textarea>
<input name="_replyto" id="email" type="email" placeholder="E-Mail" class="form-control">
</div>
<div class="form-group">
<textarea name="message" id="message" rows="3" placeholder="Nachricht / Message" class="form-control"></textarea>
</div>
<button class="btn btn-primary" type="submit">Senden / Envoi</button>
</form>

View file

@ -1,6 +1,10 @@
<address>
<p>{{ contact.trans_title }}<br>
{{ contact.address }}
{% if contact.map_url %}
<a href="{{ contact.map_url }}">{{ contact.address }}</a>
{% else %}
{{ contact.address }}
{% endif %}
</p>
<p>Tel. <a href="{{ contact.phone_link }}">{{ contact.phone }}</a><br>
<a href="{{ contact.email_link }}">{{ contact.email }}</a><br>
@ -14,3 +18,30 @@
{{ sc.network_title }}</a>
{% endfor %}
</div>
{% if contact.is_google_analytics %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', '{{ contact.analytics }}', 'auto');
ga('send', 'pageview');
</script>
{% elif contact.get_piwik_analytics %}
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
_paq.push(["setCookieDomain", document.domain]);
_paq.push(["setDomains", [document.domain,"*." + document.domain]]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//{{ contact.get_piwik_analytics.server }}";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', {{ contact.get_piwik_analytics.site }}]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
{% endif %}

View file

@ -41,6 +41,11 @@ section {
}
}
// Article index blocks
.article-subcategories article {
margin-bottom: 1.5em;
}
// Special article layout
.article-page .lead {
h2,h3,h4,h5 { text-align: center; }

View file

@ -194,6 +194,9 @@ $banner-height: 700px;
}
@include max-screen(480px) {
.navbar-pre .navbar-nav,
#carousel-banner { display: none !important; }
#banner { margin-top: 100px; }
#carousel-banner {
.carousel-caption { left: 0px; right: 0px; overflow-x: hidden; }
.carousel-inner { margin-bottom: 0px; }
}
//#banner { margin-top: 100px; }
}

View file

@ -39,17 +39,25 @@ article footer .btn {
}
// Footer contact form
// Footer contact information
#contact-info {
address {
margin-bottom: 0px;
}
.social-networks > a {
border: 2px solid white;
width: 32px; height: 32px;
}
}
// Footer contact form
#footer #contact-form {
textarea.form-control, input.form-control {
color: white;
}
}
// Base style for social network buttons as used in header
.social-networks > a {
width: 14px; height: 14px;