code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
module DefaultRelationshipTypes
RELATIONSHIP_TYPES = {
:data_asset_has_process => {
:source_type => "DataAsset",
:target_type => "Process",
:forward_phrase => "has",
:reverse_phrase => "is a process for",
:forward_description => "This data asset relies upon the following processes."... | Ruby |
# A lot of this is cribbed from how declarative_authorization handles
# model-based authorization.
module Authorization
# Controller-independent method for retrieving the current user.
# Needed for model security where the current controller is not available.
# Primarily for use by the console and tests, where w... | Ruby |
module CommonModel
def self.included(model)
model.send(:include, AuthoredModel)
model.has_many :object_people, :as => :personable, :dependent => :destroy
model.has_many :people, :through => :object_people
model.has_many :object_documents, :as => :documentable, :dependent => :destroy
model.has_many... | Ruby |
module BusinessObjectModel
@business_object_models = nil
def self.included(model)
model.class_eval do
end
model.extend(ClassMethods)
if model.ancestors.include?(ActiveRecord::Base)
@business_object_models = [] if @business_object_models.nil?
@business_object_models.push(model)
end
... | Ruby |
module AuthoredModel
# Typecast form parameters into the right primitive to work around a DataMapper dirty-detection bug.
#
# If we don't do this, the persistence layer thinks all non-strings params are modifications
# where in fact we might just have changed false => 0, which is a no-op. This is important
#... | Ruby |
module ControlState
VALUES = [ :green, :yellow, :red, :unknown ]
STATE_WEIGHT = { :green => 10, :unknown => 15, :yellow => 20, :red => 30 }
STATE_IS_GOOD = { :green => true, :unknown => true }
end
| Ruby |
# Sanitize attributes before validation.
#
# Usage in model:
#
# sanitize_attributes :description, :documentation_description
#
module SanitizableAttributes
# based on defaults from ActionView::Base.sanitized_allowed_tags with table tags added
SANITIZED_ALLOWED_TAGS = %w(strong em b i p code pre tt samp kbd var s... | Ruby |
module StateModel
def state
index = read_attribute(:state) || self.class.columns_hash['state'].default
ControlState::VALUES[index]
end
def state=(value)
write_attribute(:state, ControlState::VALUES.index(value))
end
def good_state?
ControlState::STATE_IS_GOOD[state]
end
def self.include... | Ruby |
module RoleModel
ROLES = [:tech, :business]
def role
index = read_attribute(:role) || self.class.columns_hash['role'].default
ROLES[index]
end
def role=(value)
write_attribute(:role, ROLES.index(value))
end
def self.included(model)
model.validates :role, :presence => true
end
end
| Ruby |
# Provides utility functions for doing authorization on CRUD and other operations
# to the model, given a standard way of getting the current user and
# a list of users and roles for an object.
# Note: requires the model to implement the authorizing_objects method
# FIXME: Properly deal with anonymous users - or are w... | Ruby |
module SearchableModel
def self.included(model)
model.extend(ClassMethods)
end
def self.sphinx_servers
@@sphinx_servers ||= begin
servers = CMS_CONFIG['FULLTEXT']
(servers or '').split(',').map do |host_port|
{ :host => host_port.split(':')[0],
:port => host_port.split(':')[... | Ruby |
# RelatedModel mixin
#
# Many mixins that exist for managing relationships, and especially the relationship
# traversal functions that are used in the context of authorization.
#
# Also creates some useful scoping functions that allow you to
# create scopes for relationships with very little code. Example usage:
#
# In... | Ruby |
module SluggedModel
def compact_slug
return slug unless parent
cslug = slug
cslug[parent.slug] = '' if cslug[parent.slug] # Substring replacement of parent.slug with ''
return cslug
end
def self.included(model)
model.extend(ClassMethods)
model.class_eval do
validates :slug, :presen... | Ruby |
module BusinessObjectsHelper
def related_objects(instance)
if instance.is_a?(System) && instance.is_biz_process?
instance.class.related_models("Process")
else
instance.class.related_models
end
end
def arranged_related_objects(instance)
end
end
| Ruby |
module WelcomeHelper
end
| Ruby |
module ApplicationHelper
# Shorthand humanized text for admin pages
def pat(sym)
sym.to_s.humanize
end
# Default time display (localize at some point)
def display_time(time)
time.strftime("%Y-%m-%d %H:%M") rescue "-"
end
#:nocov:
# FIXME: No obvious way to sanely test this.
# Use instead of ... | Ruby |
module FormHelper
# Simple helper for repetitive form error spans
def error_messages_inline(f, field_name)
capture_haml do
haml_tag :span, :class => 'help-inline' do
f.object.errors[field_name].each do |error|
haml_tag :span do
haml_concat "#{error}"
end
en... | Ruby |
module CyclesHelper
def generate_default_title_for_cycle(program=nil)
default_title = (program.nil? ? "" : program.title + " ") + "Audit"
count = Cycle.where(Cycle.arel_table[:title].matches("%#{default_title}%")).count
default_title += count > 0 ? " " + (count + 1).to_s : ""
return "#{Date.today.ye... | Ruby |
module ImportHelper
def trim_array(a)
while !a.empty? && a.last.blank?
a.pop
end
a
end
def validate_import_slug(object, object_name, expected_slug)
raise ImportException.new("#{object_name} Code column does not exist") unless object["slug"]
raise ImportException.new("#{object_name} Code... | Ruby |
module ManyHelper
# Many to many AJAX page - show form.
#
# Example:
# if request.put?
# post_many2many(:left_class => Control,
# :right_class => DocumentDescriptor,
# :right_relation => :evidence_descriptors,
# :right_ids => :evid... | Ruby |
require 'prawn_monkeypatch'
module EvidenceHelper
include ApplicationHelper
# Capture evidence on Google Docs
#
# Convert the evidence document to PDF and watermark it with:
#
# * Acceptance date
# * Who accepted the evidence
# * Which system was the evidence attached to
#
# The PDF is then upload... | Ruby |
module AuthorizationHelper
# Roles
def access_control_roles
[:user, :admin, :risk, :admin_risk, :no_access]
end
def allowed_objs(objects, ability)
objects
#Authorization::allowed_objects(ability, @current_user, objects)
end
def check_model_risk_authorization(models)
if current_user.can_man... | Ruby |
# Helper methods defined here can be accessed in any controller or view in the application
module GdataHelper
# Transform a list of docs to a map by title
def gdocs_by_title(docs)
by_title = {}
docs.values.each do |doc|
by_title[doc.full_title] = doc
end
by_title
end
# Check if this is a... | Ruby |
module SlugfilterHelper
def walk_slug_tree(tree, options=nil, &block)
options ||= {}
depth = options[:depth]
capture_haml do
walk_slug_tree_children_helper(tree, nil, true, depth, options, &block)
end
end
def walk_slug_tree_children_helper(tree, step=nil, odd=true, depth=nil, options=nil, ... | Ruby |
module MappingHelper
end
| Ruby |
module DashboardHelper
def init_quick_find
@quick_find ||= {}
@quick_find[:controls] ||= Control.all
@quick_find[:systems] ||= System.where(:is_biz_process => false).all
@quick_find[:biz_processes] ||= System.where(:is_biz_process => true).all
end
end
| Ruby |
module DirectivesHelper
# Set up a directive and relevant stats for display
def directive_stats(directive)
stats = {}
stats[:sections_count] = Section.where(:directive_id => directive.id).count()
stats[:sections_done_count] = Section.joins(:controls).where(:directive_id => directive.id).count(:distinct ... | Ruby |
# Helper methods defined here can be accessed in any controller or view in the application
module DocumentHelper
# Transform a document URL for display purposes.
#
# Currently just transforms a Google Docs url to the editable document
# version.
def transform_document_url(url)
gdoc_url = Gdoc.edit_url_fr... | Ruby |
module ProgramsDashHelper
end
| Ruby |
module ControlsHelper
def control_params
control_params = params[:control] || {}
if control_params[:directive_id]
# TODO: Validate the user has access to add controls to the directive
control_params[:directive] = Directive.where(:id => control_params.delete(:directive_id)).first
end
%w(typ... | Ruby |
class UrlValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
valid = begin
URI.parse(value).kind_of?(URI::HTTP)
rescue URI::InvalidURIError
false
end
unless valid
record.errors[attribute] << (options[:message] || "is an invalid URL")
end
end
e... | Ruby |
class EmailValidator < ActiveModel::EachValidator
EMAIL_RE = /([^@\s]+)(?:@((?:[-a-z0-9]+\.)+[a-z]{2,}))/i
EMAILS_RE = /\A\s*#{EMAIL_RE}(?:\s*[, ]\s*#{EMAIL_RE})*\Z/i
def validate_each(record, attribute, value)
unless value =~ /^#{EMAIL_RE}$/
record.errors[attribute] << (options[:message] || "must be a... | Ruby |
class MultiEmailValidator < ActiveModel::EachValidator
EMAIL_RE = /([^@\s]+)(?:@((?:[-a-z0-9]+\.)+[a-z]{2,}))/i
EMAILS_RE = /\A\s*#{EMAIL_RE}(?:\s*[, ]\s*#{EMAIL_RE})*\Z/i
def validate_each(record, attribute, value)
unless value =~ EMAILS_RE #/\A([^@\s]+)(?:@((?:[-a-z0-9]+\.)+[a-z]{2,}))?\z/i
record.er... | Ruby |
require 'authorization'
# class to manage user accounts on CMS. Note that this class is different
# than the Person class, because not all people responsible for compliance will
# have an account.
class Account < ActiveRecord::Base
include AuthoredModel
attr_accessor :password, :password_confirmation
attr_acc... | Ruby |
# System to Control many to many
class SystemControl < ActiveRecord::Base
include CommonModel
include StateModel
attr_accessible :control, :system, :cycle
belongs_to :control
belongs_to :system
belongs_to :cycle
is_versioned_ext
def self.by_system_control(system_id, control_id, cycle)
sc = Syste... | Ruby |
require 'slugged_model'
# A company / regulation control
#
class Control < ActiveRecord::Base
include CommonModel
include SluggedModel
include SearchableModel
include AuthorizedModel
include RelatedModel
include SanitizableAttributes
include DatedModel
CATEGORY_TYPE_ID = 100
CATEGORY_ASSERTION_TYPE_... | Ruby |
class SectionSweeper < ActionController::Caching::Sweeper
observe Section, ControlSection
# TODO: monitor implementing_controls
def after_create(section)
expire_cache_for(section)
end
def after_update(section)
expire_cache_for(section)
end
def after_destroy(section)
expire_cache_for(sectio... | Ruby |
class PbcList < ActiveRecord::Base
include AuthoredModel
include AuthorizedModel
include SanitizableAttributes
attr_accessible :audit_cycle
belongs_to :audit_cycle, :class_name => 'Cycle'
has_many :requests, :dependent => :destroy
has_many :control_assessments, :dependent => :destroy
is_versioned_ex... | Ruby |
class Option < ActiveRecord::Base
include AuthoredModel
include SanitizableAttributes
attr_accessible :role, :title, :description, :required
def to_s
title
end
scope :options_for, lambda { |role| where(:role => role) }
scope :ordered_by_title_desc, order("#{table_name}.title DESC")
is_versioned_... | Ruby |
class Response < ActiveRecord::Base
include AuthoredModel
include AuthorizedModel
attr_accessible :request, :system, :status, :population, :samples,
:population_document, :sample_worksheet_document, :sample_evidence_document
belongs_to :request
belongs_to :system
has_one :population_sample, :dependen... | Ruby |
class Risk < ActiveRecord::Base
include AuthoredModel
include SluggedModel
include SearchableModel
include AuthorizedModel
include RelatedModel
include SanitizableAttributes
include DatedModel
RATINGS = {
1 => "Minimal",
2 => "Moderate",
3 => "Significant",
4 => "Major",
5 => "Extre... | Ruby |
# A user session
class UserSession < Authlogic::Session::Base
extend ActiveModel::Naming
authenticate_with Account
cookie_key "_cms_cred"
end
| Ruby |
# Program to Directive many to many
class ProgramDirective < ActiveRecord::Base
include CommonModel
attr_accessible :program, :directive
belongs_to :program
belongs_to :directive
is_versioned_ext
#def self.by_system_control(system_id, control_id, cycle)
# sc = SystemControl
# .where(:system_id =... | Ruby |
class OrgGroup < ActiveRecord::Base
include AuthoredModel
include SluggedModel
include SearchableModel
include AuthorizedModel
include RelatedModel
include SanitizableAttributes
include BusinessObjectModel
include DatedModel
attr_accessible :title, :slug, :description, :url, :version, :start_date, ... | Ruby |
class PopulationSample < ActiveRecord::Base
include CommonModel
attr_accessible :response, :population_document, :population, :sample_worksheet_document, :samples, :sample_evidence_document
belongs_to :response
belongs_to :population_document, :class_name => "Document"
belongs_to :sample_worksheet_document... | Ruby |
# Risk to RiskyAttribute many to many
class RiskRiskyAttribute < ActiveRecord::Base
include CommonModel
attr_accessible :risk, :risky_attribute
belongs_to :risk
belongs_to :risky_attribute
is_versioned_ext
#def self.by_system_control(system_id, control_id, cycle)
# sc = SystemControl
# .where(:s... | Ruby |
# Control to Risk many to many
class ControlRisk < ActiveRecord::Base
include CommonModel
attr_accessible :control, :risk
belongs_to :control
belongs_to :risk
is_versioned_ext
#def self.by_control_risk(risk_id, control_id, cycle)
# sc = ControlRisk
# .where(:risk_id => risk_id,
# :co... | Ruby |
# A Regulation, Policy, or Contract
class Directive < ActiveRecord::Base
include CommonModel
include SluggedModel
include SearchableModel
include AuthorizedModel
include RelatedModel
include SanitizableAttributes
include DatedModel
KINDS = [
"Regulation",
"Company Controls Policy",
"Compan... | Ruby |
# A link between systems
class SystemSystem < ActiveRecord::Base
include AuthoredModel
attr_accessible :parent, :child, :type, :order
belongs_to :parent,
:foreign_key => 'parent_id', :class_name => 'System'
belongs_to :child,
:foreign_key => 'child_id', :class_name => 'System'
is_versioned_ext
... | Ruby |
class ControlAssessment < ActiveRecord::Base
include AuthoredModel
include AuthorizedModel
include SanitizableAttributes
has_many :requests, :dependent => :nullify
belongs_to :pbc_list
belongs_to :control
attr_accessible :control_version, :external_tod, :external_toe, :internal_tod, :internal_toe, :not... | Ruby |
class Product < ActiveRecord::Base
include AuthoredModel
include SluggedModel
include SearchableModel
include AuthorizedModel
include RelatedModel
include SanitizableAttributes
include BusinessObjectModel
include DatedModel
attr_accessible :title, :slug, :description, :url, :version, :type, :start_da... | Ruby |
# A system to be audited
class System < ActiveRecord::Base
include CommonModel
include SluggedModel
include SearchableModel
include AuthorizedModel
include RelatedModel
include SanitizableAttributes
include DatedModel
CATEGORY_TYPE_ID = 101
attr_accessible :title, :slug, :description, :url, :version... | Ruby |
# A Person
#
# Normally an owner or otherwise responsbile for an audit function.
class Person < ActiveRecord::Base
include AuthoredModel
include AuthorizedModel
include RelatedModel
attr_accessible :email, :name, :company, :language
has_one :account
has_many :object_people, :dependent => :destroy
belo... | Ruby |
class Transaction < ActiveRecord::Base
include CommonModel
include SanitizableAttributes
attr_accessible :system, :title, :description
belongs_to :system
is_versioned_ext
sanitize_attributes :description
def display_name
title
end
end
| Ruby |
class Help < ActiveRecord::Base
include AuthoredModel
include SearchableModel
include AuthorizedModel
include SanitizableAttributes
is_versioned_ext
sanitize_attributes :content
attr_accessible :title, :content, :slug
end
| Ruby |
# System to CO many to many relationship
# `state` is the rolled up state from the System to Control association
class SystemSection < ActiveRecord::Base
include AuthoredModel
include StateModel
attr_accessible :section, :system
belongs_to :section
belongs_to :system
is_versioned_ext
end
| Ruby |
class Request < ActiveRecord::Base
include AuthoredModel
include AuthorizedModel
include SanitizableAttributes
include DatedModel
TYPES = {
1 => "Documentation",
2 => "Population Sample",
3 => "Interview"
}
STATUSES = [
"Draft",
"Requested",
"Responded",
"Amended/Updated Requ... | Ruby |
class Relationship < ActiveRecord::Base
include AuthoredModel
# Note: No accessible attributes - you pretty much
# never want to allow changes to these without authorization.
belongs_to :source, :polymorphic => true
belongs_to :destination, :polymorphic => true
belongs_to :relationship_type
is_versione... | Ruby |
require 'slugged_model'
# A control objective (inverse of risk)
#
# The slug of a Section has to have the slug of the parent as prefix.
class Section < ActiveRecord::Base
include CommonModel
include SluggedModel
include SearchableModel
include AuthorizedModel
include RelatedModel
include SanitizableAttribu... | Ruby |
# A Document
#
# Can either be linked by a URL or attached from Google Docs.
class Document < ActiveRecord::Base
include AuthoredModel
include AuthorizedModel
include RelatedModel
include SanitizableAttributes
VALID_SCHEMES = ['http', 'https', 'file']
attr_accessible :link, :title, :description, :type, :k... | Ruby |
class ObjectDocument < ActiveRecord::Base
include AuthoredModel
include AuthorizedModel
include RelatedModel
include DatedModel
attr_accessible :document, :documentable, :role, :notes, :start_date, :stop_date
belongs_to :document
belongs_to :documentable, :polymorphic => true
is_versioned_ext
def ... | Ruby |
# A Program which links Directives
#
# The top of the Program -> Directive -> Control hierarchy
class Program < ActiveRecord::Base
include CommonModel
include SluggedModel
include SearchableModel
include AuthorizedModel
include RelatedModel
include SanitizableAttributes
include DatedModel
KINDS = [
... | Ruby |
class ControlControl < ActiveRecord::Base
include AuthoredModel
attr_accessible :control, :implemented_control
belongs_to :control
belongs_to :implemented_control, :class_name => 'Control'
is_versioned_ext
end
| Ruby |
class Facility < ActiveRecord::Base
include AuthoredModel
include SluggedModel
include SearchableModel
include AuthorizedModel
include RelatedModel
include SanitizableAttributes
include BusinessObjectModel
include DatedModel
attr_accessible :title, :slug, :description, :url, :version, :start_date, :s... | Ruby |
class RelationshipType < ActiveRecord::Base
include AuthoredModel
include SanitizableAttributes
# attr_accessible :title, :body
self.primary_key = 'relationship_type'
has_many :relationships
is_versioned_ext
sanitize_attributes :description
end
| Ruby |
class Market < ActiveRecord::Base
include AuthoredModel
include SluggedModel
include SearchableModel
include AuthorizedModel
include RelatedModel
include SanitizableAttributes
include BusinessObjectModel
include DatedModel
attr_accessible :title, :slug, :description, :url, :version, :start_date, :sto... | Ruby |
class Category < ActiveRecord::Base
include AuthoredModel
attr_accessible :name, :scope_id, :parent, :required
scope :ctype, lambda { |sid| where(:scope_id => sid) }
acts_as_nested_set :scope => :scope_id, :dependent => :destroy
has_many :categorizations, :dependent => :destroy
has_many :controls, :throu... | Ruby |
class DataAsset < ActiveRecord::Base
include AuthoredModel
include SluggedModel
include SearchableModel
include AuthorizedModel
include RelatedModel
include SanitizableAttributes
include BusinessObjectModel
include DatedModel
attr_accessible :title, :slug, :description, :url, :version, :start_date, :... | Ruby |
class Project < ActiveRecord::Base
include AuthoredModel
include SluggedModel
include SearchableModel
include AuthorizedModel
include RelatedModel
include SanitizableAttributes
include BusinessObjectModel
include DatedModel
attr_accessible :title, :slug, :description, :url, :version, :start_date, :st... | Ruby |
# An Audit Cycle
#
# Used to group evidence for a particular audit of a program
# start_at is the audit period start date. If missing, this is a continuous process.
class Cycle < ActiveRecord::Base
include CommonModel
include AuthorizedModel
include SanitizableAttributes
include DatedModel
attr_accessible :... | Ruby |
class ControlSweeper < ActionController::Caching::Sweeper
observe Control
def after_create(control)
expire_cache_for(control)
end
def after_update(control)
expire_cache_for(control)
end
def after_destroy(control)
expire_cache_for(control)
end
private
def expire_cache_for(control)
#... | Ruby |
class ObjectPerson < ActiveRecord::Base
include AuthoredModel
include AuthorizedModel
include RelatedModel
include DatedModel
attr_accessible :person, :personable, :notes, :start_date, :stop_date
belongs_to :person
belongs_to :personable, :polymorphic => true
is_versioned_ext
validates :role, :pre... | Ruby |
class ControlSection < ActiveRecord::Base
include AuthoredModel
attr_accessible :control, :section
belongs_to :control
belongs_to :section
is_versioned_ext
end
| Ruby |
class RiskyAttribute < ActiveRecord::Base
include AuthoredModel
include SluggedModel
include SearchableModel
include AuthorizedModel
include RelatedModel
include SanitizableAttributes
include DatedModel
TYPE_STRINGS = %w(OrgGroup Product Facility Market Project DataAsset Process System)
attr_accessi... | Ruby |
class Categorization < ActiveRecord::Base
include AuthoredModel
attr_accessible :category, :categorizable
belongs_to :category
belongs_to :categorizable, :polymorphic => true
is_versioned_ext
end
| Ruby |
class Meeting < ActiveRecord::Base
include CommonModel
attr_accessible :response, :start_at, :calendar_url
belongs_to :response
is_versioned_ext
validates_presence_of :response, :calendar_url
def display_name
"#{response.system.title} meeting"
end
def calendar_url
self[:calendar_url].gsub ... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
require 'csv'
class DirectivesController < BaseObjectsController
# FIXME: Decide if the :section, controls, etc.
# methods should be moved, and what access controls they
# need.
before_filter :load_di... | Ruby |
# Handle PBC Lists
require 'csv'
class ImportException < Exception
end
class PbcListsController < BaseObjectsController
include ImportHelper
PBC_METADATA_MAP = Hash[*%w(
Type type
)]
PBC_REQUEST_MAP = Hash[*%w(
Request\ Type type_name
Control\ Code pbc_control_code
Control\ Description pbc_... | Ruby |
class SystemControlsController < BaseMappingsController
# access_control :acl do
# allow :superuser
# end
def index
@objects = SystemControl
if params[:system_id].present?
@objects = @objects.where(:system_id => params[:system_id])
end
if params[:control_id].present?
@objects = @obj... | Ruby |
class CategorizationsController < BaseMappingsController
# access_control :acl do
# allow :superuser
# end
def index
@objects = Categorization
if params[:object_id].present?
@objects = @objects.where(
:categorizable_type => params[:object_type],
:categorizable_id => params[:object... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2011
# License:: Apache 2.0
# Handle evidence collection
class EvidenceController < ApplicationController
include GdataHelper
include DocumentHelper
include EvidenceHelper
include ApplicationHelper
# access_control :acl do
# ... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Handle Org Groups
class OrgGroupsController < BusinessObjectsController
# access_control :acl do
# # FIXME: Implement real authorization
#
# allow :superuser
#
# actions :index do
# allow :re... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Handle Products
class ProductsController < BusinessObjectsController
# access_control :acl do
# # FIXME: Implement real authorization
#
# allow :superuser
#
# actions :index do
# allow :read,... | Ruby |
# Handle RiskyAttributes
class RiskyAttributesController < BaseObjectsController
# access_control :acl do
# # FIXME: Implement real authorization
#
# allow :superuser
#
# actions :index do
# allow :read, :read_risky_attribute
# end
#
# actions :new, :create do
# allow :create, :create_risky_a... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Browse sections
class SectionsController < BaseObjectsController
include DirectivesHelper
cache_sweeper :section_sweeper, :only => [:create, :update, :destroy]
# access_control :acl do
# allow :sup... | Ruby |
class BaseObjectsController < ApplicationController
include ApplicationHelper
before_filter :load_object,
:only => [ :show, :edit, :update, :delete, :destroy, :tooltip]
def index
object_set = model_class
if params[:s].present?
if object_set.respond_to?(:fulltext_search)
object_set = ob... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2011
# License:: Apache 2.0
# This class is the base for all controllers used in this app
#require 'dm-rails/middleware/identity_map'
class ApplicationController < ActionController::Base
include ApplicationHelper
include Authorizati... | Ruby |
class WelcomeController < ApplicationController
skip_before_filter :require_user
access_control :acl do
allow all
end
def index
session[:return_to] = login_dispatch_path
if current_user
redirect_to programs_dash_path
end
end
def login_dispatch
if current_user.nil?
redirect... | Ruby |
class MeetingsController < BaseObjectsController
# access_control :acl do
# allow :superuser
# end
layout 'dashboard'
no_base_action :index, :show, :tooltip
private
def object_path
flow_pbc_list_path(@meeting.response.request.pbc_list_id)
end
def post_destroy_path
flow_pbc_list_... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Admin dashboard
class AdminDashController < ApplicationController
# access_control :acl do
# allow :superuser
# end
before_filter :check_admin_authorization
layout 'dashboard'
def index
... | Ruby |
# Author:: Daniel Ring (mailto:danring+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
class CategoriesController < BaseObjectsController
# access_control :acl do
# allow :superuser
# end
layout 'dashboard'
no_base_action :tooltip
def index
@categories = Category
if params[... | Ruby |
class BaseMappingsController < ApplicationController
include ApplicationHelper
def create
if params[:items].present?
errors, objects = {}, {}
ActiveRecord::Base.transaction do
params[:items].keys.each do |id|
item_errors, item_object = create_or_update_object(params[:items][id])
... | Ruby |
class HelpController < ApplicationController
layout 'help'
# access_control :acl do
# allow logged_in
# end
# Render the requested partial under 'help'
def edit
slug = params[:help]['slug']
@help = Help.find_by_slug(slug) ||
Help.new(:slug => slug)
@help.title = params[:help]['title']
... | Ruby |
# Handle projects
class ProjectsController < BusinessObjectsController
access_control :acl do
# FIXME: Implement real authorization
allow :superuser
actions :new, :create do
allow :create, :create_project
end
actions :edit, :update do
allow :update, :update_project, :of => :project... | Ruby |
class RiskRiskyAttributesController < BaseMappingsController
# access_control :acl do
# allow :superuser
# end
before_filter :check_risk_authorization
def index
@objects = RiskRiskyAttribute
if params[:risk_id].present?
@objects = @objects.where(:risk_id => params[:risk_id])
end
if p... | Ruby |
class ProgramDirectivesController < BaseMappingsController
# access_control :acl do
# allow :superuser
# end
def index
@objects = ProgramDirective
if params[:program_id].present?
@objects = @objects.where(:program_id => params[:program_id])
if params[:directive_meta_kind].present?
@... | Ruby |
# Handle Requests
class RequestsController < BaseObjectsController
# access_control :acl do
# # FIXME: Implement real authorization
#
# allow :superuser
#
# actions :index do
# allow :read, :read_request
# end
#
# actions :new, :create do
# allow :create, :create_request
# end
#
# actio... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
class CyclesController < BaseObjectsController
# access_control :acl do
# allow :superuser
#
# actions :new, :create do
# allow :create, :create_cycle
# end
#
# actions :show, :tooltip do
# ... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Handle Controls
class ControlsController < BaseObjectsController
include ControlsHelper
include AuthorizationHelper
before_filter :load_control, :only => [:sections,
... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Handle markets
class MarketsController < BusinessObjectsController
# access_control :acl do
# # FIXME: Implement real authorization
#
# allow :superuser
#
# actions :new, :create do
# allow :... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.