Commit 6b4bbed3 authored by maxime's avatar maxime

models, display & forms for twitter everywhere #421

parent 09ebfe10
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-12-18 16:49
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('data_manager', '0049_merge_20191217_1421'),
]
operations = [
migrations.AddField(
model_name='actiongroup',
name='anytwittContent',
field=models.CharField(blank=True, max_length=280, null=True, verbose_name='Contenu du tweet'),
),
migrations.AddField(
model_name='actiongroup',
name='anytwittExplination',
field=models.TextField(blank=True, null=True, verbose_name='Contenu du tweet'),
),
migrations.AddField(
model_name='actiongroup',
name='anytwittTargets',
field=models.TextField(blank=True, null=True, verbose_name='Contenu du tweet'),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-12-18 17:05
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('data_manager', '0050_auto_20191218_1749'),
]
operations = [
migrations.AlterField(
model_name='actiongroup',
name='anytwittContent',
field=models.CharField(blank=True, max_length=280, null=True, verbose_name='Tweet Global - Content'),
),
migrations.AlterField(
model_name='actiongroup',
name='anytwittExplination',
field=models.TextField(blank=True, null=True, verbose_name='Tweet Global - Explination'),
),
migrations.AlterField(
model_name='actiongroup',
name='anytwittTargets',
field=models.TextField(blank=True, null=True, verbose_name='Tweet Global - Targets'),
),
]
......@@ -201,9 +201,14 @@ class ActionGroup(Model):
videotitle = models.CharField(max_length=255, blank=True, null=True, verbose_name=u"Titre de la vidéo")
videourl = models.URLField(max_length=9999999, blank=True, null=True, verbose_name=u"Vidéo associé à l'action")
#interpellation anyone on twitter
anytwittContent = models.CharField(blank=True, null=True,max_length=280, verbose_name=u"Tweet Global - Content")
anytwittTargets = models.TextField(blank=True, null=True, verbose_name=u"Tweet Global - Targets")
anytwittExplination = models.TextField(blank=True, null=True, verbose_name=u"Tweet Global - Explination")
class Meta:
auto_author = 'author'
serializer_fields = ['@id','videourl','videotitle','calltitle','callcontent','callmoreinfo','supported_group','twitter_content','name', 'related_text', 'author','pressreleasetitle','pressreleasecontent','jugementmaj','signuplink','instagram','twitter','facebook', 'objective','actiondate','endactiondate','actioninfolink', 'description', 'theme', 'frequency','linkcollabtext','electedofficialemailsubject', 'electedofficialemailtext', 'representatives', 'members', 'actiongroups', 'loomios', 'conversation', 'address', 'city', 'postcode', 'lat', 'lng', 'events','org_actions']
serializer_fields = ['@id','anytwittExplination','anytwittTargets','anytwittContent','videourl','videotitle','calltitle','callcontent','callmoreinfo','supported_group','twitter_content','name', 'related_text', 'author','pressreleasetitle','pressreleasecontent','jugementmaj','signuplink','instagram','twitter','facebook', 'objective','actiondate','endactiondate','actioninfolink', 'description', 'theme', 'frequency','linkcollabtext','electedofficialemailsubject', 'electedofficialemailtext', 'representatives', 'members', 'actiongroups', 'loomios', 'conversation', 'address', 'city', 'postcode', 'lat', 'lng', 'events','org_actions']
nested_fields=[ "author",'supported_group','related_text', "representatives", "loomios", "actiongroups", "conversation", "members", "events",'org_actions']
anonymous_perms = ['view','add']
authenticated_perms = ['inherit', 'add']
......
......@@ -169,7 +169,7 @@
}
}
}
sib-display-div[name="petition-txt"],sib-display-div[name="sectionsoutient"],sib-display-div[name="sectionelues-txt"],sib-display-div[name="concertation-txt"]{
sib-display-div[name="petition-txt"],sib-display-div[name="sectionsoutient"],sib-display-div[name="sectionelues-txt"],sib-display-div[name="concertation-txt"],sib-display-div[name="interpelation-title"]{
text-align: center;
font-size: 26px;
font-weight: initial;
......@@ -198,13 +198,22 @@
}
}
sib-display-div[name="electedofficialemailtext-title"],sib-display-div[name="call-txt"]{
sib-display-div[name="electedofficialemailtext-title"],sib-display-div[name="call-txt"],sib-display-div[name="interpelation-txt"]{
font-size: 14px;
font-weight: bold;
text-align:center;
>div{
margin: 20px 0 10px 0;
}
}
}
sib-display-div[name="anytwittTargets-txt"]{
font-size:14px;
font-style: italic;
>div{
margin-bottom: 10px;
}
}
sib-display-div[name="sectionelues-txt-twitter"],sib-display-div[name="sectionelues-txt-email"]{
......
......@@ -3,7 +3,7 @@
Email, Twitter module block && Conformation Page CSS
==============================
*/
#email-eo,#twitt-eo,#section-eo-twitter{
#email-eo,#twitt-eo,#section-eo-twitter,#tweet-anyone{
div.email-section{
/*Find elected section*/
.find-elected{
......
......@@ -31,6 +31,8 @@
sectionelues(sectionelues-txt,electedofficialemailtext-title,sectionelues-txt-twitter,twitter_content,sectionelues-txt-email,electedofficialemailsubject,electedofficialemailtext,representatives),
interpellation(interpelation-title,interpelation-txt, anytwittContent,anytwittTargets,anytwittTargets-txt,anytwittExplination),
concertation(concertation-txt,
txtcollab(linkcollabtext-txt,linkcollabtext),
jugmaj(jugementmaj-txt,jugementmaj))
......@@ -61,6 +63,21 @@
widget-videourl="sib-form-placeholder-text"
widget-interpelation-title="sib-display-div"
widget-interpelation-txt="sib-display-div"
widget-anytwittTargets-txt="sib-display-div"
widget-anytwittContent="sib-form-placeholder-text"
widget-anytwittTargets="sib-form-placeholder-text"
widget-anytwittExplination="sib-form-placeholder-text"
value-interpelation-title="Interpellation ciblé sur twitter"
value-interpelation-txt="Proposez des comptes twitter à cibler précisement"
value-anytwittTargets-txt='Ajoutez les noms de comptes avec le format @NomDuCompte. <br>Pour ajoutez plusieurs comptes, séparez les noms de compte avec une virgule. Par exemple "@AssembleeNationale, @Elysee, @Min_Ecologie"'
label-anytwittContent="Contenu du tweet"
label-anytwittTargets="Compte à cibler"
label-anytwittExplination="Expliquez pourquoi c'est pertinent de contacter ces personnes"
widget-petition-txt="sib-display-div"
value-petition-txt="Appel et Pétition"
......
......@@ -400,6 +400,78 @@
</div>
<!--
========================================================
Contact Anyone on twitter
========================================================
-->
<sib-display
class="additionnal-features"
bind-resources
id="tweet-anyone"
fields="anytwittContent,anytwittTargets,anytwittExplination,tweet-button"
label-twitter_content="Tweet proposé"
label-anytwittExplination="Ces personnes sont ciblés car :"
label-anytwittContent=""
widget-anytwittContent="sib-display-backspaced-labelled-any-twitter-text"
widget-tweet-button="sib-display-div"
value-tweet-button='<button class="cta-1" onclick="tweetAnyone()" >Interpeller sur twitter</button>'
></sib-display>
<sib-widget name="sib-display-backspaced-labelled-any-twitter-text">
<template>
${value ? '<h3 id="anyone-twitter-module">Interpellation twitter</h3> <div name="'+name+'"><p class="label">'+ label +'</p><p id="eo-tweet">'+anchorme(value.replace(/\n/g, "<br/>"))+'</p></div>':""}
</template>
</sib-widget>
<script type="text/javascript">
//get content of email and pass it to mailto
function tweetAnyone(){
try {
var anywhereBlock = document.querySelector("#tweet-anyone");
//window.alert(anywhereBlock);
var target_account = document.getElementsByName("anytwittTargets")[0].value;
var twitt_content = document.getElementsByName("anytwittContent")[0].value;
//window.alert(target_account +" and " + twitt_content);
var target_account = target_account.split('https\:\/\/twitter.com\/').join('@');
//window.alert(eo_account); //for debug / works
var tweet= twitt_content + " " + target_account;
//window.alert(tweet);
// encode it
var sharableTweet = "https://twitter.com/intent/tweet?text=" +encodeURI(tweet)
//encode the #
var sharableTweet = sharableTweet.replace(/#/g, '%23');
//window.alert("Encoded : " + sharableTweet); //for debug
window.open(sharableTweet, '_blank'); //share it
//figure out how to do target _blank
//.open , '_blank' doens't work
}
catch(err) {
console.log(err.message);
}
}
</script>
......
......@@ -31,6 +31,8 @@
sectionelues(sectionelues-txt,electedofficialemailtext-title,sectionelues-txt-twitter,twitter_content,sectionelues-txt-email,electedofficialemailsubject,electedofficialemailtext,representatives),
interpellation(interpelation-title,interpelation-txt, anytwittContent,anytwittTargets,anytwittTargets-txt,anytwittExplination),
concertation(concertation-txt,
txtcollab(linkcollabtext-txt,linkcollabtext),
jugmaj(jugementmaj-txt,jugementmaj))
......@@ -61,6 +63,21 @@
widget-videourl="sib-form-placeholder-text"
widget-interpelation-title="sib-display-div"
widget-interpelation-txt="sib-display-div"
widget-anytwittTargets-txt="sib-display-div"
widget-anytwittContent="sib-form-placeholder-text"
widget-anytwittTargets="sib-form-placeholder-text"
widget-anytwittExplination="sib-form-placeholder-text"
value-interpelation-title="Interpellation ciblé sur twitter"
value-interpelation-txt="Proposez des comptes twitter à cibler précisement"
value-anytwittTargets-txt='Ajoutez les noms de comptes avec le format @NomDuCompte. <br>Pour ajoutez plusieurs comptes, séparez les noms de compte avec une virgule. Par exemple "@AssembleeNationale, @Elysee, @Min_Ecologie"'
label-anytwittContent="Contenu du tweet"
label-anytwittTargets="Compte à cibler"
label-anytwittExplination="Expliquez pourquoi c'est pertinent de contacter ces personnes"
widget-petition-txt="sib-display-div"
value-petition-txt="Appel et Pétition"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment