Skip to content

Commit

Permalink
Making tags edition like other data type edition.
Browse files Browse the repository at this point in the history
I wonder when this was last updated since all the code was ported on the new system ages ago (git says at least 2 years ago)
  • Loading branch information
Frédéric de Villamil committed Aug 26, 2013
1 parent 0eecd27 commit 1904984
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 48 deletions.
32 changes: 19 additions & 13 deletions app/controllers/admin/tags_controller.rb
@@ -1,29 +1,35 @@
class Admin::TagsController < Admin::BaseController
cache_sweeper :blog_sweeper

def index
@tags = Tag.order('display_name').page(params[:page]).per(this_blog.admin_display_elements)
def index; redirect_to action: 'new' ; end
def new; new_or_edit; end
def edit; new_or_edit; end

def destroy
destroy_a(Tag)
end

def edit
@tag = Tag.find(params[:id])
@tag.attributes = params[:tag]
private

def new_or_edit
@tags = Tag.order('display_name').page(params[:page]).per(this_blog.admin_display_elements)
@tag = case params[:id]
when nil
Tag.new
else
Tag.find(params[:id])
end

@tag.attributes = params[:tag]
if request.post?
old_name = @tag.name
old_name = @tag.name if @tag.id

if @tag.save
# Create a redirection to ensure nothing nasty happens in the future
Redirect.create(:from_path => "/tag/#{old_name}", :to_path => @tag.permalink_url(nil, true))

flash[:notice] = _('Tag was successfully updated.')
redirect_to :action => 'index'
end
end
end

def destroy
destroy_a(Tag)
render 'new'
end

end
12 changes: 0 additions & 12 deletions app/views/admin/tags/edit.html.erb

This file was deleted.

23 changes: 0 additions & 23 deletions app/views/admin/tags/index.html.erb

This file was deleted.

39 changes: 39 additions & 0 deletions app/views/admin/tags/new.html.erb
@@ -0,0 +1,39 @@
<% @page_heading = _('Manage tags') %>

<div>
<div class='span4'>
<%= form_tag :action=>"edit", :id => @tag.id do %>
<%= error_messages_for 'tag' %>
<label for="tag_display_name"><%= _("Name")%>:</label>
<%= text_field 'tag', 'display_name', :class => 'medium' %>
<div class='form-actions'>
<%= cancel_or_save %>
</div>
<% end %>
</div>
<div class='span8'>
<table class="table table-striped">
<thead>
<tr class='noborder'>
<th><%= _("Display Name") %></th>
<th><%= _("Name") %></th>
<th><%= _("Articles") %></th>
</tr>
</thead>
<%= render_void_table(@tags.size, 3) %>
<% for tag in @tags %>
<tr <%= alternate_class %>>
<td>
<%= link_to_edit tag.display_name, tag %>
<%= show_tag_actions tag %>
</td>
<td><%= tag.name %></td>
<td><%= tag.published_articles.count.to_s %></td>
</tr>
<% end %>
<%= display_pagination(@tags, 3)%>
</table>

</div>
</div>

0 comments on commit 1904984

Please sign in to comment.