Merge pull request #6 from datalets/social-accounts

Social media accounts support
This commit is contained in:
datalets 2017-05-05 14:50:36 +02:00 committed by GitHub
commit 97b65cab50
26 changed files with 117 additions and 6 deletions

View file

@ -1 +0,0 @@
../../../static/libs

View file

@ -1 +0,0 @@
../images

View file

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View file

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 91 KiB

View file

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 86 KiB

View file

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

View file

Before

Width:  |  Height:  |  Size: 333 KiB

After

Width:  |  Height:  |  Size: 333 KiB

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View file

Before

Width:  |  Height:  |  Size: 169 KiB

After

Width:  |  Height:  |  Size: 169 KiB

View file

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View file

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View file

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View file

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 101 KiB

View file

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

View file

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-05-05 08:43
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0015_dataletssettings'),
]
operations = [
migrations.CreateModel(
name='SocialContact',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('network', models.CharField(choices=[('twitter', 'Twitter'), ('facebook', 'Facebook')], default='twitter', max_length=16)),
('profile', models.CharField(default='', help_text='Name of the account, e.g. @myaccount', max_length=255)),
],
),
]

View file

@ -11,8 +11,44 @@ from wagtail.wagtailadmin.edit_handlers import FieldPanel
from ..util import TranslatedField from ..util import TranslatedField
# List of supported social networks
SOCIAL_NETWORK_SUPPORTED = (
('twitter', 'Twitter'),
('facebook', 'Facebook'),
)
@register_snippet
class SocialContact(models.Model):
"""
Adds contact options through social networks
"""
network = models.CharField(max_length=16, default="twitter",
choices=SOCIAL_NETWORK_SUPPORTED)
profile = models.CharField(max_length=255, default="",
help_text="Name of the account, e.g. @myaccount, or full URL")
panels = [
FieldPanel('network'),
FieldPanel('profile'),
]
social_networks = dict(SOCIAL_NETWORK_SUPPORTED)
def network_title(self):
return self.social_networks[self.network]
def network_url(self):
if '://' in self.profile:
return self.profile
if self.network == 'twitter':
return "https://twitter.com/%s" % self.profile
elif self.network == 'facebook':
return "https://facebook.com/%s" % self.profile
return "#"
def __str__(self):
return "%s" % self.network
@register_snippet @register_snippet
class Contact(models.Model): class Contact(models.Model):
"""
Defines contact options for the organisation, usually shown in footer
"""
title = models.CharField(max_length=255, default="") title = models.CharField(max_length=255, default="")
title_fr = models.CharField(max_length=255, default="") title_fr = models.CharField(max_length=255, default="")
trans_title = TranslatedField( trans_title = TranslatedField(

View file

@ -6,3 +6,11 @@
<a href="{{ contact.email_link }}">{{ contact.email }}</a><br> <a href="{{ contact.email_link }}">{{ contact.email }}</a><br>
<a href="{{ contact.www }}">{{ contact.www_domain }}</a></p> <a href="{{ contact.www }}">{{ contact.www_domain }}</a></p>
</address> </address>
<div class="social-networks">
{% for sc in socials %}
<a href="{{ sc.network_url }}" target="_blank" title="{{ sc.network_title }}"
style="background-image:url(/static/images/social/{{ sc.network }}.png)">
{{ sc.network_title }}</a>
{% endfor %}
</div>

View file

@ -1,7 +1,15 @@
<span class="social-networks">
{% for sc in socials %}
<a href="{{ sc.network_url }}" target="_blank" title="{{ sc.network_title }}"
style="background-image:url(/static/images/social/{{ sc.network }}.png)">
{{ sc.network_title }}</a>
{% endfor %}
</span>
<a href="{{ contact.phone_link }}"> <a href="{{ contact.phone_link }}">
<span class="glyphicon glyphicon-earphone" aria-hidden="true"></span> <span class="glyphicon glyphicon-earphone" aria-hidden="true"></span>
<span class="hidden-xs">{{ contact.phone }}</span></a> <span class="hidden-xs">{{ contact.phone }}</span></a>
<a href="{{ contact.email_link }}"> <a href="{{ contact.email_link }}">
<span class="glyphicon glyphicon-envelope" aria-hidden="true"></span> <span class="glyphicon glyphicon-envelope" aria-hidden="true"></span>
<span class="hidden-xs">{{ contact.email }}</span></a> <span class="hidden-xs">{{ contact.email }}</span></a>

View file

@ -2,7 +2,7 @@
from django import template from django import template
from django.utils import translation from django.utils import translation
from ..models.snippets import Contact from ..models.snippets import Contact, SocialContact
register = template.Library() register = template.Library()
@ -11,6 +11,7 @@ register = template.Library()
def contact_info(): def contact_info():
return { return {
'contact': Contact.objects.last(), 'contact': Contact.objects.last(),
'socials': SocialContact.objects.all()
} }
# Contact form (footer) # Contact form (footer)
@ -25,6 +26,7 @@ def contact_form():
def contact_links(): def contact_links():
return { return {
'contact': Contact.objects.last(), 'contact': Contact.objects.last(),
'socials': SocialContact.objects.all()
} }
# Styled contact name (header) # Styled contact name (header)

View file

@ -23,3 +23,38 @@ footer#footer {
article footer .btn { article footer .btn {
margin-bottom: 1em; margin-bottom: 1em;
} }
// Footer search form
#search-form {
input {
float: left;
width: auto;
color: white;
}
button {
background: none; border: none;
padding-top: 0.5em;
}
}
// Footer contact form
#contact-info {
address {
margin-bottom: 0px;
}
.social-networks > a {
border: 2px solid white;
width: 32px; height: 32px;
}
}
.social-networks > a {
width: 14px; height: 14px;
font-size: 0px !important;
display: inline-block;
background-size: auto 70%;
background-repeat: no-repeat;
background-position: center;
}

View file

@ -47,6 +47,7 @@
} }
// Search result form
#search-page { #search-page {
input[type='text'] { input[type='text'] {
font-size: 110%; font-size: 110%;

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -1,4 +1,4 @@
{% load wagtailcore_tags navigation information %} {% load static wagtailcore_tags navigation information %}
{% get_site_root as site_root %} {% get_site_root as site_root %}
<nav class="navbar-pre navbar-fixed-top"> <nav class="navbar-pre navbar-fixed-top">
@ -25,7 +25,7 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="navbar-brand" href="{% pageurl site_root %}"> <a class="navbar-brand" href="{% pageurl site_root %}">
<img src="/static/images/public-health-logo-sign.png" alt="[logo]"> <img src="{% static 'images/public-health-logo-sign.png' %}" alt="[logo]">
<span class="hidden-xs">{% contact_name %}</span></a> <span class="hidden-xs">{% contact_name %}</span></a>
</div> </div>