Initial Commit

Co-authored-by: Subin <subinthattaparambil@gmail.com>
Co-authored-by: Manoj <manojmj92@gmail.com>
Co-authored-by: Nithin <webofnithin@gmail.com>
This commit is contained in:
Pranav Raj Sreepuram
2019-08-14 15:18:44 +05:30
commit 2a34255e0b
537 changed files with 27318 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
class ApplicationPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def index?
false
end
def show?
scope.where(:id => record.id).exists?
end
def create?
false
end
def new?
create?
end
def update?
false
end
def edit?
update?
end
def destroy?
false
end
def scope
Pundit.policy_scope!(user, record.class)
end
class Scope
attr_reader :user, :scope
def initialize(user, scope)
@user = user
@scope = scope
end
def resolve
scope
end
end
end

View File

@@ -0,0 +1,18 @@
class ContactPolicy < ApplicationPolicy
def index?
@user.administrator?
end
def update?
@user.administrator?
end
def show?
@user.administrator?
end
def create?
true
end
end

View File

@@ -0,0 +1,26 @@
class InboxPolicy < ApplicationPolicy
class Scope
attr_reader :user, :scope
def initialize(user, scope)
@user = user
@scope = scope
end
def resolve
if user.administrator?
scope.all
elsif user.agent?
user.assigned_inboxes
end
end
end
def index?
true
end
def destroy?
@user.administrator?
end
end

View File

@@ -0,0 +1,18 @@
class UserPolicy < ApplicationPolicy
def index?
true
end
def create?
@user.administrator?
end
def update?
@user.administrator?
end
def destroy?
@user.administrator?
end
end