Class: Knitkit::ErpApp::Desktop::ContentController

Inherits:
AppController
  • Object
show all
Defined in:
app/controllers/knitkit/erp_app/desktop/content_controller.rb

Constant Summary

Constants inherited from AppController

AppController::KNIT_KIT_ROOT

Instance Method Summary collapse

Methods inherited from AppController

#available_roles, #websites

Instance Method Details

#save_excerptObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/knitkit/erp_app/desktop/content_controller.rb', line 33

def save_excerpt
  result = {:success => true}
  begin
    current_user.with_capability('edit_excerpt', 'Content') do
      id      = params[:id]
      html    = params[:html]
      content = Content.find(id)
      content.excerpt_html = html

      if content.save
        unless params[:site_id].blank?
          website = Website.find(params[:site_id])
          content.publish(website, 'Auto Publish', content.version, current_user) if website.publish_on_save?
        end
      else
        result = {:success => false}
      end

      render :json => result
    end
  rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
    render :json => {:success => false, :message => ex.message}
  end
end

#updateObject



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
# File 'app/controllers/knitkit/erp_app/desktop/content_controller.rb', line 6

def update
  result = {:success => true}
  begin
    current_user.with_capability('edit_html', 'Content') do
      id      = params[:id]
      html    = params[:html]
      content = Content.find(id)
      content.body_html = html

      if content.save
        unless params[:site_id].blank?
          website = Website.find(params[:site_id])
          content.publish(website, 'Auto Publish', content.version, current_user) if website.publish_on_save?
        end
        #added for inline editing
        result[:last_update] = content.updated_at.strftime("%m/%d/%Y %I:%M%p")
      else
        result = {:success => false}
      end

      render :json => result
    end
  rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
    render :json => {:success => false, :message => ex.message}
  end
end