Skip to content

Instantly share code, notes, and snippets.

View mokevnin's full-sized avatar

Kirill Mokevnin mokevnin

View GitHub Profile
class Device::SearchesController < ApplicationController
##
# Search
#
# @example [Request] GET /search?q=name&page=2
# @example [Response] total: <count>, episodes: [<episode>, <episode>, ...]
#
# @overload show(q)
# @param [String] q Query string
upstream <%= @name %> {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
server unix:/u/apps/<%= @name %>/shared/.sock fail_timeout=0;
}
server {
server_name staging.club.kommersant.home;
class Company < ActiveRecord::Base
ACCOUNT_VARIANT = %w'A B C'
include Files::Company
include StateMachines::Company
validates :abbr, :uniqueness => true
validates :name, :presence => true
validates :uri, :presence => true
class W::Company < BasePresenter
present ::Company
include Files::Company
include StateMachines::Company
default_scope with_state(:published)
belongs_to :country, :class_name => 'W::Geo'
belongs_to :variant
module ConfirmationHelper
extend ActiveSupport::Concern
include AuthHelper
included do
alias_method_chain :sign_out, :confirmation_request_clear
end
module InstanceMethods
YaAcl::Builder.build do
roles do
role :admin, :name => 'Администратор'
role :remote_operator, :name => 'Удаленный Оператор'
role :editor, :name => 'Редактор'
role :taxonom, :name => 'Таксоном'
role :operator, :name => 'Оператор'
role :solo_operator, :name => 'Соло Оператор'
role :transcripter, :name => 'Транскриптер'
role :transcripts_editor, :name => 'Редактор транскриптов'
module AccessHelper
include AuthHelper
def check_access(values = {})
acl.check! self.class.to_s, self.action_name, current_roles, values
end
def current_roles
@current_roles ||= current_user.roles_hash.keys
end
class FacebookService
class << self
def register_via_google(data)
auth = User::Google.find_by_uid(data.uid)
if auth
return :block if auth.user.blocked?
auth.user.activate! unless auth.user.active?
return :success
end
require "errors"
class GoogleService
private_class_method :new
class << self
def register(data_hash)
data = AuthData.new(data_hash)
auth = User::Google.find_by_uid(data.uid)
require "errors"
class FacebookService
class << self
def register(data_hash)
data = AuthData.new(data_hash)
auth = User::Facebook.find_by_uid(data.uid)
if auth
raise UserBlockedError if auth.user.blocked?