Skip to content

Commit

Permalink
organisation tags
Browse files Browse the repository at this point in the history
  • Loading branch information
will-r committed Nov 3, 2011
1 parent fbc94e8 commit 09e3903
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/group_invitations_controller.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/group_invitations/new.html.haml
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions app/views/admin/group_invitations/preview.html.haml
Expand Up @@ -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|
Expand All @@ -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
Expand All @@ -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
Expand Down
24 changes: 24 additions & 0 deletions lib/message_tags.rb
Expand Up @@ -54,6 +54,30 @@ class TagError < StandardError; end
tag.locals.recipient.send(field)
end
end

desc %{
Displays the organisation recorded for the current recipient.
<pre><code><r:reader:organisation /></code></pre>
}
tag "recipient:organisation" do |tag|
tag.locals.recipient.post_organisation
end

desc %{
Expands if the current recipient has an organisation.
<pre><code><r:reader:organisation /></code></pre>
}
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.
<pre><code><r:reader:organisation /></code></pre>
}
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.
Expand Down
2 changes: 1 addition & 1 deletion 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"
Expand Down
24 changes: 24 additions & 0 deletions lib/reader_tags.rb
Expand Up @@ -86,6 +86,30 @@ class TagError < StandardError; end
end
end

desc %{
Displays the organisation recorded for the current reader.
<pre><code><r:reader:organisation /></code></pre>
}
tag "reader:organisation" do |tag|
tag.locals.reader.post_organisation if tag.locals.reader
end

desc %{
Expands if the current reader has an organisation.
<pre><code><r:reader:organisation /></code></pre>
}
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.
<pre><code><r:reader:organisation /></code></pre>
}
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@
Expand Down

0 comments on commit 09e3903

Please sign in to comment.