diff --git a/app/controllers/admin/snippets_controller.rb b/app/controllers/admin/snippets_controller.rb deleted file mode 100644 index 4473ad5b..00000000 --- a/app/controllers/admin/snippets_controller.rb +++ /dev/null @@ -1,52 +0,0 @@ -class Admin::SnippetsController < ApplicationController - - layout "admin" - before_filter :authenticate_user! - before_filter :find_parent_item - before_filter :is_admin? - - #Snippet is a object admin user can define his own tag and being used later on in parser - - def show - #TODO - end - - def new - @snippet = Snippet.new - @snippet.parent_id = @parent_item.id - end - - def edit - @snippet = Snippet.find(params[:id]) - end - - def create - @snippet = Snippet.new(params[:snippet]) - - if @snippet.save - flash[:notice] = t('admin.create_success_snippet') - redirect_to admin_items_url( :parent_id => @snippet.parent_id ) - else - render :action => "new" - end - end - - def update - @snippet = Snippet.find(params[:id]) - - if @snippet.update_attributes(params[:snippet]) - flash[:notice] = t('admin.update_success_snippet') - redirect_to admin_items_url( :parent_id => @snippet.parent_id ) - else - render :action => "edit" - end - end - - def destroy - @snippet = Snippet.find(params[:id]) - @snippet.destroy - - redirect_to admin_items_url( :parent_id => @snippet.parent_id ) - end - -end diff --git a/app/models/snippet.rb b/app/models/snippet.rb deleted file mode 100644 index fcce86b7..00000000 --- a/app/models/snippet.rb +++ /dev/null @@ -1,38 +0,0 @@ -class Snippet - - include Mongoid::Document - include Mongoid::Timestamps - - field :name, :index => true - field :full_name, :index => true - - field :parent_id, :index => true - field :parent_name - - field :content - - before_validation :setup_default_value - validates_presence_of :name, :full_name, :parent_id - validates_uniqueness_of :name, :scope => :parent_id - - referenced_in :parent, :class_name => "Item", :foreign_key => :parent_id - - # Get an array of ancestors - def ancestors - node, nodes = self, [] - nodes << node = node.parent while !node.parent.blank? rescue nil - nodes.reverse - end - - def setup_default_value - # Set the parent value - self.parent_name = Item.find( self.parent_id ).name rescue nil - - # Build the full_name from the ancestors array - full_node = self.ancestors.map{ |a| a.name }.push( self.name ) - # Remove root node if not root - full_node.shift if full_node.size >= 2 - self.full_name = full_node.join("/") - end - -end diff --git a/app/views/admin/snippets/_form.html.erb b/app/views/admin/snippets/_form.html.erb deleted file mode 100644 index 36c8a7aa..00000000 --- a/app/views/admin/snippets/_form.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -<%= f.hidden_field :parent_id %> - -
-<%= f.label :name, t('admin.name') %> -<%= f.text_field :name, :class => 'text' %> -
- --<%= f.label "content", t('admin.content') %> -<%= f.text_area "content", :size => '100x30' %> -
diff --git a/app/views/admin/snippets/edit.html.erb b/app/views/admin/snippets/edit.html.erb deleted file mode 100644 index b7ae0b93..00000000 --- a/app/views/admin/snippets/edit.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -- <%= f.submit 'Update' %> <%= link_back %> -
-<% end %> diff --git a/app/views/admin/snippets/new.html.erb b/app/views/admin/snippets/new.html.erb deleted file mode 100644 index a2fd23ce..00000000 --- a/app/views/admin/snippets/new.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -- <%= f.submit t('create') %> <%= link_back %> -
-<% end %>