Merge pull request #6 from datalets/social-accounts
Social media accounts support
|
@ -1 +0,0 @@
|
|||
../../../static/libs
|
|
@ -1 +0,0 @@
|
|||
../images
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 91 KiB |
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 333 KiB After Width: | Height: | Size: 333 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 169 KiB After Width: | Height: | Size: 169 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 101 KiB |
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
23
publichealth/home/migrations/0016_socialcontact.py
Normal 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)),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -11,8 +11,44 @@ from wagtail.wagtailadmin.edit_handlers import FieldPanel
|
|||
|
||||
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
|
||||
class Contact(models.Model):
|
||||
"""
|
||||
Defines contact options for the organisation, usually shown in footer
|
||||
"""
|
||||
title = models.CharField(max_length=255, default="")
|
||||
title_fr = models.CharField(max_length=255, default="")
|
||||
trans_title = TranslatedField(
|
||||
|
|
|
@ -6,3 +6,11 @@
|
|||
<a href="{{ contact.email_link }}">{{ contact.email }}</a><br>
|
||||
<a href="{{ contact.www }}">{{ contact.www_domain }}</a></p>
|
||||
</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>
|
||||
|
|
|
@ -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 }}">
|
||||
<span class="glyphicon glyphicon-earphone" aria-hidden="true"></span>
|
||||
<span class="hidden-xs">{{ contact.phone }}</span></a>
|
||||
|
||||
|
||||
<a href="{{ contact.email_link }}">
|
||||
<span class="glyphicon glyphicon-envelope" aria-hidden="true"></span>
|
||||
<span class="hidden-xs">{{ contact.email }}</span></a>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from django import template
|
||||
from django.utils import translation
|
||||
|
||||
from ..models.snippets import Contact
|
||||
from ..models.snippets import Contact, SocialContact
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
@ -11,6 +11,7 @@ register = template.Library()
|
|||
def contact_info():
|
||||
return {
|
||||
'contact': Contact.objects.last(),
|
||||
'socials': SocialContact.objects.all()
|
||||
}
|
||||
|
||||
# Contact form (footer)
|
||||
|
@ -25,6 +26,7 @@ def contact_form():
|
|||
def contact_links():
|
||||
return {
|
||||
'contact': Contact.objects.last(),
|
||||
'socials': SocialContact.objects.all()
|
||||
}
|
||||
|
||||
# Styled contact name (header)
|
||||
|
|
|
@ -23,3 +23,38 @@ footer#footer {
|
|||
article footer .btn {
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
|
||||
}
|
||||
|
||||
// Search result form
|
||||
#search-page {
|
||||
input[type='text'] {
|
||||
font-size: 110%;
|
||||
|
|
BIN
publichealth/static/images/social/facebook.png
Normal file
After Width: | Height: | Size: 380 B |
BIN
publichealth/static/images/social/twitter.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
|
@ -1,4 +1,4 @@
|
|||
{% load wagtailcore_tags navigation information %}
|
||||
{% load static wagtailcore_tags navigation information %}
|
||||
{% get_site_root as site_root %}
|
||||
|
||||
<nav class="navbar-pre navbar-fixed-top">
|
||||
|
@ -25,7 +25,7 @@
|
|||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<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>
|
||||
</div>
|
||||
|
||||
|
|