From 01cf6431a97f6a159fdd44fcdf65619e49a3fc9b Mon Sep 17 00:00:00 2001 From: Patrick Gansterer Date: Wed, 17 Feb 2016 12:26:21 +0100 Subject: [PATCH 1/4] Add messagegroup Messagegroups are a new kind of group. Every user can join and leave such a group on her own. They are useful to create topics for mails. E.g. if there is a weekly newsletter we can create a new messagegroup for it and every user which is interested in receiving the newsletter can join the corresponding group. --- app/views/shared/_group.html.haml | 5 ++- .../admin/messagegroups_controller.rb | 20 +++++++++ .../controllers/messagegroups_controller.rb | 18 ++++++++ plugins/messages/app/models/messagegroup.rb | 7 ++++ .../views/admin/messagegroups/_form.html.haml | 5 +++ .../messagegroups/_messagegroups.html.haml | 18 ++++++++ .../views/admin/messagegroups/edit.html.haml | 3 ++ .../views/admin/messagegroups/index.html.haml | 14 +++++++ .../views/admin/messagegroups/index.js.haml | 1 + .../views/admin/messagegroups/new.html.haml | 3 ++ .../views/admin/messagegroups/show.html.haml | 6 +++ .../messagegroups/_messagegroup.html.haml | 8 ++++ .../app/views/messagegroups/index.html.haml | 5 +++ plugins/messages/config/locales/en.yml | 42 +++++++++++++++++++ .../messages/lib/foodsoft_messages/engine.rb | 26 ++++++++---- 15 files changed, 172 insertions(+), 9 deletions(-) create mode 100644 plugins/messages/app/controllers/admin/messagegroups_controller.rb create mode 100644 plugins/messages/app/controllers/messagegroups_controller.rb create mode 100644 plugins/messages/app/models/messagegroup.rb create mode 100644 plugins/messages/app/views/admin/messagegroups/_form.html.haml create mode 100644 plugins/messages/app/views/admin/messagegroups/_messagegroups.html.haml create mode 100644 plugins/messages/app/views/admin/messagegroups/edit.html.haml create mode 100644 plugins/messages/app/views/admin/messagegroups/index.html.haml create mode 100644 plugins/messages/app/views/admin/messagegroups/index.js.haml create mode 100644 plugins/messages/app/views/admin/messagegroups/new.html.haml create mode 100644 plugins/messages/app/views/admin/messagegroups/show.html.haml create mode 100644 plugins/messages/app/views/messagegroups/_messagegroup.html.haml create mode 100644 plugins/messages/app/views/messagegroups/index.html.haml diff --git a/app/views/shared/_group.html.haml b/app/views/shared/_group.html.haml index 5956ed9d..73f91a76 100644 --- a/app/views/shared/_group.html.haml +++ b/app/views/shared/_group.html.haml @@ -6,8 +6,9 @@ %dd=h group.contact %dt= heading_helper(Ordergroup, :contact_address) + ':' %dd= link_to_gmaps group.contact_address - %dt= t('.access') + ':' - %dd= format_roles(group) + - if group.is_a?(Workgroup) + %dt= t('.access') + ':' + %dd= format_roles(group) %dt= heading_helper(Ordergroup, :user_tokens) + ':' %dd - members = group.users diff --git a/plugins/messages/app/controllers/admin/messagegroups_controller.rb b/plugins/messages/app/controllers/admin/messagegroups_controller.rb new file mode 100644 index 00000000..dcbeff98 --- /dev/null +++ b/plugins/messages/app/controllers/admin/messagegroups_controller.rb @@ -0,0 +1,20 @@ +# encoding: utf-8 +class Admin::MessagegroupsController < Admin::BaseController + inherit_resources + + def index + @messagegroups = Messagegroup.order('name ASC') + # if somebody uses the search field: + @messagegroups = @messagegroups.where('name LIKE ?', "%#{params[:query]}%") unless params[:query].blank? + + @messagegroups = @messagegroups.page(params[:page]).per(@per_page) + end + + def destroy + @messagegroup = Messagegroup.find(params[:id]) + @messagegroup.destroy + redirect_to admin_messagegroups_url, notice: t('admin.messagegroups.destroy.notice') + rescue => error + redirect_to admin_messagegroups_url, alert: t('admin.messagegroups.destroy.error', error: error.message) + end +end diff --git a/plugins/messages/app/controllers/messagegroups_controller.rb b/plugins/messages/app/controllers/messagegroups_controller.rb new file mode 100644 index 00000000..c3d66d6a --- /dev/null +++ b/plugins/messages/app/controllers/messagegroups_controller.rb @@ -0,0 +1,18 @@ +class MessagegroupsController < ApplicationController + + def index + @messagegroups = Messagegroup.order("name") + end + + def join + @messagegroup = Messagegroup.find(params[:id]) + @messagegroup.users << current_user + redirect_to messagegroups_url, :notice => I18n.t('messagegroups.join.notice') + end + + def leave + @messagegroup = Messagegroup.find(params[:id]) + @messagegroup.users.destroy(current_user) + redirect_to messagegroups_url, :notice => I18n.t('messagegroups.leave.notice') + end +end diff --git a/plugins/messages/app/models/messagegroup.rb b/plugins/messages/app/models/messagegroup.rb new file mode 100644 index 00000000..d5b66576 --- /dev/null +++ b/plugins/messages/app/models/messagegroup.rb @@ -0,0 +1,7 @@ +# encoding: utf-8 +class Messagegroup < Group + + validates_uniqueness_of :name + + protected +end diff --git a/plugins/messages/app/views/admin/messagegroups/_form.html.haml b/plugins/messages/app/views/admin/messagegroups/_form.html.haml new file mode 100644 index 00000000..da67ff66 --- /dev/null +++ b/plugins/messages/app/views/admin/messagegroups/_form.html.haml @@ -0,0 +1,5 @@ += simple_form_for [:admin, @messagegroup] do |f| + = render 'shared/group_form_fields', :f => f + .form-actions + = f.button :submit + = link_to t('ui.or_cancel'), :back diff --git a/plugins/messages/app/views/admin/messagegroups/_messagegroups.html.haml b/plugins/messages/app/views/admin/messagegroups/_messagegroups.html.haml new file mode 100644 index 00000000..6b3b1733 --- /dev/null +++ b/plugins/messages/app/views/admin/messagegroups/_messagegroups.html.haml @@ -0,0 +1,18 @@ +- if Messagegroup.count > 20 + = items_per_page += pagination_links_remote @messagegroups +%table.table.table-striped + %thead + %tr + %th= t '.name' + %th= t '.members' + %th= t 'ui.actions' + %tbody + - for messagegroup in @messagegroups + %tr + %td= link_to messagegroup.name, [:admin, messagegroup] + %td= messagegroup.users.size + %td + = link_to t('ui.edit'), edit_admin_messagegroup_path(messagegroup), class: 'btn btn-mini' + = link_to t('ui.delete'), [:admin, messagegroup], :data => {:confirm => t('admin.confirm', name: messagegroup.name)}, + :method => :delete, class: 'btn btn-mini btn-danger' diff --git a/plugins/messages/app/views/admin/messagegroups/edit.html.haml b/plugins/messages/app/views/admin/messagegroups/edit.html.haml new file mode 100644 index 00000000..7724f1b7 --- /dev/null +++ b/plugins/messages/app/views/admin/messagegroups/edit.html.haml @@ -0,0 +1,3 @@ +- title t '.title' + += render 'form' diff --git a/plugins/messages/app/views/admin/messagegroups/index.html.haml b/plugins/messages/app/views/admin/messagegroups/index.html.haml new file mode 100644 index 00000000..03ef11f9 --- /dev/null +++ b/plugins/messages/app/views/admin/messagegroups/index.html.haml @@ -0,0 +1,14 @@ +- title t '.title' + +- content_for :actionbar do + = link_to t('.new_messagegroup'), new_admin_messagegroup_path, class: 'btn btn-primary' + +- content_for :sidebar do + %p= t('.first_paragraph', url: link_to(t('.new_messagegroups'), new_admin_messagegroup_path)).html_safe +.well.well-small + = form_tag admin_messagegroups_path, :method => :get, :remote => true, + 'data-submit-onchange' => true, class: 'form-search' do + = text_field_tag :query, params[:query], class: 'input-medium search-query', + placeholder: t('admin.search_placeholder') +#messagegroups + = render "messagegroups" diff --git a/plugins/messages/app/views/admin/messagegroups/index.js.haml b/plugins/messages/app/views/admin/messagegroups/index.js.haml new file mode 100644 index 00000000..a005f7a9 --- /dev/null +++ b/plugins/messages/app/views/admin/messagegroups/index.js.haml @@ -0,0 +1 @@ +$('#messagegroups').html('#{escape_javascript(render("messagegroups"))}'); diff --git a/plugins/messages/app/views/admin/messagegroups/new.html.haml b/plugins/messages/app/views/admin/messagegroups/new.html.haml new file mode 100644 index 00000000..7724f1b7 --- /dev/null +++ b/plugins/messages/app/views/admin/messagegroups/new.html.haml @@ -0,0 +1,3 @@ +- title t '.title' + += render 'form' diff --git a/plugins/messages/app/views/admin/messagegroups/show.html.haml b/plugins/messages/app/views/admin/messagegroups/show.html.haml new file mode 100644 index 00000000..6e77fea2 --- /dev/null +++ b/plugins/messages/app/views/admin/messagegroups/show.html.haml @@ -0,0 +1,6 @@ +- title t '.title', name: @messagegroup.name + +%section= render 'shared/group', group: @messagegroup += link_to t('ui.edit'), edit_admin_messagegroup_path(@messagegroup), class: 'btn' += link_to t('ui.delete'), [:admin, @messagegroup], :data => {:confirm => t('.confirm')}, :method => :delete, class: 'btn btn-danger' += link_to t('.send_message'), new_message_path(:message => {:group_id => @messagegroup.id}), class: 'btn' diff --git a/plugins/messages/app/views/messagegroups/_messagegroup.html.haml b/plugins/messages/app/views/messagegroups/_messagegroup.html.haml new file mode 100644 index 00000000..f3ea5163 --- /dev/null +++ b/plugins/messages/app/views/messagegroups/_messagegroup.html.haml @@ -0,0 +1,8 @@ +%section.well + %h3= messagegroup.name + = render :partial => 'shared/group', :locals => { :group => messagegroup } + = link_to_new_message(message_params: {group_id: messagegroup.id}) + - if messagegroup.member?(current_user) + = link_to t('.leave'), leave_messagegroup_path(messagegroup), class: 'btn', method: :post + - else + = link_to t('.join'), join_messagegroup_path(messagegroup), class: 'btn', method: :post diff --git a/plugins/messages/app/views/messagegroups/index.html.haml b/plugins/messages/app/views/messagegroups/index.html.haml new file mode 100644 index 00000000..fd440e82 --- /dev/null +++ b/plugins/messages/app/views/messagegroups/index.html.haml @@ -0,0 +1,5 @@ +- title t('.title') + += t('.body').html_safe + += render :partial => "messagegroup", :collection => @messagegroups diff --git a/plugins/messages/config/locales/en.yml b/plugins/messages/config/locales/en.yml index 9c1bb67f..74133c84 100644 --- a/plugins/messages/config/locales/en.yml +++ b/plugins/messages/config/locales/en.yml @@ -8,9 +8,35 @@ en: recipient_tokens: Recipients sent_to_all: Send to all members subject: Subject + messagegroup: + description: Description + name: Name + user_tokens: Members models: message: Message + messagegroup: Messagegroup admin: + messagegroups: + destroy: + error: 'Messagegroup could not be deleted: %{error}' + notice: Messagegroup was deleted + edit: + title: Edit messagegroup + index: + first_paragraph: Here you can create %{url}, edit and delete them. + new_messagegroup: Create new messagegroup + new_messagegroups: new messagegroups + title: Messagegroups + new: + title: Create messagegroup + show: + confirm: Are you sure? + edit: Edit group/members + send_message: Send message + title: Messagegroup %{name} + messagegroups: + members: Members + name: Name ordergroups: show: send_message: Send message @@ -39,6 +65,19 @@ en: view_all: See all messages start_nav: write_message: Write message + messagegroups: + index: + body: You can join or leave any of the messagegroups. + title: Messagegroups + join: + error: 'Messagegroup could not be joined: %{error}' + notice: Messagegroup was joined + leave: + error: 'Messagegroup could not be left: %{error}' + notice: Messagegroup was left + messagegroup: + join: Join messagegroup + leave: Leave messagegroup messages: create: notice: Message is saved and will be sent. @@ -99,4 +138,7 @@ en: ' navigation: + admin: + messagegroups: Messagegroups + messagegroups: Messagegroups messages: Messages diff --git a/plugins/messages/lib/foodsoft_messages/engine.rb b/plugins/messages/lib/foodsoft_messages/engine.rb index 527b5603..74aa7c58 100644 --- a/plugins/messages/lib/foodsoft_messages/engine.rb +++ b/plugins/messages/lib/foodsoft_messages/engine.rb @@ -2,13 +2,25 @@ module FoodsoftMessages class Engine < ::Rails::Engine def navigation(primary, context) return unless FoodsoftMessages.enabled? - return if primary[:foodcoop].nil? - sub_nav = primary[:foodcoop].sub_navigation - sub_nav.items << - SimpleNavigation::Item.new(primary, :message_threads, I18n.t('navigation.messages'), context.message_threads_path) - # move to right before tasks item - if i = sub_nav.items.index(sub_nav[:tasks]) - sub_nav.items.insert(i, sub_nav.items.delete_at(-1)) + unless primary[:foodcoop].nil? + sub_nav = primary[:foodcoop].sub_navigation + sub_nav.items << + SimpleNavigation::Item.new(primary, :messagegroups, I18n.t('navigation.messagegroups'), context.messagegroups_path) + sub_nav.items << + SimpleNavigation::Item.new(primary, :messages, I18n.t('navigation.messages'), context.messages_path) + # move to right before tasks item + if i = sub_nav.items.index(sub_nav[:tasks]) + sub_nav.items.insert(i, sub_nav.items.delete_at(-1)) + end + end + unless primary[:admin].nil? + sub_nav = primary[:admin].sub_navigation + sub_nav.items << + SimpleNavigation::Item.new(primary, :messagegroups, I18n.t('navigation.admin.messagegroups'), context.admin_messagegroups_path) + # move to right before config item + if i = sub_nav.items.index(sub_nav[:config]) + sub_nav.items.insert(i, sub_nav.items.delete_at(-1)) + end end end From 179f442a87840b7328088ba40776cfa8107b9f57 Mon Sep 17 00:00:00 2001 From: wvengen Date: Fri, 4 Mar 2016 14:26:56 +0100 Subject: [PATCH 2/4] Small message group improvements --- .../add_messages_prefs.html.haml.deface | 7 ++- .../views/admin/messagegroups/index.html.haml | 1 + .../app/views/message_threads/index.html.haml | 4 +- .../app/views/messagegroups/index.html.haml | 2 +- .../app/views/messages/_actionbar.haml | 8 ++++ .../app/views/messages/index.html.haml | 5 +- plugins/messages/config/locales/de.yml | 10 +++- plugins/messages/config/locales/en.yml | 48 +++++++++++-------- .../messages/lib/foodsoft_messages/engine.rb | 4 +- 9 files changed, 55 insertions(+), 34 deletions(-) create mode 100644 plugins/messages/app/views/messages/_actionbar.haml diff --git a/plugins/messages/app/overrides/shared/_user_form_fields/add_messages_prefs.html.haml.deface b/plugins/messages/app/overrides/shared/_user_form_fields/add_messages_prefs.html.haml.deface index 4769106c..b41ef105 100644 --- a/plugins/messages/app/overrides/shared/_user_form_fields/add_messages_prefs.html.haml.deface +++ b/plugins/messages/app/overrides/shared/_user_form_fields/add_messages_prefs.html.haml.deface @@ -1,4 +1,9 @@ -/ insert_before 'erb:contains("simple_fields_for :notify")' +/ insert_after 'erb:contains("notify.input \'upcoming_tasks\'")' - if FoodsoftMessages.enabled? = s.simple_fields_for :messages, defaults: { inline_label: true, label: false } do |messages| = messages.input 'send_as_email', as: :boolean, input_html: { checked: f.object.settings.messages['send_as_email'] } + - if Messagegroup.any? + .controls + = link_to messagegroups_path do + = t('shared.user_form_fields.messagegroups') + %i.icon.icon-chevron-right diff --git a/plugins/messages/app/views/admin/messagegroups/index.html.haml b/plugins/messages/app/views/admin/messagegroups/index.html.haml index 03ef11f9..2be2cd20 100644 --- a/plugins/messages/app/views/admin/messagegroups/index.html.haml +++ b/plugins/messages/app/views/admin/messagegroups/index.html.haml @@ -5,6 +5,7 @@ - content_for :sidebar do %p= t('.first_paragraph', url: link_to(t('.new_messagegroups'), new_admin_messagegroup_path)).html_safe + %p= t '.second_paragraph' .well.well-small = form_tag admin_messagegroups_path, :method => :get, :remote => true, 'data-submit-onchange' => true, class: 'form-search' do diff --git a/plugins/messages/app/views/message_threads/index.html.haml b/plugins/messages/app/views/message_threads/index.html.haml index ff275ae1..a108897a 100644 --- a/plugins/messages/app/views/message_threads/index.html.haml +++ b/plugins/messages/app/views/message_threads/index.html.haml @@ -1,8 +1,6 @@ - title t('.title') -- content_for :actionbar do - = link_to t('.messages'), messages_path, class: 'btn' - = link_to t('.new'), new_message_path, class: 'btn btn-primary' += render 'messages/actionbar', active: 'message_threads' = render 'groupmessage_threads', group: nil, name: t('.other'), id: 0 diff --git a/plugins/messages/app/views/messagegroups/index.html.haml b/plugins/messages/app/views/messagegroups/index.html.haml index fd440e82..c588e515 100644 --- a/plugins/messages/app/views/messagegroups/index.html.haml +++ b/plugins/messages/app/views/messagegroups/index.html.haml @@ -1,5 +1,5 @@ - title t('.title') -= t('.body').html_safe +%p= t('.body') = render :partial => "messagegroup", :collection => @messagegroups diff --git a/plugins/messages/app/views/messages/_actionbar.haml b/plugins/messages/app/views/messages/_actionbar.haml new file mode 100644 index 00000000..4e3b44c9 --- /dev/null +++ b/plugins/messages/app/views/messages/_actionbar.haml @@ -0,0 +1,8 @@ +- content_for :actionbar do + .btn-group + = link_to message_threads_path, class: "btn #{'active' if active == 'message_threads'}" do + %i.icon.icon-align-left{title: t('.message_threads')} + = link_to messages_path, class: "btn #{'active' if active == 'messages'}" do + %i.icon.icon-align-justify{title: t('.messages')} + = link_to t('.messagegroups'), messagegroups_path, class: 'btn' + = link_to t('.new'), new_message_path, class: 'btn btn-primary' diff --git a/plugins/messages/app/views/messages/index.html.haml b/plugins/messages/app/views/messages/index.html.haml index b2126638..08c3b0d5 100644 --- a/plugins/messages/app/views/messages/index.html.haml +++ b/plugins/messages/app/views/messages/index.html.haml @@ -1,7 +1,6 @@ - title t('.title') -- content_for :actionbar do - = link_to t('.message_threads'), message_threads_path, class: 'btn' - = link_to t('.new'), new_message_path, class: 'btn btn-primary' += render 'actionbar', active: 'messages' + #messages = render 'messages', messages: @messages, pagination: true diff --git a/plugins/messages/config/locales/de.yml b/plugins/messages/config/locales/de.yml index 08584d44..8fb44fd1 100644 --- a/plugins/messages/config/locales/de.yml +++ b/plugins/messages/config/locales/de.yml @@ -18,6 +18,7 @@ de: first_paragraph: Hier kannst du %{url} anlegen, Gruppen bearbeiten und löschen. new_messagegroup: Neue Nachrichtengruppe anlegen new_messagegroups: neue Nachrichtengruppe + second_paragraph: Eine Nachrichtengruppe ist wie ein Mail-Verteilen. Mitglieder können Verteiler in ihrem Profil abonnieren (und auch wieder abbestellen) an denen sie interessiert sind. title: Nachrichtengruppen new: title: Nachrichtengruppe anlegen @@ -47,6 +48,12 @@ de: join: Nachrichtengruppe beitreten leave: Nachrichtengruppe verlassen messages: + actionbar: + message_threads: + messagegroups: + messages: + create: + notice: Message is saved and will be sent. index: message_threads: Nachrichtenverläufe thread: @@ -56,7 +63,6 @@ de: groupmessage_threads: show_message_threads: Alle Nachrichtenverläufe anzeigen index: - messages: Nachrichten new: Neue Nachricht other: Allgemeine Nachrichten title: Nachrichtenverläufe @@ -67,7 +73,7 @@ de: started_by: Gestartet von show: other: Allgemeine Nachrichten + reply: Antworten navigation: admin: messagegroups: Nachrichtengruppen - messagegroups: Nachrichtengruppen diff --git a/plugins/messages/config/locales/en.yml b/plugins/messages/config/locales/en.yml index 74133c84..d7deed05 100644 --- a/plugins/messages/config/locales/en.yml +++ b/plugins/messages/config/locales/en.yml @@ -14,26 +14,27 @@ en: user_tokens: Members models: message: Message - messagegroup: Messagegroup + messagegroup: Message group admin: messagegroups: destroy: - error: 'Messagegroup could not be deleted: %{error}' - notice: Messagegroup was deleted + error: 'Message group could not be deleted: %{error}' + notice: Message group was deleted edit: - title: Edit messagegroup + title: Edit message group index: first_paragraph: Here you can create %{url}, edit and delete them. - new_messagegroup: Create new messagegroup - new_messagegroups: new messagegroups - title: Messagegroups + new_messagegroup: Create new message group + new_messagegroups: new message groups + second_paragraph: "A message group is like a mailing-list. Members can subscribe to (and unsubscribe from) the lists they're interested in, from their profile." + title: Message groups new: - title: Create messagegroup + title: Create message group show: confirm: Are you sure? edit: Edit group/members send_message: Send message - title: Messagegroup %{name} + title: Message group %{name} messagegroups: members: Members name: Name @@ -61,28 +62,31 @@ en: home: index: messages: - title: Newest Messages + title: Newest messages view_all: See all messages start_nav: write_message: Write message messagegroups: index: - body: You can join or leave any of the messagegroups. - title: Messagegroups + body: 'A message group is like a mailing-list: you can join (or leave) any of them to receive the updates sent to that group.' + title: Message groups join: - error: 'Messagegroup could not be joined: %{error}' - notice: Messagegroup was joined + error: 'Could not join message group: %{error}' + notice: Joined message group leave: error: 'Messagegroup could not be left: %{error}' - notice: Messagegroup was left + notice: Left message group messagegroup: - join: Join messagegroup - leave: Leave messagegroup + join: Join message group + leave: Leave message group messages: + actionbar: + message_threads: Show as threads + messagegroups: Subscribe to groups + messages: Show as list create: notice: Message is saved and will be sent. index: - message_threads: View as threads new: New message title: Messages messages: @@ -116,11 +120,11 @@ en: title: Show message thread: all_message_threads: All message threads + reply: Reply message_threads: groupmessage_threads: show_message_threads: show all index: - messages: View as messages new: New message other: General title: Message threads @@ -139,6 +143,8 @@ en: ' navigation: admin: - messagegroups: Messagegroups - messagegroups: Messagegroups + messagegroups: Message groups messages: Messages + shared: + user_form_fields: + messagegroups: Join or leave message groups diff --git a/plugins/messages/lib/foodsoft_messages/engine.rb b/plugins/messages/lib/foodsoft_messages/engine.rb index 74aa7c58..237197cf 100644 --- a/plugins/messages/lib/foodsoft_messages/engine.rb +++ b/plugins/messages/lib/foodsoft_messages/engine.rb @@ -5,9 +5,7 @@ module FoodsoftMessages unless primary[:foodcoop].nil? sub_nav = primary[:foodcoop].sub_navigation sub_nav.items << - SimpleNavigation::Item.new(primary, :messagegroups, I18n.t('navigation.messagegroups'), context.messagegroups_path) - sub_nav.items << - SimpleNavigation::Item.new(primary, :messages, I18n.t('navigation.messages'), context.messages_path) + SimpleNavigation::Item.new(primary, :messages, I18n.t('navigation.messages'), context.message_threads_path) # move to right before tasks item if i = sub_nav.items.index(sub_nav[:tasks]) sub_nav.items.insert(i, sub_nav.items.delete_at(-1)) From 5d9e1845b7f382b81ef4a8cf5c5e1caa3d9debbf Mon Sep 17 00:00:00 2001 From: wvengen Date: Mon, 7 Mar 2016 21:06:49 +0100 Subject: [PATCH 3/4] Fix i18n key typo --- config/locales/de.yml | 2 +- config/locales/en.yml | 2 +- config/locales/fr.yml | 2 +- config/locales/nl.yml | 2 +- plugins/messages/app/models/message.rb | 4 ++-- plugins/messages/app/views/messages/new.haml | 6 +++--- plugins/messages/config/locales/en.yml | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/config/locales/de.yml b/config/locales/de.yml index 1d5160be..83ab1b97 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -70,7 +70,7 @@ de: group_id: Gruppe private: Privat recipient_tokens: Empfänger_innen - sent_to_all: An alle Mitglieder schicken + send_to_all: An alle Mitglieder schicken subject: Betreff order: closed_by: Abgerechnet von diff --git a/config/locales/en.yml b/config/locales/en.yml index 8cb8ca8d..ef93fe22 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -70,7 +70,7 @@ en: group_id: Group private: Private recipient_tokens: Recipients - sent_to_all: Send to all members + send_to_all: Send to all members subject: Subject order: boxfill: Fill boxes after diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 6eb89785..5b18cb95 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -70,7 +70,7 @@ fr: group_id: Cellule ou équipe private: Privé recipient_tokens: Destinataires - sent_to_all: Envoyer à tous les membres + send_to_all: Envoyer à tous les membres subject: Sujet order: closed_by: Décompté par diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 5ce39c3f..da9cfa0b 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -70,7 +70,7 @@ nl: group_id: Groep private: Privé recipient_tokens: Geadresseerden - sent_to_all: Aan alle leden sturen + send_to_all: Aan alle leden sturen subject: Onderwerp order: closed_by: Afgerekend door diff --git a/plugins/messages/app/models/message.rb b/plugins/messages/app/models/message.rb index bfe00589..e61528fd 100644 --- a/plugins/messages/app/models/message.rb +++ b/plugins/messages/app/models/message.rb @@ -6,7 +6,7 @@ class Message < ActiveRecord::Base belongs_to :reply_to_message, :class_name => "Message", :foreign_key => "reply_to" serialize :recipients_ids, Array - attr_accessor :sent_to_all, :recipient_tokens + attr_accessor :send_to_all, :recipient_tokens scope :pending, -> { where(:email_state => 0) } scope :sent, -> { where(:email_state => 1) } @@ -35,7 +35,7 @@ class Message < ActiveRecord::Base def clean_up_recipient_ids add_recipients Group.find(group_id).users unless group_id.blank? self.recipients_ids = recipients_ids.uniq.reject { |id| id.blank? } unless recipients_ids.nil? - self.recipients_ids = User.all.collect(&:id) if sent_to_all == "1" + self.recipients_ids = User.all.collect(&:id) if send_to_all == "1" end def add_recipients(users) diff --git a/plugins/messages/app/views/messages/new.haml b/plugins/messages/app/views/messages/new.haml index 40a2d67b..b50f18fd 100644 --- a/plugins/messages/app/views/messages/new.haml +++ b/plugins/messages/app/views/messages/new.haml @@ -10,7 +10,7 @@ theme: 'facebook' }); - $('#message_sent_to_all').on('change', function() { + $('#message_send_to_all').on('change', function() { if ($(this).is(':checked')) { $('#recipients').slideUp(); } else { @@ -18,7 +18,7 @@ } }); // make sure state is correct when loading - $('#recipients').toggle(!$('#message_sent_to_all').is(':checked')); + $('#recipients').toggle(!$('#message_send_to_all').is(':checked')); }); - title t('.title') @@ -30,7 +30,7 @@ %p= t('.reply_to', link: link_to(t('.message'), message_path(@message.reply_to))).html_safe - if FoodsoftConfig[:mailing_list].blank? - = f.input :sent_to_all, :as => :boolean + = f.input :send_to_all, :as => :boolean - else %b= t('.list.desc', list: mail_to(FoodsoftConfig[:mailing_list])).html_safe %br/ diff --git a/plugins/messages/config/locales/en.yml b/plugins/messages/config/locales/en.yml index d7deed05..a660e426 100644 --- a/plugins/messages/config/locales/en.yml +++ b/plugins/messages/config/locales/en.yml @@ -6,7 +6,7 @@ en: group_id: Group private: Private recipient_tokens: Recipients - sent_to_all: Send to all members + send_to_all: Send to all members subject: Subject messagegroup: description: Description From 80ab359860591cf363cc8157a20f0cb6269772dc Mon Sep 17 00:00:00 2001 From: wvengen Date: Mon, 7 Mar 2016 22:17:18 +0100 Subject: [PATCH 4/4] Correct messages i18n --- .../app/controllers/messages_controller.rb | 2 +- .../messages/app/mailers/messages_mailer.rb | 4 ++-- ...est_public_messages_index.html.haml.deface | 5 +---- .../add_messages_prefs.html.haml.deface | 2 +- .../messagegroups/_messagegroups.html.haml | 4 ++-- .../views/admin/messagegroups/show.html.haml | 2 +- plugins/messages/config/locales/de.yml | 19 ++++++----------- plugins/messages/config/locales/en.yml | 21 ++++++++++--------- 8 files changed, 25 insertions(+), 34 deletions(-) diff --git a/plugins/messages/app/controllers/messages_controller.rb b/plugins/messages/app/controllers/messages_controller.rb index f05c4335..6d8b25aa 100644 --- a/plugins/messages/app/controllers/messages_controller.rb +++ b/plugins/messages/app/controllers/messages_controller.rb @@ -24,7 +24,7 @@ class MessagesController < ApplicationController @message.body = I18n.t('messages.model.reply_header', :user => original_message.sender.display, :when => I18n.l(original_message.created_at, :format => :short)) + "\n" original_message.body.each_line{ |l| @message.body += I18n.t('messages.model.reply_indent', :line => l) } else - redirect_to new_message_url, alert: 'Nachricht ist privat!' + redirect_to new_message_url, alert: I18n.t('messages.new.error_private') end end end diff --git a/plugins/messages/app/mailers/messages_mailer.rb b/plugins/messages/app/mailers/messages_mailer.rb index a793d83e..85695050 100644 --- a/plugins/messages/app/mailers/messages_mailer.rb +++ b/plugins/messages/app/mailers/messages_mailer.rb @@ -7,14 +7,14 @@ class MessagesMailer < Mailer reply_email_domain = FoodsoftConfig[:reply_email_domain] if reply_email_domain hash = message.mail_hash_for_user recipient - reply_to = "Foodsoft <#{FoodsoftConfig.scope}.#{message.id}.#{recipient.id}.#{hash}@#{reply_email_domain}>" + reply_to = "#{I18n.t('layouts.foodsoft')} <#{FoodsoftConfig.scope}.#{message.id}.#{recipient.id}.#{hash}@#{reply_email_domain}>" else reply_to = "#{show_user(message.sender)} <#{message.sender.email}>" end mail subject: "[#{FoodsoftConfig[:name]}] " + message.subject, to: recipient.email, - from: "#{show_user(message.sender)} via Foodsoft <#{FoodsoftConfig[:email_sender]}>", + from: "#{show_user(message.sender)} via #{I18n.t('layouts.foodsoft')} <#{FoodsoftConfig[:email_sender]}>", reply_to: reply_to end end diff --git a/plugins/messages/app/overrides/home/index/latest_public_messages_index.html.haml.deface b/plugins/messages/app/overrides/home/index/latest_public_messages_index.html.haml.deface index d984b61c..b264102e 100644 --- a/plugins/messages/app/overrides/home/index/latest_public_messages_index.html.haml.deface +++ b/plugins/messages/app/overrides/home/index/latest_public_messages_index.html.haml.deface @@ -4,7 +4,4 @@ %section#messages %h2= t '.messages.title' = render 'messages/messages', messages: Message.pub.order('created_at DESC').limit(5), pagination: false - %p - = link_to t('.messages.view_all'), messages_path - != ' | ' - = link_to t('.message_threads.view_all'), message_threads_path + %p= raw t '.messages.view_all.text', messages: link_to(t('.messages.view_all.messages'), messages_path), threads: link_to(t('.messages.view_all.threads'), message_threads_path) diff --git a/plugins/messages/app/overrides/shared/_user_form_fields/add_messages_prefs.html.haml.deface b/plugins/messages/app/overrides/shared/_user_form_fields/add_messages_prefs.html.haml.deface index b41ef105..88ad9a8a 100644 --- a/plugins/messages/app/overrides/shared/_user_form_fields/add_messages_prefs.html.haml.deface +++ b/plugins/messages/app/overrides/shared/_user_form_fields/add_messages_prefs.html.haml.deface @@ -5,5 +5,5 @@ - if Messagegroup.any? .controls = link_to messagegroups_path do - = t('shared.user_form_fields.messagegroups') + = t '.messagegroups' %i.icon.icon-chevron-right diff --git a/plugins/messages/app/views/admin/messagegroups/_messagegroups.html.haml b/plugins/messages/app/views/admin/messagegroups/_messagegroups.html.haml index 6b3b1733..87b45b30 100644 --- a/plugins/messages/app/views/admin/messagegroups/_messagegroups.html.haml +++ b/plugins/messages/app/views/admin/messagegroups/_messagegroups.html.haml @@ -4,8 +4,8 @@ %table.table.table-striped %thead %tr - %th= t '.name' - %th= t '.members' + %th= Messagegroup.human_attribute_name :name + %th= Messagegroup.human_attribute_name :user_tokens %th= t 'ui.actions' %tbody - for messagegroup in @messagegroups diff --git a/plugins/messages/app/views/admin/messagegroups/show.html.haml b/plugins/messages/app/views/admin/messagegroups/show.html.haml index 6e77fea2..553b7e33 100644 --- a/plugins/messages/app/views/admin/messagegroups/show.html.haml +++ b/plugins/messages/app/views/admin/messagegroups/show.html.haml @@ -2,5 +2,5 @@ %section= render 'shared/group', group: @messagegroup = link_to t('ui.edit'), edit_admin_messagegroup_path(@messagegroup), class: 'btn' -= link_to t('ui.delete'), [:admin, @messagegroup], :data => {:confirm => t('.confirm')}, :method => :delete, class: 'btn btn-danger' += link_to t('ui.delete'), [:admin, @messagegroup], :data => {:confirm => t('ui.confirm_delete', name: @messagegroup.name)}, :method => :delete, class: 'btn btn-danger' = link_to t('.send_message'), new_message_path(:message => {:group_id => @messagegroup.id}), class: 'btn' diff --git a/plugins/messages/config/locales/de.yml b/plugins/messages/config/locales/de.yml index 8fb44fd1..55e642ff 100644 --- a/plugins/messages/config/locales/de.yml +++ b/plugins/messages/config/locales/de.yml @@ -23,17 +23,15 @@ de: new: title: Nachrichtengruppe anlegen show: - confirm: Bist Du sicher? - edit: Gruppe/Mitglieder bearbeiten send_message: Nachricht senden title: Nachrichtengruppe %{name} - messagegroups: - members: Mitglieder - name: Name home: index: - message_threads: - view_all: Alle Nachrichteverläufe anzeigen + messages: + view_all: + text: '%{messages} oder %{threads} anzeigen' + messages: + threads: messagegroups: index: body: Du kannst jede der Nachrichtengruppen beitreten oder sie wieder verlassen. @@ -52,10 +50,7 @@ de: message_threads: messagegroups: messages: - create: - notice: Message is saved and will be sent. - index: - message_threads: Nachrichtenverläufe + new: Neue Nachricht thread: all_message_threads: Alle Nachrichtenverläufe reply: Antworten @@ -63,7 +58,6 @@ de: groupmessage_threads: show_message_threads: Alle Nachrichtenverläufe anzeigen index: - new: Neue Nachricht other: Allgemeine Nachrichten title: Nachrichtenverläufe message_threads: @@ -73,7 +67,6 @@ de: started_by: Gestartet von show: other: Allgemeine Nachrichten - reply: Antworten navigation: admin: messagegroups: Nachrichtengruppen diff --git a/plugins/messages/config/locales/en.yml b/plugins/messages/config/locales/en.yml index a660e426..b006f78b 100644 --- a/plugins/messages/config/locales/en.yml +++ b/plugins/messages/config/locales/en.yml @@ -31,13 +31,8 @@ en: new: title: Create message group show: - confirm: Are you sure? - edit: Edit group/members send_message: Send message title: Message group %{name} - messagegroups: - members: Members - name: Name ordergroups: show: send_message: Send message @@ -63,7 +58,10 @@ en: index: messages: title: Newest messages - view_all: See all messages + view_all: + text: 'Show %{messages} or %{threads}' + messages: all messages + threads: threads start_nav: write_message: Write message messagegroups: @@ -84,10 +82,10 @@ en: message_threads: Show as threads messagegroups: Subscribe to groups messages: Show as list + new: New message create: notice: Message is saved and will be sent. index: - new: New message title: Messages messages: reply: Reply @@ -96,6 +94,7 @@ en: reply_indent: ! '> %{line}' reply_subject: ! 'Re: %{subject}' new: + error_private: Sorry, this message is private. hint_private: Message doesn’t show in Foodsoft mail inbox list: desc: ! 'Please send messages to all using the mailing-list: %{list}' @@ -125,13 +124,15 @@ en: groupmessage_threads: show_message_threads: show all index: - new: New message other: General title: Message threads + message_threads: + last_reply_at: Last replied at + last_reply_by: Last replied by + started_at: Started at + started_by: Started by show: - all_message_threads: All message threads other: General - reply: Reply messages_mailer: foodsoft_message: footer: ! 'Reply: %{reply_url}