Class: DocumentController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- DocumentController
- Includes:
- DocumentHelper, GdataHelper
- Defined in:
- app/controllers/document_controller.rb
Overview
Handle Google Docs integration
Constant Summary
Constant Summary
Constants included from ApplicationHelper
ApplicationHelper::ADMIN_MODULES, ApplicationHelper::WORKFLOW_MODULES
Instance Method Summary (collapse)
-
- (Object) index
Show the list of Google docs.
-
- (Object) sync
Sync our local list of document folders with Google Docs.
Methods included from DocumentHelper
Methods included from GdataHelper
#accepted_gfolder, #auth_gdocs, #cycle_gfolder, #gdocs_by_title, #get_gdata, #get_gdata_client, #get_gdocs, #get_gfolders, #new_client, #new_evidence_gfolder, #system_gfolder
Methods included from ApplicationHelper
#access_control_roles, #admin_project_modules, #display_compact, #display_time, #equal_ids, #filter_biz_processes, #filter_system_controls, #filter_systems, #mat, #mt, #pat, #program_display, #project_modules, #render_for, #typecast_params, #yield_content!
Instance Method Details
- (Object) index
Show the list of Google docs
18 19 20 21 22 23 |
# File 'app/controllers/document_controller.rb', line 18 def index return unless auth_gdocs @folders = get_gfolders() return if !@folders render 'document/index' end |
- (Object) sync
Sync our local list of document folders with Google Docs.
Ensure that folders exist for CMS/CYCLE, CMS/CYCLE/Systems, Cms/CYCLE/Accepted and each system.
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 |
# File 'app/controllers/document_controller.rb', line 28 def sync folders = get_gfolders(:refresh => true) folders or return by_title = gdocs_by_title(folders) @messages = [] top = by_title['CMS'] unless top flash[:error] = 'No CMS folder in your Google Docs' return render 'document/sync' end client = get_gdata_client return unless client unless by_title[cycle_gfolder(@cycle)] folder = client.create_folder(@cycle.slug, :parent => top) by_title[cycle_gfolder(@cycle)] = folder session[:gfolders] = {} # clear cache @messages << "Created #{folder.full_title}" end cycle_folder = by_title["#{top.full_title}/#{@cycle.slug}"] ['Systems', 'Accepted'].each do |name| unless by_title["#{cycle_folder.full_title}/#{name}"] folder = client.create_folder(name, :parent => cycle_folder) by_title["#{cycle_folder.full_title}/#{name}"] = folder session[:gfolders] = {} # clear cache @messages << "Created #{folder.full_title}" end end systems = by_title["#{cycle_folder.full_title}/Systems"] System.all.each do |sys| path = system_gfolder(@cycle, sys) unless by_title[path] folder = client.create_folder(sys.slug, :parent => systems) session[:gfolders] = {} # clear cache @messages << "Created #{folder.full_title}" end end end |