Permalink
Browse files

various bugfixes

  • Loading branch information...
1 parent fedcb2b commit aa4d7e31903c80d0ffe77b454dd8698fcdf53516 @will-r will-r committed Nov 22, 2011
@@ -90,9 +90,8 @@ def create
end
def update
- @reader.attributes = params[:reader]
- @reader.clear_password = params[:reader][:password] if params[:reader][:password]
- if @reader.save
+ params[:reader][:clear_password] = params[:reader][:password] if params[:reader][:password]
+ if @reader.update_attributes(params[:reader])
flash[:notice] = t('reader_extension.account_updated')
redirect_to reader_dashboard_url
else
View
@@ -18,6 +18,7 @@ class Reader < ActiveRecord::Base
end
belongs_to :user
+ before_validation :combine_names
before_update :update_user
belongs_to :created_by, :class_name => 'User'
@@ -28,8 +29,6 @@ class Reader < ActiveRecord::Base
has_many :groups, :through => :memberships, :uniq => true
accepts_nested_attributes_for :memberships
- before_validation :combine_names
-
validates_presence_of :name, :forename, :surname, :email
validates_uniqueness_of :nickname, :allow_blank => true
validates_length_of :name, :forename, :surname, :maximum => 100, :allow_nil => false
@@ -268,12 +267,15 @@ def send_group_invitation_message(group=nil)
private
def combine_names
- if self.name?
- self.forename ||= self.name.split(/\s+/).first
- self.surname ||= self.name.split(/\s+/).last
- else
+ if self.forename_changed? || self.surname_changed?
self.name = "#{self.forename} #{self.surname}"
+ elsif self.name_changed?
+ self.forename = self.name.split(/\s+/).first
+ self.surname = self.name.split(/\s+/).last
end
+ self.forename = self.name.split(/\s+/).first unless self.forename?
+ self.surname = self.name.split(/\s+/).last unless self.surname?
+ self.name = "#{self.forename} #{self.surname}" unless self.name?
end
def email_must_not_be_in_use
@@ -67,9 +67,9 @@
- form.edit_groups do
= render :partial => 'choose_memberships'
- - render_region :form_bottom, :locals => {:f => f} do |form_bottom|
- - form_bottom.edit_buttons do
+ - form.buttons do
%p
= submit_tag reader.new_record? ? t('reader_extension.create_account') : t("reader_extension.update_account")
or
= link_to 'cancel', request.referer
+
@@ -86,9 +86,8 @@
%br
%span.formnote= t('reader_extension.form_notes.account.unshareable')
- - render_region :form_bottom, :locals => {:f => f} do |form_bottom|
- - form_bottom.edit_buttons do
- %p
- = submit_tag reader.new_record? ? t('reader_extension.create_account') : t("reader_extension.update_account")
- or
- = link_to 'cancel', request.referer
+ - form.buttons do
+ %p
+ = submit_tag reader.new_record? ? t('reader_extension.create_account') : t("reader_extension.update_account")
+ or
+ = link_to 'cancel', request.referer
@@ -33,7 +33,7 @@
= f.date_select :dob
%br
= f.check_box :dob_secret
- = f.label :dob_secret
+ = f.label :dob_secret, nil, :class => 'checkbox'
- form.edit_phone do
%p
@@ -68,7 +68,7 @@
- form.edit_notes do
%p
= f.check_box :disabled
- = f.label :disabled
+ = f.label :disabled, nil, :class => 'checkbox'
%p
= f.label :notes, t('reader_extension.notes'), :class => "optional"
~ f.text_area "notes", :size => "53x4", :class => "textarea"
@@ -26,7 +26,7 @@
%tbody
- @readers.each do |reader|
- %tr
+ %tr{:class => reader.disabled? ? 'disabled' : 'active'}
- render_region :tbody do |tbody|
- tbody.title_cell do
%td{:class => reader.activated? ? 'name activated' : 'name inactive'}
@@ -1,5 +1,5 @@
module RadiantReaderExtension
- VERSION = '3.0.37'
+ VERSION = '3.0.38'
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"
View
@@ -115,13 +115,11 @@ def load_default_account_regions
end
account.edit = Radiant::AdminUI::RegionSet.new do |edit|
edit.main.concat %w{preamble form gravatar}
- edit.form.concat %w{edit_name edit_email edit_password}
- edit.form_bottom.concat %w{edit_buttons}
+ edit.form.concat %w{edit_name edit_email edit_password buttons}
end
account.edit_profile = Radiant::AdminUI::RegionSet.new do |edit_profile|
edit_profile.main.concat %w{preamble profile_form gravatar}
- edit_profile.profile_form.concat %w{edit_honorific edit_name edit_dob edit_phone edit_mobile edit_address edit_shareability}
- edit_profile.form_bottom.concat %w{edit_buttons}
+ edit_profile.profile_form.concat %w{edit_honorific edit_name edit_dob edit_phone edit_mobile edit_address edit_shareability buttons}
end
account.new = account.edit
end
@@ -13,6 +13,13 @@
font-weight: normal
a
color: #06c
+
+#readers_table
+ tbody
+ tr.disabled
+ color: #aaa
+ a
+ color: #999
/* show and send page
@@ -89,3 +96,4 @@ ul.help
code
color: #c00
font-size: 115%
+

0 comments on commit aa4d7e3

Please sign in to comment.