homeland-wiki 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8efe19f3119e5867c24bc768eb200e44fedcd984
4
- data.tar.gz: 94f9232944ad2e7f08a25de1faf0b4b677111444
3
+ metadata.gz: 33c85fe4edab99469bbd84cb946d85b3769a87d1
4
+ data.tar.gz: ef6028d5cddedb8320de340163defb3b1c23f56c
5
5
  SHA512:
6
- metadata.gz: ab76466efa368b108ba4f8d96d41bf48ceb6cafaa2b9f32971f4d9dc89283663a7bcfda852462756cd01ed47ef3bb75da1f7a431b1ee9d00742053239c49465d
7
- data.tar.gz: '087f335fd8666bba63cfeabd7e823f70f9eeab58b647f719a5b659bd2be3aca8dd6d5dd09184317f018b3d3a3e461f09b827dcc86924ffe1b03b64dc00db8daf'
6
+ metadata.gz: d6a81401716122682d49dd9de3664005bcb632c395f0b94ef46013a59298eca944209521f9566b48976a41f5b258fafb7570c8432c9be83ea935a78531ff7a00
7
+ data.tar.gz: 725e9074db67ce09237f681ebc846f2eab2a2e2ddfa2ebf06a0700c14d3064ef264d1569094c5be80dc30ec2169268204179a0a2b8eb86968e7d7e651f183934
@@ -1,5 +1,9 @@
1
1
  module Homeland::Wiki
2
2
  class ApplicationController < ::ApplicationController
3
3
  helper ApplicationHelper
4
+
5
+ def current_ability
6
+ @current_ability ||= Homeland::Wiki::Ability.new(current_user)
7
+ end
4
8
  end
5
9
  end
@@ -1,7 +1,6 @@
1
1
  module Homeland::Wiki
2
2
  class PagesController < Homeland::Wiki::ApplicationController
3
3
  require_module_enabled! :wiki
4
- authorize_resource :page
5
4
  before_action :set_page, only: [:show, :edit, :update, :destroy, :comments]
6
5
 
7
6
  etag { Setting.wiki_sidebar_html }
@@ -35,6 +34,8 @@ module Homeland::Wiki
35
34
  end
36
35
 
37
36
  def new
37
+ authorize! :create, Page
38
+
38
39
  @page = Page.new
39
40
  @page.slug = params[:title]
40
41
  respond_to do |format|
@@ -44,9 +45,12 @@ module Homeland::Wiki
44
45
  end
45
46
 
46
47
  def edit
48
+ authorize! :edit, @page
47
49
  end
48
50
 
49
51
  def create
52
+ authorize! :create, Page
53
+
50
54
  @page = Page.new(page_params)
51
55
  @page.user_id = current_user.id
52
56
  @page.version_enable = true
@@ -59,6 +63,8 @@ module Homeland::Wiki
59
63
  end
60
64
 
61
65
  def update
66
+ authorize! :update, @page
67
+
62
68
  @page.version_enable = true
63
69
  @page.user_id = current_user.id
64
70
 
@@ -6,15 +6,21 @@ module Homeland::Wiki
6
6
 
7
7
  def initialize(u)
8
8
  @user = u
9
- return roles_for_create_wiki if @user.present? && (@user.roles?(:admin) || @user.roles?(:wiki_editor))
10
- roles_for_anonymous
9
+ if @user.blank?
10
+ roles_for_anonymous
11
+ elsif @user.roles?(:admin)
12
+ can :manage, Page
13
+ elsif @user.roles?(:wiki_editor)
14
+ roles_for_wiki_editor
15
+ else
16
+ roles_for_anonymous
17
+ end
11
18
  end
12
19
 
13
20
  protected
14
21
 
15
- def roles_for_create_wiki
22
+ def roles_for_wiki_editor
16
23
  can :create, Page
17
- can :edit, Page, locked: false
18
24
  can :update, Page, locked: false
19
25
  end
20
26
 
@@ -2,6 +2,6 @@ module Homeland
2
2
  module Wiki
3
3
  NAME = 'wiki'
4
4
  DESCRIPTION = 'Display Wiki channel in navbar for wike pages.'
5
- VERSION = '0.2.0'
5
+ VERSION = '0.2.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: homeland-wiki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Griffin Qiu