Skip to content

Commit

Permalink
Merge branch 'development' of git://github.com/cykod/Webiva into post…
Browse files Browse the repository at this point in the history
…-stream
  • Loading branch information
Doug Youch committed Apr 26, 2010
2 parents 4626e46 + 832b183 commit a1a415b
Show file tree
Hide file tree
Showing 13 changed files with 224 additions and 157 deletions.
8 changes: 5 additions & 3 deletions app/controllers/editor/auth_controller.rb
Expand Up @@ -16,7 +16,7 @@ class Editor::AuthController < ParagraphController #:nodoc:all

editor_for :user_edit_account, :name => 'User Edit Account', :feature => 'user_edit_account', :triggers => [ ['Edit Account','action' ]]

editor_for :edit_account, :name => 'Edit Account', :triggers => [ ['Edit Profile','action' ]]
# editor_for :edit_account, :name => 'Edit Account', :triggers => [ ['Edit Profile','action' ]]


editor_for :missing_password, :name => 'Missing Password', :triggers => [ ['Sent Email','action']], :features => ['missing_password']
Expand Down Expand Up @@ -73,7 +73,8 @@ def available_field_list
:gender => ['Gender'.t, :radio_buttons, :gender, { :options => [ ['Male'.t,'m'],['Female'.t,'f' ] ] } ],
:introduction => ['Introduction'.t, :radio_buttons, :introduction, { :options => [ ['Mr.'.t,'Mr.'],['Mrs.'.t,'Mrs.' ], ['Ms.'.t, 'Ms.'] ] } ],
:username => [ 'Username'.t,:text_field, :username ],
:salutation => [ 'Salutation'.t,:text_field, :salutation ]
:salutation => [ 'Salutation'.t,:text_field, :salutation ],
:image => [ 'Profile Image'.t,:file_upload, :domain_file_id ]
}
end

Expand Down Expand Up @@ -226,7 +227,8 @@ def available_field_list
:gender => ['Gender'.t, :radio_buttons, :gender, { :options => [ ['Male'.t,'m'],['Female'.t,'f' ] ] } ],
:introduction => ['Introduction'.t, :radio_buttons, :introduction, { :options => [ ['Mr.'.t,'Mr.'],['Mrs.'.t,'Mrs.' ], ['Ms.'.t, 'Ms.'] ] } ],
:username => [ 'Username'.t,:text_field, :username ],
:salutation => [ 'Salutation'.t,:text_field, :salutation ]
:salutation => [ 'Salutation'.t,:text_field, :salutation ],
:domain_file_id => [ 'Upload Profile Image'.t,:file_field, :domain_file_id ]
}
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/editor/auth_feature.rb
Expand Up @@ -127,7 +127,7 @@ def user_register_feature(data)

def user_edit_account_feature(data)
webiva_custom_feature(:user_edit_account,data) do |c|
c.form_for_tag('edit',:user) { |t| data[:usr] ? data[:usr] : nil }
c.form_for_tag('edit',:user,:html => { :enctype => 'multipart/form-data' }) { |t| data[:usr] ? data[:usr] : nil }

c.expansion_tag('edit:errors') { |t| data[:failed] }
c.expansion_tag('edit:updated') { |t| data[:updated] }
Expand Down
76 changes: 39 additions & 37 deletions app/controllers/editor/auth_renderer.rb
Expand Up @@ -200,18 +200,19 @@ def user_edit_account
@business = @usr.work_address || @usr.build_work_address(:address_name => 'Business Address'.t, :country => @options.country )

if @options.publication
field = @options.content_publication_user_field
model_class = @options.publication.content_model.model_class
field = @options.content_publication_user_field
model_class = @options.publication.content_model.model_class
@model = model_class.find(:first, :conditions => {field.to_sym => myself.id}) || model_class.new(field.to_sym => myself.id)
end
end

if request.post? && params[:user] && !editor? && myself.id


handle_image_upload(params[:user],:domain_file_id)
# Assign a slice of params to the user
@usr.attributes = params[:user].slice(*(@options.required_fields + @options.optional_fields + @options.always_required_fields).uniq)
unless @usr.editor?
@usr.user_class_id = @options.user_class_id if @usr.user_class_id.blank? || @options.modify_profile == 'modify'
@usr.user_class_id = @options.user_class_id if @usr.user_class_id.blank? || @options.modify_profile == 'modify'
end

# check everything is valid
Expand All @@ -225,8 +226,9 @@ def user_edit_account
end
end


all_valid = false unless @usr.errors.length == 0

# same for address
all_valid = false unless assign_entry(@address, params[:address], @options.available_address_field_list.keys, @options.address_required_fields)

Expand All @@ -243,7 +245,7 @@ def user_edit_account
@failed = true unless all_valid

if all_valid

if params[:address]
@address.save
@usr.address_id = @address.id
Expand All @@ -267,16 +269,16 @@ def user_edit_account
update_subscriptions(@usr,@options.include_subscriptions,params[:subscription])
end

@model.save if @model
@model.save if @model

if @options.access_token_id
tkn = AccessToken.find_by_id(@options.access_token_id)
@usr.add_token!(tkn) if tkn
end
if @options.access_token_id
tkn = AccessToken.find_by_id(@options.access_token_id)
@usr.add_token!(tkn) if tkn
end
# run any triggered actions
paragraph.run_triggered_actions(@usr,'action',@usr)

# send mail template if we have one
# send mail template if we have one
if @options.mail_template_id.to_i > 0 && @mail_template = MailTemplate.find_by_id(@options.mail_template_id)
vars = {}
@mail_template.deliver_to_user(@usr,vars)
Expand All @@ -289,8 +291,8 @@ def user_edit_account
return
end

flash[:notice] = 'Account Updated'.t
@updated = true
flash[:notice] = 'Account Updated'.t
@updated = true
end
end
end
Expand Down Expand Up @@ -495,7 +497,7 @@ def edit_account
@required_fields = %w(email)
@optional_fields = %w{first_name last_name gender username dob}
@adr_fields = %w(company phone fax address city state zip country)

@user = myself
@address = @user.address ? @user.address : @user.build_address(:address_name => 'Default Address'.t )
@work_address = @user.work_address ? @user.work_address : @user.build_work_address(:address_name => 'Default Work Address'.t )
Expand All @@ -513,7 +515,7 @@ def edit_account
@address.validate_registration(:home,opts.address == 'required',opts.address_type )
all_valid = false unless @address.errors.empty?
end

if opts.work_address != 'off'
@work_address.attributes = params[:work_address].slice(*@adr_fields)
@work_address.country = opts.country unless opts.country.blank?
Expand All @@ -522,9 +524,9 @@ def edit_account
end

if opts.content_publication.to_i > 0
fill_entry(@publication,@entry,@user)
all_valid = false unless @entry.valid?
fill_entry(@publication,@entry,@user)

all_valid = false unless @entry.valid?
end

@user.valid?
Expand All @@ -538,16 +540,16 @@ def edit_account
@user.address_id = @address.id
end
if opts.work_address != 'off'
@work_address.save
@user.work_address_id = @work_address.id
@work_address.save
@user.work_address_id = @work_address.id
end

@user.save

if !opts.add_tags.to_s.empty?
@user.tag_names_add(opts.add_tags)
end
if !opts.add_tags.to_s.empty?
@user.tag_names_add(opts.add_tags)
end

if opts.include_subscriptions.is_a?(Array) && opts.include_subscriptions.length > 0
update_subscriptions(@user,opts.include_subscriptions,params[:subscription])
end
Expand All @@ -556,17 +558,17 @@ def edit_account
paragraph.run_triggered_actions(@user,'action',@user)
end

paragraph_action(myself.action('/editor/auth/edit_account_profile', :identifier => @user.email))
paragraph_action(myself.action('/editor/auth/edit_account_profile', :identifier => @user.email))

if opts.success_page
nd = SiteNode.find_by_id(opts.success_page)
if nd
redirect_paragraph nd.node_path if nd
return
end
end
render_paragraph :text => 'Successfully Edited Profile'.t
return
end
end
render_paragraph :text => 'Successfully Edited Profile'.t
return
end
end

Expand All @@ -579,12 +581,12 @@ def edit_account

render_paragraph :partial => '/editor/auth/edit_account',
:locals => { :user => @user,
:opts => opts.to_h.merge(:vertical => opts.form_display == 'vertical'),
:fields => @optional_fields,
:address => @address,
:work_address => @work_address,
:subscriptions => @subscriptions,
:reset_password => flash['reset_password'] }
:opts => opts.to_h.merge(:vertical => opts.form_display == 'vertical'),
:fields => @optional_fields,
:address => @address,
:work_address => @work_address,
:subscriptions => @subscriptions,
:reset_password => flash['reset_password'] }
end

# update users subscriptions
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/modules_controller.rb
Expand Up @@ -10,6 +10,8 @@ def index

@domain = Domain.find(DomainModel.active_domain_id)
@available_modules = SiteModule.available_modules(@domain)

@available_modules = @available_modules.sort { |a,b| a[:name] <=> b[:name] }

expire_site if params[:refresh]

Expand Down
32 changes: 29 additions & 3 deletions app/controllers/paragraph_feature.rb
Expand Up @@ -401,9 +401,9 @@ def define_value_tag(name,field='value',&block)
# </div>
# </cms:posts>
# <cms:no_posts><h2>No Posts</h2></cms:no_posts>
def define_loop_tag(name,plural=nil)
def define_loop_tag(name,plural=nil,options = {})
name_parts = name.split(":")
name_base = name_parts[-1]
name_base = options[:local] || name_parts[-1]
plural = name_base.pluralize unless plural
name_parts[-1] = plural

Expand Down Expand Up @@ -1166,6 +1166,18 @@ def define_publication_filter_fields_tags(prefix,arg,publication,options={})
end
end


def define_content_model_fields_value_tags(prefix,content_model_fields,options = {})
c = self
local = options.delete(:local) || 'entry'
content_model_fields.each do |fld|
fld.site_feature_value_tags(c,prefix,:full,:local => local)
end
end

def define_content_model_value_tags(prefix,content_model,options = {})
define_content_model_fields_value_tags(prefix,content_model.content_model_fields,options)
end

# Defines a list of tags based on a passed-in publication
# Can only be used in webiva_custom_feature
Expand Down Expand Up @@ -1706,6 +1718,17 @@ def define_publication_filter_fields_tags(prefix,arg,publication,options={}) #:n
end
end
end

def define_content_model_fields_value_tags(prefix,content_model_fields,options = {})
c = self
content_model_fields.each do |fld|
fld.site_feature_value_tags(c,prefix,:full,:local => local)
end
end

def define_content_model_value_tags(prefix,content_model,options = {})
define_content_model_fields_value_tags(prefix,content_model.content_model_fields,options)
end

def define_user_address_tags(name_base,options={}) #:nodoc:
define_value_tag("#{name_base}:display")
Expand Down Expand Up @@ -1808,6 +1831,7 @@ def webiva_feature(feature_name,data={})
end
opts = {}
opts[:site_feature_id] = data[:site_feature_id] if data.has_key?(:site_feature_id)
opts[:custom_feature_body] = data[:custom_feature_body] if data.has_key?(:custom_feature_body)
feature = get_feature(feature_name,opts)
feature.body_html = single_feature(data[:partial_feature], feature.body_html) unless data[:partial_feature].blank?
parse_feature(feature,parser_context)
Expand All @@ -1828,7 +1852,9 @@ def single_feature(tag_name, feature_body)
end

def get_feature(type,options = {}) #:nodoc:
if options.has_key?(:site_feature_id) && @feature_override = SiteFeature.find_by_id(options[:site_feature_id])
if options.has_key?(:custom_feature_body)
SiteFeature.new(:body_html => options[:custom_feature_body], :options => {})
elsif options.has_key?(:site_feature_id) && @feature_override = SiteFeature.find_by_id(options[:site_feature_id])
@feature_override
elsif !options.has_key?(:site_feature_id) && @para.site_feature && (@para.site_feature.feature_type == :any || @para.site_feature.feature_type == type.to_s)
@para.site_feature
Expand Down
8 changes: 6 additions & 2 deletions app/helpers/page_helper.rb
Expand Up @@ -20,15 +20,19 @@ def end_user_table_for(tbl,options = {},&block)
style = ''
end
tbl_type =options[:type] == 'div' ? 'div' : 'table'

if options[:class]
extra_class = " " + options[:class]
end

div_id = options[:container_id] || tbl.name
concat(register_table_js(tbl,div_id,options[:refresh_url]))
concat("<form id='#{tbl.name}_update_form' action='' onsubmit='return false;'>") unless options[:no_form]

if tbl_type == 'table'
concat("<#{tbl_type} cellspacing='0' cellpadding='0' class='user_#{tbl_type}' #{style} >")
concat("<#{tbl_type} cellspacing='0' cellpadding='0' class='user_#{tbl_type}#{extra_class}' #{style} >")
else
concat("<#{tbl_type} class='user_#{tbl_type}' #{style} >")
concat("<#{tbl_type} class='user_#{tbl_type}#{extra_class}' #{style} >")
end


Expand Down
5 changes: 5 additions & 0 deletions app/models/model_extension/content_cache_extension.rb
Expand Up @@ -188,6 +188,11 @@ def self.append_features(mod) #:nodoc:

module CacheClassMethods

def cache_expire_by_id(item_id)
DataCache.expire_content(self.to_s,"ID#{item_id}")
content_cache_expire_list
end

# Expire any lists data cache elements
def content_cache_expire_list
logger.warn("Content Cache Expire List: #{self.to_s}") unless RAILS_ENV == 'production'
Expand Down
2 changes: 2 additions & 0 deletions app/models/page_paragraph.rb
Expand Up @@ -204,6 +204,8 @@ def cache_attributes
def self.thaw(atr)
para_id = atr.delete('id') || atr.delete(:id)
para = PageParagraph.new(atr)
para.connections.symbolize_keys! if para.connections
para.connections.each { |key,hsh| hsh.symbolize_keys! if hsh.is_a?(Hash) } if para.connections
para.id = para_id
para
end
Expand Down
1 change: 1 addition & 0 deletions app/models/site_module.rb
Expand Up @@ -336,6 +336,7 @@ def options_url

def post_initialization!
if self.status == 'initialized'
self.admin_controller_class.content_node_type_generate
if ( self.admin_controller_class.method_defined?('options') ||
self.admin_controller_class.respond_to?('module_options') )
if self.admin_controller_class.respond_to?('module_options')
Expand Down
6 changes: 3 additions & 3 deletions app/views/modules/index.rhtml
Expand Up @@ -41,11 +41,11 @@ confirmDeactivation: function() {
<tr id='elem_mod_<%= t[:module] -%>_row' onmouseover='SCMS.highlightRow(this);' onmouseout='SCMS.lowlightRow(this);' onclick='SCMS.clickRow("mod","<%= t[:module] -%>"); ModuleEditor.updateButtons(); '>
<td nowrap='1'>
<% if (t[:status] == 'active' || t[:status] == 'initialized') && "#{t[:name].to_s.camelcase}::AdminController".constantize.method_defined?('options') %>
<b><%= link_to t[:name].humanize.capitalize, { :action => 'edit', :path => t[:module] } %></b>
<b><%= link_to t[:name].underscore.titleize, { :action => 'edit', :path => t[:module] } %></b>
<% elsif t[:status] == 'active' -%>
<b><%= t[:name].humanize.capitalize %></b>
<b><%= t[:name].underscore.titleize %></b>
<% else -%>
<%= t[:name].humanize.capitalize %>
<%= t[:name].underscore.titleize %>
<% end -%>
</td>
<td nowrap='1'><%= t[:status].humanize.t %></td>
Expand Down
8 changes: 8 additions & 0 deletions lib/hash_model.rb
Expand Up @@ -111,6 +111,14 @@ def self.boolean_options(*objs)
class << self; self end.send(:define_method,"current_boolean_opts") do
objs
end

objs.each do |obj|
self.class_eval <<-EOF
def #{obj}?
! @#{obj}.blank?
end
EOF
end
end

def self.float_options(*objs)
Expand Down

0 comments on commit a1a415b

Please sign in to comment.