L'Agenda du Libre diffuse maintenant ses événements sur twitter
This commit is contained in:
parent
dc74926377
commit
f5ded6c84e
@ -35,6 +35,7 @@ class ModerationsController < ApplicationController
|
|||||||
def accept
|
def accept
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @moderation.update(moderated: true) && send_accept_mails
|
if @moderation.update(moderated: true) && send_accept_mails
|
||||||
|
tweet
|
||||||
format.html { redirect_to moderations_path, notice: t('.ok') }
|
format.html { redirect_to moderations_path, notice: t('.ok') }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
else
|
else
|
||||||
@ -92,6 +93,17 @@ class ModerationsController < ApplicationController
|
|||||||
ModerationMailer.accept(@moderation, current_user).deliver
|
ModerationMailer.accept(@moderation, current_user).deliver
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Tweet this event, if configured using apache/system variables!
|
||||||
|
def tweet
|
||||||
|
client = Twitter::REST::Client.new do |config|
|
||||||
|
config.consumer_key = ENV['TWITTER_CONSUMER_KEY']
|
||||||
|
config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
|
||||||
|
config.access_token = ENV['TWITTER_ACCESS_TOKEN']
|
||||||
|
config.access_token_secret = ENV['TWITTER_ACCESS_SECRET']
|
||||||
|
end
|
||||||
|
client.update "#{@event} #{events_url @event}" if client.consumer_key
|
||||||
|
end
|
||||||
|
|
||||||
def send_destroy_mails
|
def send_destroy_mails
|
||||||
# Send a notification to its author
|
# Send a notification to its author
|
||||||
if params[:reason] == 'r_4'
|
if params[:reason] == 'r_4'
|
||||||
|
@ -91,6 +91,14 @@ class Event < ActiveRecord::Base
|
|||||||
[address, city, related_region.name].compact.join ', '
|
[address, city, related_region.name].compact.join ', '
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def hashtags
|
||||||
|
tags.split.map { |tag| "##{tag}" }
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"#{start_time.to_date} #{city}: #{title} #{hashtags.join(' ')}"
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def end_after_start
|
def end_after_start
|
||||||
|
@ -1,39 +1,38 @@
|
|||||||
%h2
|
%h2
|
||||||
%em.fa.fa-thumbs-down
|
%em.fa.fa-exclamation-triangle
|
||||||
=t '.title'
|
=t '.title'
|
||||||
|
|
||||||
%fieldset
|
= form_tag moderation_path(@moderation), method: :delete do |f|
|
||||||
= form_tag moderation_path(@moderation), method: :delete do |f|
|
.field.closer(title="#{t '.reason_r_1_long'}")
|
||||||
%h3=t '.question'
|
= radio_button_tag :reason, :r_1, params[:event] == 'reason_r_1'
|
||||||
|
= label_tag :reason_r_1, t('.reason_r_1')
|
||||||
|
|
||||||
.field.closer(title="#{t '.reason_r_1_long'}")
|
.field.closer(title="#{t '.reason_r_2_long'}")
|
||||||
= radio_button_tag :reason, :r_1, params[:event] == 'reason_r_1'
|
= radio_button_tag :reason, :r_2, params[:event] == 'reason_r_2'
|
||||||
= label_tag :reason_r_1, t('.reason_r_1')
|
= label_tag :reason_r_2, t('.reason_r_2')
|
||||||
|
|
||||||
.field.closer(title="#{t '.reason_r_2_long'}")
|
.field.closer(title="#{t '.reason_r_3_long'}")
|
||||||
= radio_button_tag :reason, :r_2, params[:event] == 'reason_r_2'
|
= radio_button_tag :reason, :r_3, params[:event] == 'reason_r_3'
|
||||||
= label_tag :reason_r_2, t('.reason_r_2')
|
= label_tag :reason_r_3, t('.reason_r_3')
|
||||||
|
|
||||||
.field.closer(title="#{t '.reason_r_3_long'}")
|
.field.opener(title="#{t '.reason_r_4_long'}")
|
||||||
= radio_button_tag :reason, :r_3, params[:event] == 'reason_r_3'
|
= radio_button_tag :reason, :r_4, params[:event] == 'reason_r_4' || !params[:event]
|
||||||
= label_tag :reason_r_3, t('.reason_r_3')
|
= label_tag :reason_r_4, t('.reason_r_4')
|
||||||
|
|
||||||
.field.opener(title="#{t '.reason_r_4_long'}")
|
.field
|
||||||
= radio_button_tag :reason, :r_4, params[:event] == 'reason_r_4' || !params[:event]
|
= label_tag :reason_text, t('.reason')
|
||||||
= label_tag :reason_r_4, t('.reason_r_4')
|
= text_area_tag :reason_text, nil, cols: 40, rows: 5
|
||||||
|
|
||||||
.field
|
= link_to moderations_url do
|
||||||
= label_tag :reason_text, t('.reason')
|
%em.fa.fa-arrow-left
|
||||||
= text_area_tag :reason_text, nil, cols: 40, rows: 5
|
=t '.ko'
|
||||||
|
|
||||||
= link_to moderations_url do
|
= button_tag do
|
||||||
%em.fa.fa-arrow-left
|
%em.fa.fa-thumbs-down
|
||||||
=t '.ko'
|
=t '.ok'
|
||||||
|
|
||||||
= button_tag do
|
|
||||||
%em.fa.fa-thumbs-down
|
|
||||||
=t '.ok'
|
|
||||||
|
|
||||||
%fieldset
|
%fieldset
|
||||||
%legend= Event.model_name.human
|
%legend
|
||||||
|
%em.fa.fa-calendar
|
||||||
|
= Event.model_name.human
|
||||||
= render file: '/events/show'
|
= render file: '/events/show'
|
||||||
|
@ -1,22 +1,32 @@
|
|||||||
%h2
|
%h2
|
||||||
%em.fa.fa-thumbs-up
|
%em.fa.fa-exclamation-triangle
|
||||||
=t '.title'
|
=t '.title'
|
||||||
|
|
||||||
%fieldset
|
- if @event.locality?
|
||||||
- if @event.locality?
|
%h2.warning=t '.warning'
|
||||||
%h2.warning=t '.warning'
|
|
||||||
|
|
||||||
= form_for @moderation, url: { action: :accept }, html: { method: :put } do |f|
|
= form_for @moderation, url: { action: :accept }, html: { method: :put } do |f|
|
||||||
%h2=t '.question'
|
= link_to moderations_url do
|
||||||
|
%em.fa.fa-arrow-left
|
||||||
|
=t '.ko'
|
||||||
|
|
||||||
= link_to moderations_url do
|
= f.button do
|
||||||
%em.fa.fa-arrow-left
|
%em.fa.fa-thumbs-up
|
||||||
=t '.ko'
|
=t '.ok'
|
||||||
|
|
||||||
= f.button do
|
- if ENV['TWITTER_CONSUMER_KEY'] || Rails.env.development?
|
||||||
%em.fa.fa-thumbs-up
|
%fieldset
|
||||||
=t '.ok'
|
%legend
|
||||||
|
%em.fa.fa-twitter
|
||||||
|
Tweet
|
||||||
|
|
||||||
|
%h3=t '.tweet_helper'
|
||||||
|
|
||||||
|
= @event
|
||||||
|
= events_url @event
|
||||||
|
|
||||||
%fieldset
|
%fieldset
|
||||||
%legend=Event.model_name.human
|
%legend
|
||||||
|
%em.fa.fa-calendar
|
||||||
|
=Event.model_name.human
|
||||||
= render file: '/events/show'
|
= render file: '/events/show'
|
||||||
|
@ -175,17 +175,16 @@ Example: `%{daylimit}`"
|
|||||||
update:
|
update:
|
||||||
ok: Updated events
|
ok: Updated events
|
||||||
validate:
|
validate:
|
||||||
title: Event validation
|
title: Do you confirm this event validation?
|
||||||
warning: Warning, this event is of national scope!
|
warning: Warning, this event is of national scope!
|
||||||
question: Do you confirm this event validation?
|
|
||||||
ok: Yes
|
ok: Yes
|
||||||
ko: Moderation
|
ko: Moderation
|
||||||
|
tweet_helper: A tweet will be published, here is its content
|
||||||
accept:
|
accept:
|
||||||
ok: Event accepted
|
ok: Event accepted
|
||||||
refuse:
|
refuse:
|
||||||
title: Event rejection
|
title: What motive do you wish to associate to this event's rejection?
|
||||||
motif: Motive
|
motif: Motive
|
||||||
question: What motive do you wish to associate to this event's rejection?
|
|
||||||
ok: Reject
|
ok: Reject
|
||||||
ko: Moderation
|
ko: Moderation
|
||||||
reason_r_1: Off-topic
|
reason_r_1: Off-topic
|
||||||
|
@ -159,17 +159,16 @@ Exemple: `%{daylimit}`"
|
|||||||
update:
|
update:
|
||||||
ok: Événement mis à jour
|
ok: Événement mis à jour
|
||||||
validate:
|
validate:
|
||||||
title: Validation de l'événement
|
title: Confirmez-vous la validation de cet événement?
|
||||||
warning: Attention, cet événement est à portée nationale!
|
warning: Attention, cet événement est à portée nationale!
|
||||||
question: Confirmez-vous la validation de cet événement?
|
|
||||||
ok: Oui
|
ok: Oui
|
||||||
ko: Modération
|
ko: Modération
|
||||||
|
tweet_helper: Un tweet sera publié, dont voici le contenu
|
||||||
accept:
|
accept:
|
||||||
ok: Événement accepté
|
ok: Événement accepté
|
||||||
refuse:
|
refuse:
|
||||||
title: Rejet de l'événement
|
title: Quel motif souhaitez-vous associer au rejet de cet événement?
|
||||||
motif: Motif
|
motif: Motif
|
||||||
question: Quel motif souhaitez-vous associer au rejet de cet événement?
|
|
||||||
ok: Rejeter
|
ok: Rejeter
|
||||||
ko: Modération
|
ko: Modération
|
||||||
reason_r_1: Hors sujet
|
reason_r_1: Hors sujet
|
||||||
|
Loading…
Reference in New Issue
Block a user