Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from mjtko/kandan-131
Add ownership to channels and associated enhancements
- Loading branch information
Showing
25 changed files
with
341 additions
and
113 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ gem 'pg' | |
|
||
# Auth gems | ||
gem 'devise' | ||
gem 'cancan' | ||
|
||
# Server/transport gems | ||
gem 'thin' | ||
|
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 +1,2 @@ | ||
|
||
class Kandan.Collections.Users extends Backbone.Collection | ||
url: "users" |
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 Kandan.Helpers.Users | ||
@all: (options)-> | ||
$(document).data("users") | ||
|
||
@setFromCollection: (collection)-> | ||
$(document).data("users", collection.toJSON()) | ||
|
||
@currentUser: ()-> | ||
$.data(document, 'current-user') |
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class UsersController < ApplicationController | ||
before_filter :authenticate_user! | ||
before_filter :set_as_current_user_if_me, :only => :show | ||
load_and_authorize_resource | ||
|
||
def index | ||
respond_to do |format| | ||
format.json { render :json => @users } | ||
end | ||
end | ||
|
||
def show | ||
respond_to do |format| | ||
format.json { render :json => @user } | ||
end | ||
end | ||
|
||
private | ||
def set_as_current_user_if_me | ||
@user = current_user if params[:id] = 'me' | ||
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,26 @@ | ||
#============================================================================== | ||
# This file is part of Kandan. | ||
# https://github.com/kandanapp/kandan | ||
# | ||
# Kandan's code and assets are dual-licensed. Kandan is available | ||
# generally under the AGPL, and also under a custom license via | ||
# special agreement. See LICENSE for the AGPL terms, and contact us | ||
# at <admin@kandanapp.com> if you're interested in development of | ||
# Kandan under a custom license. | ||
#============================================================================== | ||
class Ability | ||
include CanCan::Ability | ||
|
||
def initialize(user) | ||
if user.is_admin | ||
can :manage, :all | ||
else | ||
can [:read, :create], Channel | ||
can :manage, Channel, :user => user | ||
can :manage, User, :id => user.id # can manage themselves | ||
end | ||
can :read, User | ||
# This goes last in order to override all other permissions. | ||
cannot :destroy, Channel, :id => 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
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,6 @@ | ||
class AddUserToChannels < ActiveRecord::Migration | ||
def change | ||
add_column :channels, :user_id, :integer | ||
add_index :channels, :user_id | ||
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
Oops, something went wrong.