Class: DocsController

Inherits:
ApplicationController show all
Defined in:
lib/generators/jinda/templates/app/controllers/jinda_org/docs_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#prepare_meta_tags

Instance Method Details

#destroyObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/docs_controller.rb', line 32

def destroy
# duplicated from jinda_controller
# Expected to use in jinda_controller
  current_ma_user = User.where(:auth_token => cookies[:auth_token]).first if cookies[:auth_token]

  if Rails.env.test? #Temp solution until fix test of current_ma_user
    current_ma_user = $xvars["current_ma_user"]
    #current_ma_user = @doc.user
  end

  if current_ma_user.role.upcase.split(',').include?("A") || current_ma_user == @doc.user
    @doc.destroy
  end
  redirect_to :action=>'my'
end

#doc_updateObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/docs_controller.rb', line 16

def doc_update
  # Instead of creaete, Doc record was created in form, when upload file
  
  if Jinda::Doc.where(:runseq_id => $xvars["doc_form"]["runseq_id"]).exists?
    @doc = Jinda::Doc.where(:runseq_id => $xvars["doc_form"]["runseq_id"]).first
    @doc.update(description: $xvars["doc_form"]["description"],
                  category: $xvars["doc_form"]["jinda_doc"]["category"],
                  keywords: $xvars["doc_form"]["keywords"],
                  user_id: $xvars["user_id"]
								)
  else
    # create here
    # Todo
  end
end

#editObject



9
10
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/docs_controller.rb', line 9

def edit
end

#indexObject



5
6
7
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/docs_controller.rb', line 5

def index
   @documents = Jinda::Doc.desc(:created_at).page(params[:page]).per(10)
end

#myObject



12
13
14
# File 'lib/generators/jinda/templates/app/controllers/jinda_org/docs_controller.rb', line 12

def my
  @page_title       = 'My Document'
end