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