Add Thematic structure and Districts - Iss685
This commit is contained in:
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user