 
 (defn plans-trial-notification [plan org-name owner]
   [:div.row-fluid
-   [:div.alert.alert-success {:class (when (plan-model/trial-over? plan) "alert-error")}
+   [:div.alert.alert-success {:class (when (pm/trial-over? plan) "alert-error")}
     [:p
-     (if (plan-model/trial-over? plan)
+     (if (pm/trial-over? plan)
        "Your 2-week trial is over!"
 
        [:span "The " [:strong org-name] " organization has "
-        (plan-model/pretty-trial-time plan) " left in its trial."])]
+        (pm/pretty-trial-time plan) " left in its trial."])]
     [:p
      "The trial plan is equivalent to the Solo plan with 6 containers."]
     (when (and (not (:too_many_extensions plan))
-               (> 3 (plan-model/days-left-in-trial plan)))
+               (> 3 (pm/days-left-in-trial plan)))
       [:p
        "Need more time to decide? "
        (forms/managed-button

      (let [org-name (get-in app state/org-name-path)
            plan (get-in app state/org-plan-path)
            selected-containers (or (get-in app state/selected-containers-path)
                                    (plan-model/usable-containers plan))
            selected-paid-containers (max 0 (- selected-containers (plan-model/freemium-containers plan)))
            old-total (plan-model/stripe-cost plan)
            new-total (plan-model/cost plan selected-containers)
            container-cost (plan-model/per-container-cost plan)]
        (html
         (if-not plan
           [:div.loading-spinner common/spinner]

           [:div#edit-plan
            [:fieldset
             [:legend
              "Our pricing is flexible and scales with you. Add as many containers as you want for $"

           [:div.loading-spinner common/spinner]

           [:div#billing.plans.pricing.row-fluid
            (when (pm/trial? plan)
              (plans-trial-notification plan org-name owner))
            (when (pm/piggieback? plan org-name)
              (plans-piggieback-plan-notification plan org-name))
            (om/build plans-component/plans app)
            (shared/customers-trust)
            (om/build plans-component/pricing-features app)
            plans-component/pricing-faq]))))))

(defn current-plan-desc
  "A div that explains your current plan."
  [app owner]
  (om/component
   (html
    (let [org-name (get-in app state/org-name-path)
          plan (get-in app state/org-plan-path)
          plan-total (pm/stripe-cost plan)
          container-cost (pm/per-container-cost plan)]
      [:div.plan
       ;; TODO: make the org-name a drop-down selector of the orgs you
       ;; are a member of.
       [:h2 org-name "'" (when-not (re-matches #".*s" org-name) "s")
        " Current Plan"]
       (cond
        (pm/paid? plan)
        (list
         [:p [:strong "PAID"]]
         [:ul
          [:li [:strong (pm/usable-containers plan) " for $" plan-total] "/ month"]
          (when (pm/freemium? plan)
            [:li "Includes " (pluralize (pm/freemium-containers plan) "container") " FREE!"])
          (if (> (pm/paid-plan-min-containers plan) 0)
            [:li (if (pm/freemium? plan) "Next " "First ")
             (pluralize (pm/paid-plan-min-containers plan) "container") " at $"
             (-> plan :paid :template :price)])
          [:li "Additional containers for $" (pm/per-container-cost plan) "/month"]
          [:li [:strong "No other limits"]]])
        
        (and (pm/freemium? plan)
             (not (pm/in-trial? plan)))
        (list
         [:p [:strong "FREE"]]
         [:ul [:li "Includes " (pluralize (:containers plan) "container") " free!"]
          [:li "Additional containers for $" container-cost "/month"]
          [:li [:strong "No other limits"]]])
        
        (pm/trial? plan)
        (list
         [:p [:strong "TRIAL" (when-not (pm/in-trial? plan) " ENDED")]]
         [:ul
          (if (pm/in-trial? plan)
            [:li "You are currently trialing a plan with " (pluralize (pm/usable-containers plan) "container") "."]
            [:li "Your trial of a plan with " (pluralize (pm/trial-containers plan) "container") " has ended. Please add containers to continue building private repositories."])
          [:li "Additional containers for $" (pm/per-container-cost plan) "/month"]
          [:li [:strong "No other limits"]]]))]))))

(defn containers [app owner]
  (reify
    ;; I stole the stateful "did we load stripe checkout code" stuff
    ;; from the plan component above, but the billing-card component
    ;; also has it. What's the nice way to
    ;; abstract it out?
    om/IInitState
    (init-state [_]
