blob: a7b31abd9f503ec38dd0cd3ea5b1c0d0abc32f87 (
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
class ForumgroupsController < ApplicationController
def index
redirect_to forums_path
end
def show
redirect_to forums_path + "#group-#{params[:id].to_i}"
end
def edit
if admin?
@group = Forumgroup.find(params[:id])
else
flash[:alert] = "You are not allowed to edit forum groups."
end
end
def update
if admin?
@group = Forumgroup.find(params[:id])
if @group.update_attributes(group_params)
flash[:notice] = "Forum group updated"
redirect_to @group
else
flash[:alert] = "Something went wrong"
render :edit
end
else
flash[:alert] = "You are not allowed to change forum groups"
end
end
def new
if admin?
@group = Forumgroup.new
else
flash[:alert] = "You are not allowed to create forum groups."
redirect_to forums_path
end
end
def create
if admin?
@group = Forumgroup.new(group_params)
if @group.save
flash[:notice] = "Forum group created."
redirect_to @group
else
flash[:alert] = "Something went wrong"
render :new
end
else
flash[:alert] = "You are not allowed to create forum groups."
redirect_to forums_path
end
end
def destroy
if admin?
@group = Forumgroup.find(params[:id])
if @group.destroy
flash[:notice] = "forum group deleted."
else
flash[:alert] = "Something went wrong"
end
else
flash[:alert] = "You are not allowed to delete forum groups."
end
redirect_to forums_path
end
private
def group_params(add = [])
a = [:name, :position, :role_read_id, :role_write_id] + add
params.require(:forumgroup).permit(a)
end
end
|