Class: GroupsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/groups_controller.rb

Instance Method Summary collapse

Instance Method Details

#check_logoObject



51
52
53
54
# File 'app/controllers/groups_controller.rb', line 51

def 
  =params[:group][:logo]
  params[:group][:logo] = .blank? ? nil : ()
end

#createObject



56
57
58
59
60
61
62
63
64
65
# File 'app/controllers/groups_controller.rb', line 56

def create
  @group=Group.new(params[:group])

  if @group.save
     flash[:notice]="群组创建成功"
  else
     flash[:error]="群组创建失败"
  end
  redirect_to :back and return
end

#destroyObject



78
79
80
81
82
83
84
85
86
87
88
# File 'app/controllers/groups_controller.rb', line 78

def destroy

  #if @group.delete
  params[:group][:enable]=false
  if @group.update_attributes(params[:group])
     flash[:notice]="群组删除成功"
  else
     flash[:error]="群组删除失败"
  end
  redirect_to :back and return
end

#editObject



21
22
# File 'app/controllers/groups_controller.rb', line 21

def edit
end

#findgroupObject



7
8
9
# File 'app/controllers/groups_controller.rb', line 7

def findgroup
  @group=Group.find(params[:id])
end

#get_logoObject



27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/groups_controller.rb', line 27

def 
  id=@group.["grid_id"]
    if FileGrid.exist?(id)
       f=FileGrid.get(id)
       send_data(f.read,:type=>f.content_type)
       #response.headers['Content-Type'] = f.content_type
    else
       render :text=>"文件不存在"
    end
end

#handle_logo(logo) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/groups_controller.rb', line 38

def ()
  filehash={}
  Zbox::QmExt.resize(.tempfile.path,:size=>:tinylogo)
  file_id=FileGrid.put(File.open(.tempfile.path),:filename=>.original_filename)      
  thefile=FileGrid.get(file_id)
        filehash["grid_id"]=file_id
        filehash["content_type"]=.content_type
        filehash["chunk_size"]=thefile.chunk_size
        filehash["filename"]=thefile.filename
  return filehash
    
end

#indexObject



11
12
13
14
15
# File 'app/controllers/groups_controller.rb', line 11

def index
  @page,@per_page=params[:page],5
  @minum = @page ? @per_page*(@page.to_i-1) : 0
  @groups=Group.paginate :pages=>@page,:per_page=>@per_page
end

#newObject



17
18
19
# File 'app/controllers/groups_controller.rb', line 17

def new
   @group=Group.new
end

#showObject



24
25
# File 'app/controllers/groups_controller.rb', line 24

def show
end

#updateObject



67
68
69
70
71
72
73
74
75
76
# File 'app/controllers/groups_controller.rb', line 67

def update
  =params[:group][:logo]
  params[:group][:logo]=File.read(.tempfile.path)
  if @group.update_attributes(params[:group])
     flash[:notice]="群组更新成功"
  else
     flash[:error]="群组更新失败"
  end
  redirect_to :back and return
end