From 79f759d52486e8922b11a25a7f6e12477ad961b5 Mon Sep 17 00:00:00 2001 From: Ethan McCutchen Date: Fri, 4 Feb 2011 11:04:17 -0700 Subject: [PATCH] fix for account requests not rendering approval options (plus some cleanup) --- app/models/card/base.rb | 12 +------ app/models/card/invitation_request.rb | 18 ++-------- app/models/card/pointer.rb | 1 - app/models/card/ruby.rb | 3 -- app/models/card/script.rb | 5 +-- app/models/card/search.rb | 10 ++---- app/models/card/setting.rb | 3 -- app/models/slot.rb | 2 +- .../types/invitation_request/_content.rhtml | 25 +++++++------- lib/cardlib/defaults.rb | 34 +++++++++++-------- spec/models/slot_spec.rb | 7 ++-- 11 files changed, 44 insertions(+), 76 deletions(-) diff --git a/app/models/card/base.rb b/app/models/card/base.rb index 7fa453784..e92f6020a 100644 --- a/app/models/card/base.rb +++ b/app/models/card/base.rb @@ -230,8 +230,6 @@ def find_or_create(args={}) end end - def is_collection?() false end - def save_with_trash! save || raise(ActiveRecord::RecordNotSaved) end @@ -382,7 +380,7 @@ def extended_referencers (dependents + [self]).plot(:referencers).flatten.uniq end - def card + def card ## is this still necessary or just legacy from CachedCards? self end @@ -448,14 +446,6 @@ def builtin? @builtin end - def clean_html? - true - end - - def generic? - false - end - def content new_card? ? ok!(:create_me) : ok!(:read) cached_revision.new_record? ? "" : cached_revision.content diff --git a/app/models/card/invitation_request.rb b/app/models/card/invitation_request.rb index 10290444b..fa5bf18ca 100644 --- a/app/models/card/invitation_request.rb +++ b/app/models/card/invitation_request.rb @@ -1,24 +1,10 @@ module Card - class InvitationRequest < Basic - attr_accessor :account + class InvitationRequest < Base + attr_accessor :account ## is this used?? - #before_validation_on_create :create_user before_destroy :block_user - def cacheable? - false # because users who can accept requests need to see different content. - end - private -=begin - def create_user - self.extension = ::User.new( self.account ) - extension.generate_password - extension.save - extension.errors.each do |attr,msg| self.errors.add(attr,msg) end - return false unless extension.valid? - end -=end def block_user if extension diff --git a/app/models/card/pointer.rb b/app/models/card/pointer.rb index 1fbee7909..c03f4154d 100644 --- a/app/models/card/pointer.rb +++ b/app/models/card/pointer.rb @@ -1,7 +1,6 @@ module Card class Pointer < Base - def cacheable?() false end def is_collection?() true end def items( context = nil ) diff --git a/app/models/card/ruby.rb b/app/models/card/ruby.rb index 5359e06c4..645ad7ff3 100644 --- a/app/models/card/ruby.rb +++ b/app/models/card/ruby.rb @@ -1,7 +1,4 @@ module Card class Ruby < Base - def cacheable? - false - end end end diff --git a/app/models/card/script.rb b/app/models/card/script.rb index b410b877b..daef44389 100644 --- a/app/models/card/script.rb +++ b/app/models/card/script.rb @@ -1,7 +1,4 @@ module Card - class Script < Base - def cacheable? - false - end + class Script < Base end end diff --git a/app/models/card/search.rb b/app/models/card/search.rb index 538c8b072..18f60c895 100644 --- a/app/models/card/search.rb +++ b/app/models/card/search.rb @@ -4,14 +4,12 @@ class Search < Base attr_accessor :self_cardname, :results, :spec before_save :escape_content + def is_collection?() true end + def escape_content self.content = CGI::unescapeHTML( URI.unescape(content) ) end - def cacheable? - name.template_name? - end - def count(params={}) Card.count_by_wql( (params.empty? && spec) ? spec : get_spec(params) ) end @@ -24,9 +22,7 @@ def search( params={} ) self.results = Card.search( self.spec ) end - def is_collection?() true end - - def each_name + def each_name ## FIXME - this should just alter the spec to have it return name rather than instantiating all the cards!! Wql.new(card.get_spec).run.map do |card| yield(card.name) end diff --git a/app/models/card/setting.rb b/app/models/card/setting.rb index c807256c9..7ec79c9c0 100644 --- a/app/models/card/setting.rb +++ b/app/models/card/setting.rb @@ -1,7 +1,4 @@ module Card class Setting < Base - def cacheable? - false - end end end \ No newline at end of file diff --git a/app/models/slot.rb b/app/models/slot.rb index b05ef88dd..5c95fe304 100644 --- a/app/models/slot.rb +++ b/app/models/slot.rb @@ -83,7 +83,7 @@ def initialize(card, opts=nil) @state=:edit args[:add_javascript]=true @form = form_for_multi - hidden_field_tag(:multi_edit, true) + _render_naked(args) + hidden_field_tag(:multi_edit, true) + _render_core(args) end view(:change) do |args| diff --git a/app/views/types/invitation_request/_content.rhtml b/app/views/types/invitation_request/_content.rhtml index 106263064..79e00cb2d 100644 --- a/app/views/types/invitation_request/_content.rhtml +++ b/app/views/types/invitation_request/_content.rhtml @@ -1,15 +1,16 @@ <%= slot.render_core %> <%#ENGLISH%> - - +<% if !card.new_card? %> <%# this if is not really necessary yet, but conceptually correct%> + +<% end %> diff --git a/lib/cardlib/defaults.rb b/lib/cardlib/defaults.rb index a537b51be..f10b85135 100644 --- a/lib/cardlib/defaults.rb +++ b/lib/cardlib/defaults.rb @@ -1,32 +1,36 @@ module Cardlib module Defaults + + #a place for frequently overridden methods. + def self.included(base) super base.extend(ClassMethods) base.class_eval do -# class_inheritable_accessor :editor_type, :description -# set_editor_type "RichText" end - end - module ClassMethods - end - # -- called by the rendering pipeline-- defined in datatypes - def allow_duplicate_revisions - false + module ClassMethods #not doing anything now but leaving around for future use. end - - def cacheable? - return true - end - + def post_render( content ) - # FIXME-- client code shouldn't have to know to do this i don't think? - # content.replace(newcontent) content end + def clean_html? + true + end + + def generic? + false + end + + def is_collection?() + false + end + + + #This definitely doesn't belong here. def valid_number?( string ) valid = true begin diff --git a/spec/models/slot_spec.rb b/spec/models/slot_spec.rb index 1e30cfba0..262658fe4 100644 --- a/spec/models/slot_spec.rb +++ b/spec/models/slot_spec.rb @@ -353,9 +353,10 @@ def simplify_html string describe "Account Request" do it "should have a special section for approving requests" do - pending # was seeing this error: undefined method `xpath_with_callback' for nil:NilClass - # probably means we need to set up legitimate Account Request with user info - render_card(:naked, :type=>'Account Request').should be_html_with { div :class=>'invite-links' } + pending + #I can't get this working. I keep getting this url_for error -- from a line that doesn't call url_for + card = Card.create!(:name=>'Big Bad Wolf', :type=>'Account Request') + Slot.new(card).render(:naked).should be_html_with { div :class=>'invite-links' } end end