diff --git a/app/controllers/admin/group_invitations_controller.rb b/app/controllers/admin/group_invitations_controller.rb index a7ac642..f7b99d4 100644 --- a/app/controllers/admin/group_invitations_controller.rb +++ b/app/controllers/admin/group_invitations_controller.rb @@ -58,7 +58,7 @@ def readers_from_csv(readerdata) csv = line.collect {|value| value ? value.gsub(/^ */, '').chomp : ''} input = {} input[:honorific] = csv.shift if Radiant::Config['reader.show_honorifics?'] - [:forename, :surname, :email, :phone].each {|field| input[field] = csv.shift} + [:forename, :surname, :email, :phone, :post_organisation].each {|field| input[field] = csv.shift} r = Reader.find_by_email(input[:email]) || Reader.new(input) r.create_password! # only for validation purposes: not saved nor passed through r.valid? # so that errors can be shown on the confirmation form diff --git a/app/views/admin/group_invitations/new.html.haml b/app/views/admin/group_invitations/new.html.haml index 57b17d6..d353080 100644 --- a/app/views/admin/group_invitations/new.html.haml +++ b/app/views/admin/group_invitations/new.html.haml @@ -13,7 +13,7 @@ %span.formnote - if Radiant::Config['reader.show_honorifics?'] title or rank, - forename, surname, email, [phone] + forename, surname, email, [phone], [organisation] = text_area_tag "readerlist", params[:readerlist], :class => "textarea", :style => "width: 100%; height: 240px;" %p.buttons diff --git a/app/views/admin/group_invitations/preview.html.haml b/app/views/admin/group_invitations/preview.html.haml index 98633ef..1bd07f0 100644 --- a/app/views/admin/group_invitations/preview.html.haml +++ b/app/views/admin/group_invitations/preview.html.haml @@ -17,6 +17,7 @@ %th= t('activerecord.attributes.reader.surname') %th= t('activerecord.attributes.reader.email') %th= t('activerecord.attributes.reader.phone') + %th= t('activerecord.attributes.reader.post_organisation') %tbody - i = 0 - @readers.each do |reader| @@ -35,6 +36,8 @@ = text_field_tag "reader_#{i}[email]", reader.email, :class => "preview#{ ' with_error' if reader.errors.on(:email)}", :title => reader.errors.on(:email) %td = text_field_tag "reader_#{i}[phone]", reader.phone, :class => "preview#{ ' with_error' if reader.errors.on(:phone)}", :title => reader.errors.on(:phone) + %td + = text_field_tag "reader_#{i}[post_organisation]", reader.post_organisation, :class => "preview#{ ' with_error' if reader.errors.on(:post_organisation)}", :title => reader.errors.on(:post_organisation) - else %tr.invite %td @@ -50,6 +53,8 @@ = text_field_tag "reader_#{i}[email]", reader.email, :class => "preview#{ ' with_error' if reader.errors.on(:email)}", :title => reader.errors.on(:email), :disabled => true %td = text_field_tag "reader_#{i}[phone]", reader.phone, :class => "preview#{ ' with_error' if reader.errors.on(:phone)}", :title => reader.errors.on(:phone), :disabled => true + %td + = text_field_tag "reader_#{i}[post_organisation]", reader.phone, :class => "preview#{ ' with_error' if reader.errors.on(:post_organisation)}", :title => reader.errors.on(:post_organisation), :disabled => true - i = i + 1 %p.buttons diff --git a/lib/message_tags.rb b/lib/message_tags.rb index fa0c314..388d149 100644 --- a/lib/message_tags.rb +++ b/lib/message_tags.rb @@ -54,6 +54,30 @@ class TagError < StandardError; end tag.locals.recipient.send(field) end end + + desc %{ + Displays the organisation recorded for the current recipient. +
+ } + tag "recipient:organisation" do |tag| + tag.locals.recipient.post_organisation + end + + desc %{ + Expands if the current recipient has an organisation. +
+ } + tag "recipient:if_organisation" do |tag| + tag.expand unless tag.locals.recipient.post_organisation.blank? + end + + desc %{ + Expands unless the current reader has an organisation. +
+ } + tag "recipient:unless_organisation" do |tag| + tag.expand if tag.locals.recipient.post_organisation.blank? + end desc %{ Only for use in email messages. Displays the password of the reader currently being emailed, if we still have it. diff --git a/lib/radiant-reader-extension.rb b/lib/radiant-reader-extension.rb index 6339b46..bc3ee1c 100644 --- a/lib/radiant-reader-extension.rb +++ b/lib/radiant-reader-extension.rb @@ -1,5 +1,5 @@ module RadiantReaderExtension - VERSION = '3.0.30' + VERSION = '3.0.31' SUMMARY = %q{Reader/viewer/visitor registration, login and access-control for Radiant CMS} DESCRIPTION = %q{Provides reader/member/user registration and management functions including password-reminder, group-based page access control and administrative email.} URL = "http://radiant.spanner.org/reader" diff --git a/lib/reader_tags.rb b/lib/reader_tags.rb index 35d2f7d..037862a 100644 --- a/lib/reader_tags.rb +++ b/lib/reader_tags.rb @@ -86,6 +86,30 @@ class TagError < StandardError; end end end + desc %{ + Displays the organisation recorded for the current reader. +
+ } + tag "reader:organisation" do |tag| + tag.locals.reader.post_organisation if tag.locals.reader + end + + desc %{ + Expands if the current reader has an organisation. +
+ } + tag "reader:if_organisation" do |tag| + tag.expand unless tag.locals.reader.post_organisation.blank? + end + + desc %{ + Expands unless the current reader has an organisation. +
+ } + tag "reader:unless_organisation" do |tag| + tag.expand if tag.locals.reader.post_organisation.blank? + end + desc %{ Displays the standard reader_welcome block, but only if a reader is present. For a block that shows an invitation to non-logged-in people, use @r:reader_welcome@