blob: 908313bdb83d18c7cab7b3649f24b91011e48c49 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# frozen_string_literal: true
class Admin::TopicsController < Admin::ApplicationController
include SendFileUpload
include PreviewMarkdown
before_action :topic, only: [:edit, :update]
feature_category :projects
def index
@topics = Projects::TopicsFinder.new(params: params.permit(:search)).execute.page(params[:page]).without_count
end
def new
@topic = Projects::Topic.new
end
def edit
end
def create
@topic = Projects::Topic.new(topic_params)
if @topic.save
redirect_to edit_admin_topic_path(@topic), notice: _('Topic %{topic_name} was successfully created.') % { topic_name: @topic.name }
else
render "new"
end
end
def update
if @topic.update(topic_params)
redirect_to edit_admin_topic_path(@topic), notice: _('Topic was successfully updated.')
else
render "edit"
end
end
private
def topic
@topic ||= Projects::Topic.find(params[:id])
end
def topic_params
params.require(:projects_topic).permit(allowed_topic_params)
end
def allowed_topic_params
[
:avatar,
:description,
:name,
:title
]
end
end
|