<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>db/migrate/002_create_pages.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,3 @@
 - Document migrations that generate sample pages and page parts
 - Split out subscription tags into separate form fields
-- Move Spreedly config to Radiant config table
 - Run through action, but render a Radiant page (see comments extension for @page.render)
\ No newline at end of file</diff>
      <filename>TODO</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,14 @@
 class Admin::SpreedlyController &lt; ApplicationController
-  def index
-    @spreedly_config = SpreedlyConfig.first
-  end
-  
   def edit
-    @spreedly_config = SpreedlyConfig.first || SpreedlyConfig.new(params[:spreedly_config])
     if request.post?
-      @spreedly_config.new_record? ? @spreedly_config.save! : @spreedly_config.update_attributes!(params[:spreedly_config])
+      Radiant::Config['spreedly.api_token'] = params[:api_token]
+      Radiant::Config['spreedly.login_name'] = params[:login_name]
+      
+      plan = SubscriptionPlan.find_by_id(params[:plan_id])
+      Radiant::Config['spreedly.plan_id'] = plan.id
+      Radiant::Config['spreedly.plan_name'] = plan.name
+      
+      Radiant::Config['spreedly.mode'] = params[:mode]
       redirect_to spreedly_index_url
     end
   end</diff>
      <filename>app/controllers/admin/spreedly_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -42,12 +42,11 @@ module SpreedlyTags
     s = tag.locals.subscriber
     if s.active?
       &quot;You are all paid up!&quot;
-    elsif SpreedlyConfig.first
+    elsif s.spreedly_configured?
       &quot;No active subscription. #{link_to 'Subscribe', s.spreedly_url}&quot;
     else
-      content_tag(:span, :style =&gt; &quot;font-weight:bold; color:red&quot;) do
-        &quot;Spreedly is not configured properly. Please contact an admin.&quot;
-      end
+      content_tag(:span, &quot;Spreedly is not configured properly. &quot; &lt;&lt;
+        &quot;Please contact an admin.&quot;, :style =&gt; &quot;font-weight:bold; color:red&quot;)
     end
   end
   </diff>
      <filename>app/models/spreedly_tags.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,12 +9,22 @@ class Subscriber &lt; ActiveRecord::Base
   before_save :encrypt_password
   
   def spreedly_url
-    if  sc = SpreedlyConfig.first
-      test = sc.mode == &quot;Testing&quot; ? &quot;-test&quot; : &quot;&quot;
-      &quot;https://spreedly.com/#{sc.login_name}#{test}/subscribers/#{id}/subscribe/#{sc.plan_id}/#{email}-#{id}&quot;
+    if spreedly_configured?
+      test = Radiant::Config['spreedly.mode'] == &quot;Testing&quot; ? &quot;-test&quot; : &quot;&quot;
+      login_name = Radiant::Config['spreedly.login_name']
+      plan_id = Radiant::Config['spreedly.plan_id']
+      &quot;https://spreedly.com/#{login_name}#{test}/subscribers/#{id}/subscribe/#{plan_id}/#{email}-#{id}&quot;
     end
   end
   
+  def spreedly_configured?
+    # TODO this is yucky
+    !Radiant::Config['spreedly.api_token'].blank? &amp;&amp;
+    !Radiant::Config['spreedly.login_name'].blank? &amp;&amp;
+    !Radiant::Config['spreedly.plan_id'].blank? &amp;&amp;
+    !Radiant::Config['spreedly.mode'].blank?
+  end
+  
   def refresh_from_spreedly
     update_attributes!(:active =&gt; SubscriberResource.find(id).active)
   end</diff>
      <filename>app/models/subscriber.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,4 +4,8 @@ class SubscriptionPlan &lt; ActiveResource::Base
   def self.to_dropdown
     find(:all).collect { |e| [e.name, e.id] }
   end
+  
+  def self.find_by_id(id)
+    find(:all).detect { |e| e.id == id.to_i }
+  end
 end
\ No newline at end of file</diff>
      <filename>app/models/subscription_plan.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,11 +1,9 @@
 &lt;h2&gt;Edit Spreedly Configuration&lt;/h2&gt;
 
-&lt;%= error_messages_for :spreedly_config %&gt;
-
-&lt;% form_for :spreedly_config do |f| -%&gt;
-  API Token: &lt;%= f.text_field :api_token, :size =&gt; 50 %&gt;&lt;br/&gt;
-  Login Name: &lt;%= f.text_field :login_name, :size =&gt; 20 %&gt;&lt;br/&gt;
-  Plan: &lt;%= f.select :plan_id, SubscriptionPlan.to_dropdown %&gt;&lt;br/&gt;
-  Mode: &lt;%= f.select :mode, %w(Testing Production) %&gt;&lt;br/&gt;
-  &lt;%= f.submit &quot;Save&quot; %&gt; or &lt;%= link_to &quot;cancel&quot;, spreedly_index_url %&gt;
+&lt;% form_tag do -%&gt;
+  API Token: &lt;%= text_field_tag :api_token, Radiant::Config['spreedly.api_token'],:size =&gt; 50 %&gt;&lt;br/&gt;
+  Login Name: &lt;%= text_field_tag :login_name, Radiant::Config['spreedly.login_name'], :size =&gt; 20 %&gt;&lt;br/&gt;
+  Plan: &lt;%= select_tag :plan_id, options_for_select(SubscriptionPlan.to_dropdown, Radiant::Config['spreedly.plan_id'].to_i) %&gt;&lt;br/&gt;
+  Mode: &lt;%= select_tag :mode, options_for_select(%w(Testing Production), Radiant::Config['spreedly.mode']) %&gt;&lt;br/&gt;
+  &lt;%= submit_tag &quot;Save&quot; %&gt; or &lt;%= link_to &quot;cancel&quot;, spreedly_index_url %&gt;
 &lt;% end -%&gt;
\ No newline at end of file</diff>
      <filename>app/views/admin/spreedly/edit.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,15 +1,12 @@
 &lt;h1&gt;Spreedly&lt;/h1&gt;
 
-&lt;% if @spreedly_config -%&gt;
-  &lt;p&gt;You can adjust your Spreedly configuration here.&lt;/p&gt;
-  &lt;p&gt;
-    &lt;b&gt;Account Name:&lt;/b&gt; &lt;%= @spreedly_config.login_name %&gt;&lt;br/&gt;
-    &lt;b&gt;Plan ID:&lt;/b&gt; &lt;%= @spreedly_config.plan_id %&gt;&lt;br/&gt;
-    &lt;b&gt;Mode:&lt;/b&gt; &lt;%= @spreedly_config.mode %&gt;&lt;br/&gt;
-  &lt;/p&gt;
-&lt;% else -%&gt;
-  &lt;p&gt;&lt;span style=&quot;font-weight:bold; color:red&quot;&gt;Please set up your Spreedly
-    account by clicking &quot;edit&quot; below.&lt;/b&gt;&lt;/p&gt;
-&lt;% end -%&gt;
+&lt;p&gt;You can adjust your Spreedly configuration here.&lt;/p&gt;
+
+&lt;p&gt;
+  &lt;b&gt;API Token:&lt;/b&gt; &lt;%= Radiant::Config['spreedly.api_token'] %&gt;&lt;br/&gt;
+  &lt;b&gt;Login Name:&lt;/b&gt; &lt;%= Radiant::Config['spreedly.login_name'] %&gt;&lt;br/&gt;
+  &lt;b&gt;Plan:&lt;/b&gt; &lt;%= Radiant::Config['spreedly.plan_name'] %&gt;&lt;br/&gt;
+  &lt;b&gt;Mode:&lt;/b&gt; &lt;%= Radiant::Config['spreedly.mode'] %&gt;&lt;br/&gt;
+&lt;/p&gt;
 
 &lt;p&gt;&lt;%= link_to &quot;edit&quot;, spreedly_edit_url %&gt;&lt;/p&gt;
\ No newline at end of file</diff>
      <filename>app/views/admin/spreedly/index.html.erb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>app/models/spreedly_config.rb</filename>
    </removed>
    <removed>
      <filename>db/migrate/002_create_spreedly_configs.rb</filename>
    </removed>
    <removed>
      <filename>db/migrate/003_create_pages.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>7d072257c81b9c3b83d2b17c33ac7d1c06499ece</id>
    </parent>
  </parents>
  <author>
    <name>Matthew Bass</name>
    <email>matt@68-243-116-122.pools.spcsdns.net</email>
  </author>
  <url>http://github.com/pelargir/radiant-spreedly-extension/commit/2ceecaffd08ee14649e7fba6d778eec0d5464999</url>
  <id>2ceecaffd08ee14649e7fba6d778eec0d5464999</id>
  <committed-date>2008-11-13T12:03:11-08:00</committed-date>
  <authored-date>2008-11-13T12:03:11-08:00</authored-date>
  <message>switched from SpreedlyConfig to Radiant::Config</message>
  <tree>368f48a4aa22720ffee51bac759ff2ef7c06a065</tree>
  <committer>
    <name>Matthew Bass</name>
    <email>matt@68-243-116-122.pools.spcsdns.net</email>
  </committer>
</commit>
