source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/helpers/datasets_helper.rb | Ruby | mit | 47 | master | 1,260 | module DatasetsHelper
# for printing a list of key values in the dataset items will
# be skipped if there is no content (or it throws an error)
def detail_item title
begin
throw unless value = yield
content_tag(:p, content_tag(:dt, title << ' ') + content_tag(:dd, value))
rescue
""
... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/helpers/flowchart_helper.rb | Ruby | mit | 47 | master | 12,200 | module FlowchartHelper
# def render_graph(dependencies, questions)
# output = ""
# questions.each_with_index do |q, index|
# output += question(q, index, dependencies, questions)
# end
#
# @deps.reverse.join("\r\n").gsub("’", "'")
# @levels.each do |k, l|
# unless k.nil?
# c... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/helpers/certificates_helper.rb | Ruby | mit | 47 | master | 6,220 | module CertificatesHelper
def prefixes
{
:cc => RDF::Vocabulary.new("http://creativecommons.org/ns#"),
:dc => RDF::Vocabulary.new("http://purl.org/dc/elements/1.1/"),
:dcat => RDF::Vocabulary.new("http://www.w3.org/ns/dcat#"),
:dct => RDF::Vocabulary... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/survey_parsing.rb | Ruby | mit | 47 | master | 807 | class SurveyParsing < ActiveRecord::Base
# Placeholder to track the MD5 of a survey file, so the deployment rake task can determine whether the survey has been
# updated or not.
attr_accessible :file_name
def jurisdiction
match = file_name.match(/\.(..)\.rb$/)
match ? match[1] : 'GB'
end
def trans... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/dependency_condition.rb | Ruby | mit | 47 | master | 2,551 | class DependencyCondition < ActiveRecord::Base
unloadable
include Surveyor::Models::DependencyConditionMethods
# overriding the to_hash method to add support for:
#
# condition_X :q_name, '==', {:string_value => '', :answer_reference => '1'}
#
# in the original implementation this doesn't work becau... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/kitten_data.rb | Ruby | mit | 47 | master | 14,103 | class KittenData < ActiveRecord::Base
belongs_to :response_set, inverse_of: :kitten_data
attr_accessor :automatic
attr_accessible :data, :url, :response_set, :automatic
serialize :data
after_initialize :request_data, :if => :new_record?
DATA_LICENCES = {
"http://opendatacommons.org/licenses/by/" => ... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/dataset.rb | Ruby | mit | 47 | master | 4,005 | class Dataset < ActiveRecord::Base
include Ownership
belongs_to :user
delegate :name, :email, :to => :user, :prefix => true, :allow_nil => true
attr_accessible :title
after_touch :destroy_if_no_responses
has_many :response_sets, :order => "response_sets.created_at DESC"
has_many :certificates, :throug... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/embed_stat.rb | Ruby | mit | 47 | master | 1,037 | class EmbedStat < ActiveRecord::Base
belongs_to :dataset
delegate :title, :to => :dataset, :prefix => true, :allow_nil => true
attr_accessible :referer
validates :referer, url: true
validates_uniqueness_of :referer, :scope => :dataset_id
before_save :extract_domain
def self.csv
CSV.generate(row_s... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/response.rb | Ruby | mit | 47 | master | 3,822 | class Response < ActiveRecord::Base
include ActionView::Helpers::SanitizeHelper
include Surveyor::Models::ResponseMethods
extend Memoist
attr_writer :reference_identifier
attr_accessible :autocompleted, :explanation
belongs_to :response_set, touch: true, inverse_of: :responses
belongs_to :question, :inv... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/certificate.rb | Ruby | mit | 47 | master | 5,557 | class Certificate < ActiveRecord::Base
include Badges, Counts, Ownership
include AASM
belongs_to :response_set, touch: true, inverse_of: :certificate
has_one :survey, through: :response_set
has_one :user, through: :response_set
has_one :dataset, through: :response_set
has_one :certificate_generator,... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/stat.rb | Ruby | mit | 47 | master | 1,660 | class Stat < ActiveRecord::Base
def self.generate(type, result)
create({
name: type,
all: result.count,
expired: expired(result),
publishers: publishers(result),
this_month: this_month(result),
level_none: level('none', result),
level_basic: level('basic', ... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/question.rb | Ruby | mit | 47 | master | 8,764 | class Question < ActiveRecord::Base
# Mustache
include Surveyor::MustacheContext
belongs_to :survey_section, :inverse_of => :questions
belongs_to :question_group, :dependent => :destroy
has_many :answers, :dependent => :destroy, :inverse_of => :question # it might not always have answers
has_one :dependenc... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/answer.rb | Ruby | mit | 47 | master | 1,319 | class Answer < ActiveRecord::Base
include Surveyor::Models::AnswerMethods
attr_accessible :corresponding_requirements, :help_text_more_url, :input_type, :placeholder, :text_as_statement
serialize :corresponding_requirements, Array
scope :urls, where(:input_type => 'url')
scope :for_id, lambda { |id| where(... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/verification.rb | Ruby | mit | 47 | master | 408 | class Verification < ActiveRecord::Base
belongs_to :user
belongs_to :certificate
attr_accessible :value, :user_id
validates :user_id, presence: true, uniqueness: {scope: :certificate_id}
validates :certificate_id, presence: true
validate :not_same_user
def not_same_user
if self.user == cert... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/ability.rb | Ruby | mit | 47 | master | 1,240 | class Ability
include CanCan::Ability
def initialize(user)
can :manage, ResponseSet do |response_set|
response_set.nil? || response_set.unowned_or_by?(user)
end
can :read, Dataset do |dataset|
dataset.visible? || user.try(:admin?) || dataset.owned_by?(user)
end
can :manage, Datas... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/response_set.rb | Ruby | mit | 47 | master | 15,557 | require 'odibot'
class ResponseSet < ActiveRecord::Base
include Surveyor::Models::ResponseSetMethods
include AASM
include Ownership
# Surveyor field types
VALUE_FIELDS = [:datetime_value, :integer_value, :float_value, :unit, :text_value, :string_value]
# Default title for a response set / dataset
DEFAU... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/claim.rb | Ruby | mit | 47 | master | 1,377 | class Claim < ActiveRecord::Base
include AASM
include Ownership
DELIVERY_ADMIN_OVERRIDE = true
belongs_to :dataset
belongs_to :user
belongs_to :initiating_user, class_name: 'User'
validates_associated :user, :dataset, :initiating_user
scope :outstanding, where(:aasm_state => [:new, :notified])
be... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/survey_translation.rb | Ruby | mit | 47 | master | 284 | class SurveyTranslation < ActiveRecord::Base
unloadable
include Surveyor::Models::SurveyTranslationMethods
def locale_name
I18n.translate(locale, scope: 'locales') || to_hash[locale] || locale
end
def to_hash
@to_hash ||= YAML.load(translation || "{}")
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/certification_campaign.rb | Ruby | mit | 47 | master | 1,750 | class CertificationCampaign < ActiveRecord::Base
include Ownership
attr_accessor :version
validates :name, uniqueness: true, presence: true
validates :url, :jurisdiction, presence: true, if: :validate_extra_details?
validates :limit, numericality: { greater_than: 0 }, allow_blank: true
has_many :certif... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/certificate_generator.rb | Ruby | mit | 47 | master | 8,876 | class CertificateGenerator < ActiveRecord::Base
include Ownership
belongs_to :user
belongs_to :response_set, :inverse_of => :certificate_generator
belongs_to :certification_campaign
has_one :dataset, through: :response_set
has_one :certificate, through: :response_set
has_one :survey, through: :response_... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/transfer.rb | Ruby | mit | 47 | master | 1,296 | class Transfer < ActiveRecord::Base
include AASM
attr_accessible :target_email, :dataset_id, :token_confirmation
before_save :downcase_target_email
before_create :generate_token
attr_readonly :token
attr_accessor :token_confirmation
belongs_to :user
belongs_to :target_user, class_name: 'User'
belon... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/survey_section.rb | Ruby | mit | 47 | master | 1,305 | class SurveySection < ActiveRecord::Base
unloadable
include Surveyor::Models::SurveySectionMethods
attr_accessible :display_header
scope :with_includes, { :include => {:questions => [:answers, :question_group, :survey_section, {:dependency => :dependency_conditions}]}}
def questions_for_certificate(respons... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/survey.rb | Ruby | mit | 47 | master | 6,036 | class Survey < ActiveRecord::Base
include Surveyor::Models::SurveyMethods
serialize :meta_map, Hash
STATUSES = %w(alpha beta final)
REQUIREMENT_LEVELS = %w(none basic pilot standard exemplar)
# Hash of access survey codes which have changed
MIGRATIONS = {'open-data-certificate-questionnaire' => 'gb'}
... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/user.rb | Ruby | mit | 47 | master | 1,977 | class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable
has_many :datasets, :order => "datasets.created_at DESC"
has_many :response_sets
has_many :sent_claims, class_name: 'Claim', foreign_key: 'initiating_us... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/dependency.rb | Ruby | mit | 47 | master | 967 | class Dependency < ActiveRecord::Base
unloadable
include Surveyor::Models::DependencyMethods
def is_met?(response_set, responses_pre = nil)
ch = conditions_hash(response_set, responses_pre)
return false if ch.blank?
# logger.debug "rule: #{self.rule.inspect}"
# logger.debug "rexp: #{rgx.inspect}... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/concerns/ownership.rb | Ruby | mit | 47 | master | 231 | module Ownership
extend ActiveSupport::Concern
def owned_by?(account)
user.present? && user == account
end
def unowned?
user.nil?
end
def unowned_or_by?(account)
unowned? || owned_by?(account)
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/concerns/badges.rb | Ruby | mit | 47 | master | 666 | module Badges
extend ActiveSupport::Concern
def badge_file_for_level(level)
if level == 'no_level'
filename = 'no_level_badge.png'
else
filename = 'basic_level_badge.png'
end
File.open(File.join(Rails.root, 'app/assets/images/badges', filename))
end
def badge_file
badge_file_f... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/models/concerns/counts.rb | Ruby | mit | 47 | master | 871 | module Counts
extend ActiveSupport::Concern
module ClassMethods
def counts
Hash[[:all, :all_this_month, :published, :published_this_month, :levels].map do |count|
[count, Certificate.send("count_#{count}")]
end]
end
def count_levels
Hash[[:basic, :pilot, :standard, :expert].... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/exporters/datasets_csv.rb | Ruby | mit | 47 | master | 2,053 | class DatasetsCSV
include ApplicationHelper
attr_reader :datasets
def initialize(datasets)
@datasets = datasets
end
def each
yield CSV.generate_line(headers)
datasets.find_each do |dataset|
yield CSV.generate_line(row(dataset))
end
end
def save(filename)
File.open(filename, '... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/controllers/campaigns_controller.rb | Ruby | mit | 47 | master | 4,760 | require 'odibot'
class CampaignsController < ApplicationController
include CampaignsHelper
before_filter :authenticate_user!
before_filter :get_campaign, except: [:index, :new, :create, :endpoint_check, :precheck, :template_typeahead]
def index
@campaigns = CertificationCampaign.where(user_id: current_us... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/controllers/main_controller.rb | Ruby | mit | 47 | master | 3,453 | class MainController < ApplicationController
def ping
if ActiveRecord::Base.connection.active?
head :ok
else
head :service_unavailable
end
end
def home
respond_to do |format|
format.html { render '/home/index' }
end
end
def discussion
@topic = 'general'
@topic_... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/controllers/response_sets_controller.rb | Ruby | mit | 47 | master | 1,892 | require 'odibot'
# Trying out having a separate controller from the central surveyor one.
class ResponseSetsController < ApplicationController
load_and_authorize_resource
def destroy
@response_set.destroy
redirect_to dashboard_path, notice: t('dashboard.deleted_response_set')
end
def publish
beg... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/controllers/certificates_controller.rb | Ruby | mit | 47 | master | 4,541 | class CertificatesController < ApplicationController
include CertificatesHelper
before_filter(:except => [:legacy_show, :certificate_from_dataset_url]) { get_certificate }
before_filter(:only => [:show]) { alternate_formats [:json] }
before_filter(:only => [:show, :badge, :embed]) { readable? }
before_filter... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/controllers/locale_controller.rb | Ruby | mit | 47 | master | 770 | class LocaleController < ApplicationController
def change_locale
redirect_to OdiLocale.changed_locale_path(params[:current_path], params[:new_locale])
end
def redirect_to_locale
new_path = request.fullpath.gsub(%r{\A/(.*)}, "/#{locale_for_redirect}/\\1")
if recognized_path?(new_path)
redirect... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/controllers/claims_controller.rb | Ruby | mit | 47 | master | 1,223 | class ClaimsController < ApplicationController
before_filter :authenticate_user!
def create
dataset = Dataset.find(claim_data[:dataset_id])
certificate = dataset.certificate
authorize! :claim, certificate
claim = current_user.sent_claims.create!(:dataset => dataset)
flash[:notice] = I18n.t('cla... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/controllers/admin_controller.rb | Ruby | mit | 47 | master | 926 | class AdminController < ApplicationController
before_filter :set_cache_buster
def index
authorize! :manage, :all
@title = "Admin"
end
def users
@user = User.find(params[:user_id])
authorize! :manage, @user
@datasets = @user.datasets.page(params[:page])
end
def typeahead
authorize... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/controllers/registrations_controller.rb | Ruby | mit | 47 | master | 572 | class RegistrationsController < Devise::RegistrationsController
respond_to :html, :js
helper_method :campaigns, :surveys
def edit
if params[:id].to_i == current_user.id
super
else
raise ActionController::RoutingError.new('Not Found')
end
end
def redirect
id = current_user.id
... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/controllers/sessions_controller.rb | Ruby | mit | 47 | master | 671 | class SessionsController < Devise::SessionsController
respond_to :js, :html
def create
if request.xhr?
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#failure")
sign_in_and_redirect(resource_name, resource)
else
super
end
end
def sign_in_an... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/controllers/transfers_controller.rb | Ruby | mit | 47 | master | 1,632 | class TransfersController < ApplicationController
def create
@transfer = Transfer.new params[:transfer]
@transfer.user = current_user
authorize! :manage, @transfer.dataset
if @transfer.save
@transfer.notify!
flash[:notice] = t('transfers.flashes.created')
else
flash[:error] = ... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/controllers/datasets_controller.rb | Ruby | mit | 47 | master | 9,504 | class DatasetsController < ApplicationController
load_and_authorize_resource
skip_authorize_resource :only => :show
before_filter :authenticate_user!, only: :dashboard
before_filter :authenticate_user_from_token!, only: [:create, :update_certificate, :import_status]
before_filter(:only => [:show, :index]) { ... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/controllers/jurisdictions_controller.rb | Ruby | mit | 47 | master | 285 | class JurisdictionsController < ApplicationController
def index
@jurisdictions = Survey.available_to_complete
.select([:title, :full_title, :status, :access_code])
.map &:attributes
render json: @jurisdictions
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/controllers/flowcharts_controller.rb | Ruby | mit | 47 | master | 935 | require 'flow'
class FlowchartsController < ApplicationController
def show
# :@jurisdiction, String
# :@type, String
# :@questions, Array
# :@dependencies, Array
# :@deps, Array
# :@levels, Hash of Arrays, the arrays contain the XML descriptive
# this all runs before the view renders? ... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/controllers/application_controller.rb | Ruby | mit | 47 | master | 2,547 | class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_locale
helper_method :after_sign_in_path_for
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
def default_url_options(options={})
{ locale: I18n.locale }
end
def after_sign_in... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/controllers/surveyor_controller.rb | Ruby | mit | 47 | master | 8,016 | class SurveyorController < ApplicationController
unloadable
before_filter :get_current_user, only: [:new, :create]
before_filter :determine_if_javascript_is_enabled, only: [:create, :update]
before_filter :set_response_set_and_render_context
before_filter :ensure_modifications_allowed, only: [:edit, :update]... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/views/datasets/show.feed.builder | Ruby | mit | 47 | master | 927 | xml.instruct! :xml, :version => "1.0"
xml.feed :xmlns => "http://www.w3.org/2005/Atom", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
xml.author do
xml.name @dataset.user_name
end
xml.updated atom_datetime(@dataset.modified_date)
xml.id dataset_url(@dataset, format: :feed, :protocol => embed_protocol... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/views/datasets/_dataset.feed.builder | Ruby | mit | 47 | master | 970 | builder.id dataset_url(dataset, :protocol => embed_protocol)
builder.link :href=> dataset_url(dataset, :protocol => embed_protocol)
builder.link :rel => "http://schema.theodi.org/certificate#certificate", :type => "text/html",
:href => dataset_latest_certificate_url(dataset.id, :protocol => embed_protocol)
bui... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/views/datasets/index.feed.builder | Ruby | mit | 47 | master | 1,558 | xml.instruct! :xml, :version => "1.0"
xml.feed :xmlns => "http://www.w3.org/2005/Atom", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
xml.author do |author|
author.name "Open Data Institute"
end
xml.id "#{embed_protocol}#{request.host_with_port}#{request.path}?#{request.query_string}"
xml.link :href =... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/workers/certificate_generator_update_worker.rb | Ruby | mit | 47 | master | 328 | class CertificateGeneratorUpdateWorker
include Sidekiq::Worker
def perform(certificate_generator_id, jurisdiction, user_id)
generator = CertificateGenerator.find(certificate_generator_id)
create_user = User.find(user_id)
CertificateGenerator.update(generator.dataset, nil, jurisdiction, create_user)
e... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/workers/certificate_generator_worker.rb | Ruby | mit | 47 | master | 363 | class CertificateGeneratorWorker
include Sidekiq::Worker
def perform(certificate_generator_id, jurisdiction, create_user, dataset_id)
generator = CertificateGenerator.find(certificate_generator_id)
dataset = Dataset.find_by_id dataset_id
unless generator.completed?
generator.generate(jurisdiction... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/inputs/select_input.rb | Ruby | mit | 47 | master | 1,008 | class SelectInput < Formtastic::Inputs::SelectInput
# prevent the <label> from having the 'label' branch
def label_html_options
{
:for => input_html_options[:id],
:class => ['question_label'],
}
end
def to_html
status = options[:status_message] || {}
input_wrapping do
[
... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/inputs/string_input.rb | Ruby | mit | 47 | master | 1,320 | class StringInput < Formtastic::Inputs::StringInput
include SurveyorHelper
# prevent the <label> from having the 'label' branch
def label_html_options
{
:for => input_html_options[:id],
:class => ['question_label'],
}
end
def label_text
((localized_label || humanized_method_name) + r... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/inputs/additional_text_input.rb | Ruby | mit | 47 | master | 488 | class AdditionalTextInput < Formtastic::Inputs::TextInput
# prevent the <label> from having the 'label' branch
def input_html_options
{
:cols => builder.default_text_area_width,
:rows => builder.default_text_area_height
}.merge(super)
end
def to_html
input_wrapping do
[
l... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/middleware/catch_json_parse_errors.rb | Ruby | mit | 47 | master | 496 | class CatchJsonParseErrors
def initialize(app)
@app = app
end
def call(env)
begin
@app.call(env)
rescue MultiJson::LoadError => error
if env['HTTP_ACCEPT'] =~ /application\/json/
error_output = "There was a problem in the JSON you submitted: #{error}"
return [
40... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/mailers/claim_mailer.rb | Ruby | mit | 47 | master | 790 | class ClaimMailer < ApplicationMailer
def notify(claim)
@claim = claim
if Claim::DELIVERY_ADMIN_OVERRIDE
to = Devise.mailer_sender
subject = I18n.t('claim_mailer.notify.admin_subject', dataset_id: @claim.dataset.id)
else
to = @claim.user.email
subject = I18n.t('claim_mailer.notify... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/mailers/devise_mailer.rb | Ruby | mit | 47 | master | 458 | class DeviseMailer < Devise::Mailer
helper :application
include Devise::Controllers::UrlHelpers
default template_path: 'devise/mailer'
def confirmation_instructions(*args)
headers['X-MC-Subaccount'] = "certificates"
super
end
def reset_password_instructions(*args)
headers['X-MC-Subaccount... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/mailers/certificate_mailer.rb | Ruby | mit | 47 | master | 343 | class CertificateMailer < ApplicationMailer
def report(certificate, reason, reporter)
@certificate = certificate
@reason = reason
@reporter = reporter
from = @reporter[:email].presence || Devise.mailer_sender
mail(subject: "Reported certificate: #{certificate.name}", to: Devise.mailer_sender, fr... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | app/presenters/certificate_presenter.rb | Ruby | mit | 47 | master | 977 | require 'delegate'
class CertificatePresenter < SimpleDelegator
def published_data
{
name: name,
publisher: curator,
created: created_at,
user: published_email,
country: survey_title,
type: survey_status,
level: attained_level,
verification_type: certification_typ... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/schema.rb | Ruby | mit | 47 | master | 18,926 | # encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative sou... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/seeds.rb | Ruby | mit | 47 | master | 414 | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
admin = User.where(admin: true).create!(
email: "test@example.com",
password: "testtest"
)
admin.confirm!
builder... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20141022100044_create_claims.rb | Ruby | mit | 47 | master | 308 | class CreateClaims < ActiveRecord::Migration
def change
create_table :claims do |t|
t.belongs_to :dataset, :null => false
t.belongs_to :initiating_user, :null => false
t.belongs_to :user, :null => false
t.string :aasm_state, :null => false
t.timestamps
end
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20141127154117_add_confirmable_devise_to_users.rb | Ruby | mit | 47 | master | 599 | class AddConfirmableDeviseToUsers < ActiveRecord::Migration
def self.up
add_column :users, :confirmation_token, :string
add_column :users, :confirmed_at, :datetime
add_column :users, :confirmation_sent_at, :datetime
add_column :users, :unconfirmed_email, :string
add_index :users, :confirmation_to... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130522123300_remove_default_title_from_dataset.rb | Ruby | mit | 47 | master | 225 | class RemoveDefaultTitleFromDataset < ActiveRecord::Migration
def up
change_column :datasets, :title, :string, default: nil
end
def down
change_column :datasets, :title, :string, default: 'Untitiled'
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20150112104243_add_domain_for_embed_stat.rb | Ruby | mit | 47 | master | 396 | class AddDomainForEmbedStat < ActiveRecord::Migration
def up
add_column :embed_stats, :domain, :string
execute("update embed_stats set domain = substring_index(substring_index(referer, '/', 3), '/', -1)")
change_column :embed_stats, :domain, :string, null: false
add_index :embed_stats, :domain, unique... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20150907141457_drop_response_cache_map.rb | Ruby | mit | 47 | master | 391 | class DropResponseCacheMap < ActiveRecord::Migration
def up
drop_table :response_cache_maps
end
def down
create_table "response_cache_maps" do |t|
t.integer "origin_id"
t.integer "target_id"
t.integer "response_set_id"
t.datetime "created_at", :null => false
t.datetime "u... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130508144200_add_placeholder_type_and_more_link_attributes.rb | Ruby | mit | 47 | master | 298 | class AddPlaceholderTypeAndMoreLinkAttributes < ActiveRecord::Migration
def change
add_column :questions, :help_text_more_url, :string
add_column :answers, :help_text_more_url, :string
add_column :answers, :input_type, :string
add_column :answers, :placeholder, :string
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130830100636_create_autocomplete_override_messages.rb | Ruby | mit | 47 | master | 258 | class CreateAutocompleteOverrideMessages < ActiveRecord::Migration
def change
create_table :autocomplete_override_messages do |t|
t.integer :response_set_id
t.integer :question_id
t.text :message
t.timestamps
end
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130520095400_add_indexes_to_database.rb | Ruby | mit | 47 | master | 1,456 | # encoding: UTF-8
class AddIndexesToDatabase < ActiveRecord::Migration
def self.up
add_index :questions, [:survey_section_id, :display_order], name: 'i_questions_on_survey_section_id_and_display_order'
add_index :questions, [:survey_section_id, :display_type, :requirement, :display_order], name: 'i_questions_... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20140724102203_add_published_at_fieldto_certificate.rb | Ruby | mit | 47 | master | 473 | class AddPublishedAtFieldtoCertificate < ActiveRecord::Migration
def up
add_column :certificates, :published_at, :datetime
add_column :certificates, :aasm_state, :string
Certificate.where(published: true).each { |c| c.update_attributes(aasm_state: :published, published_at: c.created_at) }
Certificate... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20141127120038_correct_handling_of_names.rb | Ruby | mit | 47 | master | 761 | class CorrectHandlingOfNames < ActiveRecord::Migration
def up
add_column :users, :name, :string, :null => true, :after => :email
add_column :users, :short_name, :string, :null => true, :after => :name
update(<<-SQL)
update users set short_name = first_name,
name = trim(concat(coalesce(first_... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130731203215_recompute_dataset_curator_for_certificates.rb | Ruby | mit | 47 | master | 501 | class RecomputeDatasetCuratorForCertificates < ActiveRecord::Migration
def up
# REMOVED - https://theodi.airbrake.io/groups/64547582
# puts "...this may take some time\n"
# this may still result in curator:nil for some certificates (where it's not supplied, or
# there isn't a matching question on the... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130628180246_change_response_set_default_state.rb | Ruby | mit | 47 | master | 457 | class ChangeResponseSetDefaultState < ActiveRecord::Migration
def up
change_column :response_sets, :aasm_state, :string, default: 'draft'
# update exiting
ResponseSet.where(aasm_state: 'in_progress').update_all(aasm_state: 'draft')
end
def down
change_column :response_sets, :aasm_state, :string,... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20140520143420_add_upload_usage_data_delayed_job.rb | Ruby | mit | 47 | master | 375 | class AddUploadUsageDataDelayedJob < ActiveRecord::Migration
def up
Delayed::Job.enqueue UploadUsageData, { :priority => 5, :run_at => DateTime.now.tomorrow.change(:hour => 2, :min => 00) }
end
def down
stats = Delayed::Job.enqueue UploadUsageData, { :priority => 5, :run_at => DateTime.now.tomorrow.chang... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130807111431_update_survey_statuses.rb | Ruby | mit | 47 | master | 208 | class UpdateSurveyStatuses < ActiveRecord::Migration
class Survey < ActiveRecord::Base
end
def up
Survey.reset_column_information
Survey.where(title: 'GB').update_all(status: 'beta')
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130729153219_remove_columns_from_dataset.rb | Ruby | mit | 47 | master | 464 | class RemoveColumnsFromDataset < ActiveRecord::Migration
def up
remove_column :datasets, :documentation_url
remove_column :datasets, :curating_org
remove_column :datasets, :curator_url
remove_column :datasets, :data_kind
end
def down
add_column :datasets, :data_kind, :string
add_column :d... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130702204542_create_missing_response_set_certificates.rb | Ruby | mit | 47 | master | 234 | class CreateMissingResponseSetCertificates < ActiveRecord::Migration
def up
rsets = ResponseSet.includes(:certificate).all.select {|rs| rs.certificate.nil?}
rsets.each {|r| r.update_certificate}
end
def down
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20141110141523_remove_autocomplete_override_duplicates.rb | Ruby | mit | 47 | master | 922 | class RemoveAutocompleteOverrideDuplicates < ActiveRecord::Migration
def up
find_query = <<-SQL
select count(id) as count, response_set_id, question_id
from `autocomplete_override_messages`
group by response_set_id, question_id
having count(id) > 1;
SQL
select_rows(find_query).each... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130517144237_add_default_title_to_dataset.rb | Ruby | mit | 47 | master | 220 | class AddDefaultTitleToDataset < ActiveRecord::Migration
def up
change_column :datasets, :title, :string, default: 'Untitiled'
end
def down
change_column :datasets, :title, :string, default: nil
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130912193154_update_translation_text_size.rb | Ruby | mit | 47 | master | 282 | class UpdateTranslationTextSize < ActiveRecord::Migration
def up
change_column :survey_translations, :translation, :text, :limit => 16777215 #mysql mediumtext
end
def down
change_column :survey_translations, :translation, :text, :limit => 65535 #mysql text
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130911191210_add_data_dump_delayed_jobs.rb | Ruby | mit | 47 | master | 635 | class AddDataDumpDelayedJobs < ActiveRecord::Migration
def up
Delayed::Job.enqueue StatsDump, { :priority => 5, :run_at => DateTime.now.tomorrow.change(:hour => 1, :min => 30) }
Delayed::Job.enqueue CertificateDump, { :priority => 5, :run_at => DateTime.now.tomorrow.change(:hour => 2, :min => 0) }
end
de... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20131205165507_create_certificate_generators.rb | Ruby | mit | 47 | master | 238 | class CreateCertificateGenerators < ActiveRecord::Migration
def change
create_table :certificate_generators do |t|
t.integer :response_set_id
t.integer :user_id
t.text :request
t.timestamps
end
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20151105151652_improve_question_requirement_columns.rb | Ruby | mit | 47 | master | 929 | class ImproveQuestionRequirementColumns < ActiveRecord::Migration
def up
add_column :questions, :is_requirement, :boolean, default: false, after: :api_id
add_column :questions, :corresponding_requirements, :string, after: :is_requirement
Question.where(display_type: 'label').where('requirement is not nul... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20141120173301_add_index_for_dataset_created_at.rb | Ruby | mit | 47 | master | 269 | class AddIndexForDatasetCreatedAt < ActiveRecord::Migration
def up
remove_index :datasets, :user_id
add_index :datasets, [:user_id, :created_at]
end
def down
remove_index :datasets, [:user_id, :created_at]
add_index :datasets, :user_id
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130515132624_create_survey_parsings.rb | Ruby | mit | 47 | master | 235 | class CreateSurveyParsings < ActiveRecord::Migration
def change
create_table :survey_parsings do |t|
t.string :file_name
t.string :md5
t.timestamps
end
add_index :survey_parsings, :file_name
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130830105802_retrospectively_set_full_title_on_surveys.rb | Ruby | mit | 47 | master | 499 | class RetrospectivelySetFullTitleOnSurveys < ActiveRecord::Migration
def up
Survey.where(full_title: nil).each do |survey|
#find the newest survey with the same title
full_title = Survey.where(title: survey.title).order('survey_version DESC').first.try(:full_title)
# update the column, so it d... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20131029142201_create_certificate_validations.rb | Ruby | mit | 47 | master | 241 | class CreateCertificateValidations < ActiveRecord::Migration
def change
create_table :certificate_validations do |t|
t.integer :user_id
t.integer :certificate_id
t.integer :value
t.timestamps
end
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20151105172643_rename_answers_requirement.rb | Ruby | mit | 47 | master | 234 | class RenameAnswersRequirement < ActiveRecord::Migration
def up
rename_column :answers, :requirement, :corresponding_requirements
end
def down
rename_column :answers, :corresponding_requirements, :requirement
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20150319115711_remove_orphaned_draft_certificates.rb | Ruby | mit | 47 | master | 265 | class RemoveOrphanedDraftCertificates < ActiveRecord::Migration
def up
delete(<<-SQL)
delete c
from certificates c
left outer join response_sets rs on (c.response_set_id = rs.id)
where rs.id is null
SQL
end
def down
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20131105143314_change_dev_event_message.rb | Ruby | mit | 47 | master | 258 | class ChangeDevEventMessage < ActiveRecord::Migration
def up
change_table :dev_events do |t|
t.change :message, :text, limit: 65535
end
end
def down
change_table :dev_events do |t|
t.change :message, :string
end
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130819113304_update_attained_index.rb | Ruby | mit | 47 | master | 226 | class UpdateAttainedIndex < ActiveRecord::Migration
def up
ResponseSet.where(aasm_state: [:archived, :published]).each do |response_set|
response_set.delay.store_attained_index
end
end
def down
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20140109155237_add_authentication_token_to_users.rb | Ruby | mit | 47 | master | 200 | class AddAuthenticationTokenToUsers < ActiveRecord::Migration
def change
add_column :users, :authentication_token, :string
add_index :users, :authentication_token, :unique => true
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130522124534_add_cert_population_fields_to_answer.rb | Ruby | mit | 47 | master | 266 | class AddCertPopulationFieldsToAnswer < ActiveRecord::Migration
def change
add_column :answers, :text_as_statement, :string
# display_on_certificate on question only
#add_column :answers, :display_on_certificate, :boolean, :default => false
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130430110001_create_datasets.rb | Ruby | mit | 47 | master | 297 | class CreateDatasets < ActiveRecord::Migration
def change
create_table :datasets do |t|
t.string :title
t.string :documentation_url
t.string :curating_org
t.string :curator_url
t.string :data_kind
t.references :user
t.timestamps
end
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130614085945_add_requirement_questions_to_requirement.rb | Ruby | mit | 47 | master | 275 | class AddRequirementQuestionsToRequirement < ActiveRecord::Migration
def change
add_column :questions, :question_corresponding_to_requirement_id, :string
add_column :questions, :answer_corresponding_to_requirement_id, :string
Question.all.map(&:save)
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20150623083433_add_latest_to_certificate_generator.rb | Ruby | mit | 47 | master | 207 | class AddLatestToCertificateGenerator < ActiveRecord::Migration
def change
add_column :certificate_generators, :latest, :boolean, default: true
add_index :certificate_generators, :latest
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20150119114745_add_extra_user_details.rb | Ruby | mit | 47 | master | 294 | class AddExtraUserDetails < ActiveRecord::Migration
def up
add_column :users, :organization, :string
add_column :users, :agreed_to_terms, :boolean, null: true, default: nil
end
def down
remove_column :users, :organization
remove_column :users, :agreed_to_terms
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130816155152_update_survey_statuses_again.rb | Ruby | mit | 47 | master | 319 | # This is a repeat of the update_survey_statuses, because the status of new
# surveys wasn't being updated
class UpdateSurveyStatusesAgain < ActiveRecord::Migration
class Survey < ActiveRecord::Base
end
def up
Survey.reset_column_information
Survey.where(title: 'GB').update_all(status: 'beta')
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20160816114008_add_limit_and_count_to_certification_campaigns.rb | Ruby | mit | 47 | master | 220 | class AddLimitAndCountToCertificationCampaigns < ActiveRecord::Migration
def change
add_column :certification_campaigns, :limit, :integer
add_column :certification_campaigns, :dataset_count, :integer
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20141124152635_admin_users_from_env.rb | Ruby | mit | 47 | master | 256 | class AdminUsersFromEnv < ActiveRecord::Migration
def up
admin_ids = ENV.fetch("ODC_ADMIN_IDS", "").split(',')
if admin_ids.any?
execute("update users set admin = 1 where id in (#{admin_ids.join(',')})")
end
end
def down
end
end |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20151104115606_remove_custom_renderers.rb | Ruby | mit | 47 | master | 399 | class RemoveCustomRenderers < ActiveRecord::Migration
def up
remove_column :answers, :custom_renderer
remove_column :question_groups, :custom_renderer
remove_column :questions, :custom_renderer
end
def down
add_column :answers, :custom_renderer, :string
add_column :question_groups, :custom_re... |
github | theodi/open-data-certificate | https://github.com/theodi/open-data-certificate | db/migrate/20130904153730_update_kitten_data.rb | Ruby | mit | 47 | master | 211 | class UpdateKittenData < ActiveRecord::Migration
def up
KittenData.reset_column_information
KittenData.all.each do |kitten_data|
kitten_data.request_data
kitten_data.save
end
end
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.