Les écrans de modération avancent
This commit is contained in:
parent
f9cc4e012c
commit
450f52ef43
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
|
@ -0,0 +1,39 @@
|
|||
.moderations
|
||||
table.list
|
||||
width: 100%
|
||||
margin-top: 15px
|
||||
thead tr
|
||||
background-color: transparent
|
||||
td
|
||||
padding-top: 0.5em
|
||||
padding-bottom: 0.5em
|
||||
&.empty
|
||||
background-color: white
|
||||
pre
|
||||
width: 70%
|
||||
margin: auto
|
||||
padding: 5px
|
||||
overflow: auto
|
||||
text-align: left
|
||||
background-color: #eee
|
||||
em.author
|
||||
display: block
|
||||
font-size: smaller
|
||||
text-align: right
|
||||
font-style: italic
|
||||
margin-top: 15px
|
||||
|
||||
main > h3
|
||||
font-size: inherit
|
||||
line-height: 1.3em
|
||||
font-weight: normal
|
||||
margin-left: 5em
|
||||
margin-right: 5em
|
||||
background-color: #CCC
|
||||
|
||||
.box
|
||||
width: 70%
|
||||
margin: auto
|
||||
padding: 1em
|
||||
margin-bottom: 10px
|
||||
background-color: #CCC
|
|
@ -55,6 +55,12 @@ class EventsController < InheritedResources::Base
|
|||
# PATCH/PUT /events/1
|
||||
# PATCH/PUT /events/1.json
|
||||
def update
|
||||
if params[:visu]
|
||||
@event.attributes = params[:event]
|
||||
render action: 'edit'
|
||||
return
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
# This is a special case, required to handle the region attribute with same foreign key name
|
||||
@event.region = Region.find(params[:event][:region])
|
||||
|
@ -80,6 +86,7 @@ class EventsController < InheritedResources::Base
|
|||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def event_params
|
||||
params.require(:event).permit(:title, :start_time, :end_time, :description, :city, :locality, :url, :contact, :submitter, :tags)
|
||||
params.require(:event)
|
||||
.permit :title, :start_time, :end_time, :description, :city, :locality, :url, :contact, :submitter, :tags
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
class ModerationsController < InheritedResources::Base
|
||||
before_action :set_event, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
@events = Event.unscoped.where moderated: 0
|
||||
end
|
||||
|
||||
# PATCH/PUT /moderations/1
|
||||
# PATCH/PUT /moderations/1.json
|
||||
def update
|
||||
if params[:visu]
|
||||
@event.attributes = event_params
|
||||
render action: 'edit'
|
||||
return
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
if @event.update(event_params)
|
||||
format.html { redirect_to moderations_path, notice: 'Event was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: 'edit' }
|
||||
format.json { render json: @event.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def permitted_params
|
||||
params.permit event: [:title, :start_time, :end_time, :description, :city, :locality, :url, :contact, :submitter, :tags]
|
||||
end
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_event
|
||||
@event = Event.unscoped.find params[:id]
|
||||
@moderation = @event
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def event_params
|
||||
params.require(:event)
|
||||
.permit :title, :start_time, :end_time, :description, :city, :locality, :url, :contact, :submitter, :tags
|
||||
end
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module ModerationsHelper
|
||||
end
|
|
@ -1,5 +1,6 @@
|
|||
class Event < ActiveRecord::Base
|
||||
belongs_to :region, foreign_key: 'region'
|
||||
has_many :notes
|
||||
|
||||
validates_presence_of :region
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
class Note < ActiveRecord::Base
|
||||
belongs_to :event
|
||||
belongs_to :author, class_name: User
|
||||
end
|
|
@ -1,2 +1,3 @@
|
|||
class User < ActiveRecord::Base
|
||||
has_many :notes
|
||||
end
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
- if @event && params[:visu]
|
||||
%hr/
|
||||
= render file: '/events/show'
|
||||
%hr/
|
||||
|
||||
= form_for @event do |f|
|
||||
= form_for @event, url: moderation_path(@event) do |f|
|
||||
- if @event.errors.any?
|
||||
#error_explanation
|
||||
%h2= "#{pluralize(@event.errors.count, "error")} prohibited this event from being saved:"
|
||||
|
@ -11,6 +6,7 @@
|
|||
- @event.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
|
||||
- unless @event.id
|
||||
:markdown
|
||||
Cette page permet de soumettre un évènement dans l'Agenda du Libre. Celui-ci n'apparaîtra pas automatiquement dans l'Agenda, il sera tout d'abord validé par un modérateur. Un courrier électronique vous sera envoyé à l'adresse e-mail de contact donnée ci-dessous lorsque l'évènement aura été modéré.
|
||||
|
||||
|
@ -66,11 +62,11 @@
|
|||
.field
|
||||
= f.label Event.human_attribute_name :region
|
||||
= f.select :region,
|
||||
options_from_collection_for_select(Region.all, 'id', 'name', params[:region])
|
||||
options_from_collection_for_select(Region.all, 'id', 'name', @event.region.id)
|
||||
.field
|
||||
= f.label Event.human_attribute_name :locality
|
||||
= f.select :locality,
|
||||
options_for_select([[t('attributes.locality_0'), 0], [t('attributes.locality_1'), 1]], params[:locality])
|
||||
options_for_select([[t('attributes.locality_0'), 0], [t('attributes.locality_1'), 1]], @event.locality)
|
||||
.field
|
||||
%p.helper
|
||||
%em
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
%h2=t '.title'
|
||||
|
||||
- if @event && params[:visu]
|
||||
%hr/
|
||||
= render file: 'show'
|
||||
%hr/
|
||||
|
||||
= render 'form'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- if request.format == 'text/html'
|
||||
- if request.format == 'text/html' && controller.controller_name != 'moderations'
|
||||
%p#notice= notice
|
||||
|
||||
#lug-list
|
||||
|
|
|
@ -66,4 +66,4 @@
|
|||
= link_to t('.infos'), users_url
|
||||
= link_to t('.stats'), stats_regions_url
|
||||
= link_to t('.contact'), users_url
|
||||
= link_to t('.moderation'), users_url
|
||||
= link_to t('.moderation'), moderations_url
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
%h3
|
||||
= link_to t('.moderation'), moderations_path
|
||||
>>>
|
||||
=t '.preview'
|
||||
|
||||
.box= render file: '/events/show'
|
||||
|
||||
%h3
|
||||
= link_to t('.moderation'), moderations_path
|
||||
>>>
|
||||
=t '.edit'
|
||||
|
||||
.box= render '/events/form'
|
|
@ -0,0 +1,49 @@
|
|||
%h2=t '.title'
|
||||
|
||||
%strong<
|
||||
Modérateurs, merci de lire et de tenir compte des
|
||||
= link_to 'recommandations de modération', 'http://agendadulibre.org/moderation-howto.php'
|
||||
\.
|
||||
|
||||
%table.list
|
||||
%thead
|
||||
%tr
|
||||
%th= Event.human_attribute_name :title
|
||||
%th=t '.date'
|
||||
%th= Event.human_attribute_name :city
|
||||
%th= Event.human_attribute_name :region
|
||||
%th= Event.human_attribute_name :submission_time
|
||||
%th=t '.actions'
|
||||
|
||||
%tbody
|
||||
- @events.each do |event|
|
||||
%tr
|
||||
%td= event.title
|
||||
%td
|
||||
- if event.same_day?
|
||||
Le #{l event.start_time.to_date, format: :long},
|
||||
de #{l event.start_time, format: :hours} à #{l event.end_time, format: :hours}
|
||||
- else
|
||||
Du
|
||||
=l event.start_time, format: :at
|
||||
au
|
||||
#{l event.end_time, format: :at}
|
||||
%td= event.city
|
||||
%td= event.region.name
|
||||
%td= time_ago_in_words event.submission_time.to_date
|
||||
%td
|
||||
= link_to t('edit'), edit_moderation_path(event)
|
||||
\-
|
||||
= link_to t('validate'), edit_moderation_path(event)
|
||||
\-
|
||||
= link_to t('refuse'), edit_moderation_path(event)
|
||||
|
||||
- event.notes.each do |note|
|
||||
%tr
|
||||
%td.empty/
|
||||
%td(colspan="5")
|
||||
=raw note.contents
|
||||
%em.author
|
||||
=t '.posted_by',
|
||||
author: "#{note.author.firstname} #{note.author.lastname}",
|
||||
date: l(note.date, format: :at)
|
|
@ -1,9 +1,10 @@
|
|||
fr:
|
||||
show: Voir
|
||||
edit: Éditer
|
||||
validate: Valider
|
||||
refuse: Refuser
|
||||
destroy: Supprimer
|
||||
|
||||
|
||||
attributes:
|
||||
id: ID
|
||||
name: Nom
|
||||
|
@ -50,6 +51,7 @@ fr:
|
|||
url: URL
|
||||
contact: Contact
|
||||
submitter: Soumetteur
|
||||
submission_time: En attente depuis
|
||||
region:
|
||||
name_values:
|
||||
all: Toutes les régions
|
||||
|
@ -133,3 +135,13 @@ fr:
|
|||
zero:
|
||||
one: "<strong>Dans le passé</strong>, %{count} évènement:"
|
||||
other: "<strong>Dans le passé</strong>, %{count} évènements:"
|
||||
moderations:
|
||||
index:
|
||||
title: Évènements à modérer
|
||||
actions: Actions
|
||||
posted_by: Posté par %{author} le %{date}
|
||||
date: Date
|
||||
edit:
|
||||
moderation: Modération
|
||||
preview: Prévisualisation de l'évènement
|
||||
edit: Édition de l'évènement
|
||||
|
|
|
@ -6,6 +6,7 @@ AgendaDuLibreRails::Application.routes.draw do
|
|||
resources :events
|
||||
resources :users
|
||||
resources :tags, only: [ :index, :show ]
|
||||
resources :moderations
|
||||
|
||||
get 'ical.php' => 'events#index', format: :ics
|
||||
get ':format.php' => 'events#index'
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ModerationsControllerTest < ActionController::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
|
@ -0,0 +1,13 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
contents: MyText
|
||||
date: 2014-01-05 23:34:46
|
||||
event_id:
|
||||
author_id:
|
||||
|
||||
two:
|
||||
contents: MyText
|
||||
date: 2014-01-05 23:34:46
|
||||
event_id:
|
||||
author_id:
|
|
@ -0,0 +1,4 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ModerationsHelperTest < ActionView::TestCase
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class NoteTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
Reference in New Issue