-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stepan Boltalin
committed
Mar 13, 2012
1 parent
739b2c0
commit 8d77cf6
Showing
38 changed files
with
744 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
class ApplicationController < ActionController::Base | ||
protect_from_forgery | ||
|
||
def show_welcome_page? | ||
#overriding refinery initialization wizard behavior, so unpopulated test | ||
#database will successfully run. | ||
false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class PasswordsController < Devise::SessionsController | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class SessionsController < Devise::SessionsController | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Users::UsersController < Devise::UsersController | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class UsersController < Devise::SessionsController | ||
end |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class Role < Refinery::Core::BaseModel | ||
# TODO: This works around a bug in rails habtm with namespaces. | ||
has_and_belongs_to_many :users, :join_table => :roles_users | ||
|
||
before_validation :camelize_title | ||
validates :title, :uniqueness => true | ||
|
||
def camelize_title(role_title = self.title) | ||
self.title = role_title.to_s.camelize | ||
end | ||
|
||
def self.[](title) | ||
find_or_create_by_title(title.to_s.camelize) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class RolesUsers < Refinery::Core::BaseModel | ||
belongs_to :role | ||
belongs_to :user | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,42 @@ | ||
class User < ActiveRecord::Base | ||
class User < Refinery::Core::BaseModel | ||
# Include default devise modules. Others available are: | ||
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable | ||
devise :database_authenticatable, :registerable, | ||
:recoverable, :rememberable, :trackable, :validatable | ||
|
||
# Setup accessible (or protected) attributes for your model | ||
attr_accessible :email, :password, :password_confirmation, :remember_me | ||
end | ||
has_and_belongs_to_many :roles, :join_table => :roles_users | ||
has_many :plugins, :class_name => "UserPlugin", :order => "position ASC", :dependent => :destroy | ||
|
||
def plugins=(plugin_names) | ||
if persisted? # don't add plugins when the user_id is nil. | ||
UserPlugin.delete_all(:user_id => id) | ||
|
||
plugin_names.each_with_index do |plugin_name, index| | ||
plugins.create(:name => plugin_name, :position => index) if plugin_name.is_a?(String) | ||
end | ||
end | ||
end | ||
|
||
def authorized_plugins | ||
plugins.collect { |p| p.name } | ::Refinery::Plugins.always_allowed.names | ||
end | ||
|
||
def add_role(title) | ||
raise ArgumentException, "Role should be the title of the role not a role object." if title.is_a?(::Role) | ||
roles << ::Role[title] unless has_role?(title) | ||
end | ||
|
||
def has_role?(title) | ||
raise ArgumentException, "Role should be the title of the role not a role object." if title.is_a?(::Role) | ||
roles.any?{|r| r.title == title.to_s.camelize} | ||
end | ||
|
||
def can_delete?(user_to_delete = self) | ||
user_to_delete.persisted? and | ||
id != user_to_delete.id and | ||
!user_to_delete.has_role?(:superuser) and | ||
Role[:refinery].users.count > 1 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class UserPlugin < Refinery::Core::BaseModel | ||
belongs_to :user | ||
attr_accessible :user_id, :name, :position | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
xml.instruct! | ||
|
||
xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do | ||
|
||
@locales.each do |locale| | ||
::I18n.locale = locale | ||
::Refinery::Page.live.in_menu.includes(:parts).each do |page| | ||
# exclude sites that are external to our own domain. | ||
page_url = if page.url.is_a?(Hash) | ||
# This is how most pages work without being overriden by link_url | ||
page.url.merge({:only_path => false}) | ||
elsif page.url.to_s !~ /^http/ | ||
# handle relative link_url addresses. | ||
[request.protocol, request.host_with_port, page.url].join | ||
end | ||
|
||
# Add XML entry only if there is a valid page_url found above. | ||
xml.url do | ||
xml.loc url_for(page_url) | ||
xml.lastmod page.updated_at.to_date | ||
end if page_url.present? and page.show_in_menu? | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
development: &development | ||
adapter: mysql2 | ||
host: localhost | ||
username: root | ||
password: | ||
database: your_local_database | ||
|
||
test: &test | ||
adapter: mysql2 | ||
host: localhost | ||
username: root | ||
password: | ||
database: your_test_database | ||
|
||
production: &production | ||
adapter: mysql2 | ||
host: localhost | ||
database: your_production_database | ||
username: your_production_database_login | ||
password: your_production_database_password |
Oops, something went wrong.