Class: Jinda::DocsController

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

Instance Method Summary collapse

Instance Method Details

#destroyObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/jindra_engine/docs_controller.rb', line 33

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



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/jindra_engine/docs_controller.rb', line 17

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



10
11
# File 'app/controllers/jindra_engine/docs_controller.rb', line 10

def edit
end

#indexObject



6
7
8
# File 'app/controllers/jindra_engine/docs_controller.rb', line 6

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

#myObject



13
14
15
# File 'app/controllers/jindra_engine/docs_controller.rb', line 13

def my
  @page_title       = 'My Document'
end