Add Thematic structure and Districts - Iss685

This commit is contained in:
nachogomez
2016-01-08 13:49:23 +01:00
parent 017bfe9146
commit 51d9d186af
15 changed files with 151 additions and 30 deletions

View File

@@ -25,6 +25,8 @@ module CommentableActions
@resource = resource_model.new
set_resource_instance
load_featured_tags
load_category_tags
load_district_tags
end
def create
@@ -32,18 +34,24 @@ module CommentableActions
@resource.author = current_user
if @resource.save_with_captcha
track_event
track_event
load_category_tags
load_district_tags
redirect_path = url_for(controller: controller_name, action: :show, id: @resource.id)
redirect_to redirect_path, notice: t('flash.actions.create.notice', resource_name: "#{resource_name.capitalize}")
else
load_featured_tags
load_category_tags
load_district_tags
set_resource_instance
render :new
end
end
def edit
load_featured_tags
load_featured_tags
load_category_tags
load_district_tags
end
def update
@@ -51,7 +59,9 @@ module CommentableActions
if resource.save_with_captcha
redirect_to resource, notice: t('flash.actions.update.notice', resource_name: "#{resource_name.capitalize}")
else
load_featured_tags
load_featured_tags
load_category_tags
load_district_tags
set_resource_instance
render :edit
end
@@ -70,7 +80,16 @@ module CommentableActions
def load_featured_tags
@featured_tags = ActsAsTaggableOn::Tag.where(featured: true)
end
def load_category_tags
@category_tags = ActsAsTaggableOn::Tag.select("tags.*").
where("kind = 'category' and tags.featured = true").
order(kind: :asc, id: :asc)
end
def load_district_tags
@district_tags = ActsAsTaggableOn::Tag.select("tags.*").
where("kind = 'district' and tags.featured = true").
order(kind: :asc, id: :asc)
end
def parse_tag_filter
if params[:tag].present?
@tag_filter = params[:tag] if ActsAsTaggableOn::Tag.named(params[:tag]).exists?