repository-manager 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +9 -12
- data/README.md +152 -115
- data/app/models/{app_file.rb → repo_file.rb} +3 -3
- data/app/models/repo_folder.rb +60 -0
- data/app/models/{repository.rb → repo_item.rb} +10 -10
- data/app/models/sharing.rb +58 -0
- data/app/models/sharings_member.rb +6 -0
- data/app/uploaders/{repository_uploader.rb → repo_file_uploader.rb} +1 -1
- data/db/migrate/20131018214212_create_repository_manager.rb +9 -17
- data/lib/generators/repository_manager/install_generator.rb +1 -3
- data/lib/generators/repository_manager/templates/initializer.rb +5 -10
- data/lib/repository-manager.rb +4 -4
- data/lib/repository_manager/engine.rb +0 -1
- data/lib/repository_manager/has_repository.rb +140 -129
- data/lib/repository_manager/version.rb +1 -1
- data/repository-manager.gemspec +4 -5
- data/spec/dummy/config/locales/en.yml +1 -8
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20131016193722_create_users.rb +11 -11
- data/spec/dummy/db/migrate/20131016193834_create_groups.rb +10 -10
- data/spec/dummy/db/migrate/20131016194207_create_groups_users.rb +5 -5
- data/spec/dummy/db/migrate/20131018214212_create_repository_manager.rb +9 -17
- data/spec/dummy/db/schema.rb +16 -16
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/factories/{app_file.rb → repo_file.rb} +1 -1
- data/spec/factories/{folder.rb → repo_folder.rb} +1 -1
- data/spec/has_repository_spec.rb +107 -107
- data/spec/models/associations_spec.rb +45 -45
- data/spec/models/repository_spec.rb +51 -27
- data/spec/models/share_spec.rb +39 -39
- metadata +15 -37
- data/app/models/folder.rb +0 -54
- data/app/models/share.rb +0 -58
- data/app/models/shares_item.rb +0 -10
- data/db/migrate/20131025085844_add_file_to_repositories.rb +0 -8
- data/db/migrate/20131025085845_add_file_to_files.rb +0 -5
- data/spec/dummy/db/migrate/20131025085844_add_file_to_repositories.rb +0 -8
- data/spec/dummy/db/migrate/20131025085845_add_file_to_files.rb +0 -5
@@ -1,19 +1,10 @@
|
|
1
1
|
class CreateRepositoryManager < ActiveRecord::Migration
|
2
2
|
|
3
3
|
def change
|
4
|
-
#create_table :permissions do |t|
|
5
|
-
# t.boolean :can_create, :default => false
|
6
|
-
# t.boolean :can_read, :default => false
|
7
|
-
# t.boolean :can_update, :default => false
|
8
|
-
# t.boolean :can_delete, :default => false
|
9
|
-
# t.boolean :can_share, :default => false
|
10
|
-
#end
|
11
4
|
|
12
|
-
create_table :
|
13
|
-
#t.integer :permission_id
|
14
|
-
#t.integer :user_id
|
5
|
+
create_table :sharings do |t|
|
15
6
|
t.references :owner, polymorphic: true
|
16
|
-
t.
|
7
|
+
t.references :repo_item
|
17
8
|
t.boolean :can_create, :default => false
|
18
9
|
t.boolean :can_read, :default => false
|
19
10
|
t.boolean :can_update, :default => false
|
@@ -21,19 +12,20 @@ class CreateRepositoryManager < ActiveRecord::Migration
|
|
21
12
|
t.boolean :can_share, :default => false
|
22
13
|
end
|
23
14
|
|
24
|
-
create_table :
|
25
|
-
t.
|
26
|
-
|
27
|
-
#t.integer :item_id
|
28
|
-
t.references :item, polymorphic: true
|
15
|
+
create_table :sharings_members do |t|
|
16
|
+
t.references :sharing
|
17
|
+
t.references :member, polymorphic: true
|
29
18
|
t.boolean :can_add, :default => false
|
30
19
|
t.boolean :can_remove, :default => false
|
31
20
|
end
|
32
21
|
|
33
|
-
create_table :
|
22
|
+
create_table :repo_items do |t|
|
34
23
|
t.references :owner, polymorphic: true
|
35
24
|
t.string :ancestry
|
36
25
|
t.string :name
|
26
|
+
t.float :file_size
|
27
|
+
t.string :content_type
|
28
|
+
t.string :file
|
37
29
|
t.string :type
|
38
30
|
end
|
39
31
|
end
|
@@ -23,9 +23,7 @@ module RepositoryManager #:nodoc:
|
|
23
23
|
#end
|
24
24
|
|
25
25
|
def copy_migrations
|
26
|
-
migrations = [["20131018214212_create_repository_manager.rb","create_repository_manager.rb"]
|
27
|
-
["20131025085844_add_file_to_repositories.rb","add_file_to_repositories.rb"],
|
28
|
-
["20131025085845_add_file_to_files", "add_file_to_files.rb"]
|
26
|
+
migrations = [["20131018214212_create_repository_manager.rb","create_repository_manager.rb"]
|
29
27
|
]
|
30
28
|
migrations.each do |migration|
|
31
29
|
migration_template "../../../../db/migrate/" + migration[0], "db/migrate/" + migration[1]
|
@@ -1,13 +1,8 @@
|
|
1
1
|
RepositoryManager.setup do |config|
|
2
2
|
|
3
|
-
# Default
|
4
|
-
config.
|
3
|
+
# Default repo_item permissions that an object has on the repo_item after a sharing.
|
4
|
+
config.default_repo_item_permissions = { can_read: true, can_create: false, can_update:false, can_delete:false, can_share: false }
|
5
5
|
|
6
|
-
# Default
|
7
|
-
config.
|
8
|
-
end
|
9
|
-
|
10
|
-
#Rails.application.configure do
|
11
|
-
# # Uncomment this to turn on verbose mode
|
12
|
-
# # config.my_gem.verbose = true
|
13
|
-
#end
|
6
|
+
# Default sharing permissions that an object has when he is added in a sharing.
|
7
|
+
config.default_sharing_permissions = { can_add: false, can_remove: false }
|
8
|
+
end
|
data/lib/repository-manager.rb
CHANGED
@@ -2,11 +2,11 @@ require 'repository_manager/has_repository'
|
|
2
2
|
|
3
3
|
module RepositoryManager
|
4
4
|
|
5
|
-
mattr_accessor :
|
6
|
-
@@
|
5
|
+
mattr_accessor :default_repo_item_permissions
|
6
|
+
@@default_repo_item_permissions = { can_read: true, can_create: false, can_update:false, can_delete:false, can_share: false }
|
7
7
|
|
8
|
-
mattr_accessor :
|
9
|
-
@@
|
8
|
+
mattr_accessor :default_sharing_permissions
|
9
|
+
@@default_sharing_permissions = { can_add: false, can_remove: false }
|
10
10
|
|
11
11
|
class << self
|
12
12
|
def setup
|
@@ -2,25 +2,22 @@ module RepositoryManager
|
|
2
2
|
module HasRepository
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
|
-
included do
|
6
|
-
end
|
7
|
-
|
8
5
|
module ClassMethods
|
9
6
|
def has_repository(options = {})
|
10
7
|
|
11
|
-
has_many :
|
12
|
-
has_many :
|
13
|
-
has_many :
|
8
|
+
has_many :sharings, through: :sharings_members
|
9
|
+
has_many :sharings_members, as: :member, dependent: :destroy
|
10
|
+
has_many :sharings_owners, as: :owner, class_name: 'Sharing'
|
14
11
|
|
15
|
-
# The own
|
16
|
-
has_many :
|
17
|
-
# The
|
18
|
-
has_many :
|
12
|
+
# The own repo_items
|
13
|
+
has_many :repo_items, as: :owner #, dependent: :destroy
|
14
|
+
# The sharing repo_items
|
15
|
+
has_many :shared_repo_items, through: :sharings, source: :repo_item, class_name: 'RepoItem'
|
19
16
|
|
20
|
-
#scope :
|
17
|
+
#scope :all_repo_items, -> { self.repo_items.shared_repo_items }
|
21
18
|
|
22
|
-
#All
|
23
|
-
#has_many :
|
19
|
+
#All repo_items (own and sharings)
|
20
|
+
#has_many :all_repo_items
|
24
21
|
|
25
22
|
include RepositoryManager::HasRepository::LocalInstanceMethods
|
26
23
|
end
|
@@ -28,44 +25,45 @@ module RepositoryManager
|
|
28
25
|
|
29
26
|
module LocalInstanceMethods
|
30
27
|
|
31
|
-
#
|
32
|
-
# options[:
|
33
|
-
# <tt>:can_read</tt> -
|
34
|
-
# <tt>:can_create</tt> -
|
35
|
-
# <tt>:can_edit</tt> -
|
36
|
-
# <tt>:can_delete</tt> -
|
37
|
-
# <tt>:can_share</tt> -
|
38
|
-
# options[:
|
39
|
-
# <tt>:can_add</tt> - Specify if the
|
40
|
-
# <tt>:can_remove</tt> - Specify if the
|
41
|
-
def share(
|
42
|
-
authorisations = get_authorisations(
|
43
|
-
|
44
|
-
# Here we look if the instance has the authorisation for making a
|
28
|
+
# Sharing the repo_item with the members, with the options
|
29
|
+
# options[:repo_item_permissions] contains :
|
30
|
+
# <tt>:can_read</tt> - Member can download the repo_item
|
31
|
+
# <tt>:can_create</tt> - Member can create a new repo_item on it
|
32
|
+
# <tt>:can_edit</tt> - Member can edit the repo_item
|
33
|
+
# <tt>:can_delete</tt> - Member can delete the repo_item
|
34
|
+
# <tt>:can_share</tt> - Member can share the repo_item
|
35
|
+
# options[:sharing_permissions] contains :
|
36
|
+
# <tt>:can_add</tt> - Specify if the member can add objects to the sharing
|
37
|
+
# <tt>:can_remove</tt> - Specify if the member can remove object to the sharing
|
38
|
+
def share(repo_item, members, options = nil)
|
39
|
+
authorisations = get_authorisations(repo_item)
|
40
|
+
|
41
|
+
# Here we look if the instance has the authorisation for making a sharing
|
45
42
|
if can_share?(nil, authorisations)
|
46
43
|
|
47
44
|
# We put the default options
|
48
|
-
|
49
|
-
|
45
|
+
repo_item_permissions = RepositoryManager.default_repo_item_permissions
|
46
|
+
sharing_permissions = RepositoryManager.default_sharing_permissions
|
50
47
|
|
51
48
|
# If there is options, we have to take it
|
52
49
|
if options
|
53
|
-
|
54
|
-
|
50
|
+
repo_item_permissions = options[:repo_item_permissions] if options[:repo_item_permissions]
|
51
|
+
sharing_permissions = options[:sharing_permissions] if options[:sharing_permissions]
|
55
52
|
end
|
56
53
|
|
57
|
-
|
54
|
+
repo_item_permissions = make_repo_item_permissions(repo_item_permissions, authorisations)
|
58
55
|
|
59
|
-
|
60
|
-
|
56
|
+
sharing = Sharing.new(repo_item_permissions)
|
57
|
+
sharing.owner = self
|
61
58
|
|
62
|
-
|
59
|
+
sharing.add_members(members, sharing_permissions)
|
63
60
|
|
64
|
-
|
65
|
-
|
66
|
-
|
61
|
+
repo_item.sharings << sharing
|
62
|
+
repo_item.save
|
63
|
+
sharing
|
67
64
|
else
|
68
|
-
# No permission => No
|
65
|
+
# No permission => No sharing
|
66
|
+
#raise "sharing failed. You don't have the permission to share the repo_item '#{repo_item.name}'"
|
69
67
|
false
|
70
68
|
end
|
71
69
|
end
|
@@ -77,57 +75,64 @@ module RepositoryManager
|
|
77
75
|
# If he want to create a folder in a directory, we have to check if he have the authorisation
|
78
76
|
if can_create?(source_folder)
|
79
77
|
|
80
|
-
folder =
|
78
|
+
folder = RepoFolder.new(name: name)
|
81
79
|
folder.owner = self
|
82
80
|
folder.save
|
83
81
|
|
84
|
-
#
|
85
|
-
if source_folder
|
86
|
-
|
82
|
+
# We have to look if it is ok to add the folder here
|
83
|
+
if source_folder == nil || source_folder.add(folder)
|
84
|
+
folder
|
85
|
+
else
|
86
|
+
# The add didn't works, we delete the folder
|
87
|
+
folder.destroy
|
88
|
+
#raise "create_folder failed. The folder '#{name}' already exist in folder '#{source_folder.name}'"
|
89
|
+
false
|
87
90
|
end
|
88
|
-
|
89
|
-
return folder
|
90
91
|
else
|
92
|
+
#raise "create_folder failed. You don't have the permission to create a folder in '#{source_folder.name}'"
|
91
93
|
return false
|
92
94
|
end
|
93
95
|
end
|
94
96
|
|
95
|
-
# Delete the
|
96
|
-
def
|
97
|
-
if can_delete?(
|
98
|
-
|
97
|
+
# Delete the repo_item
|
98
|
+
def delete_repo_item(repo_item)
|
99
|
+
if can_delete?(repo_item)
|
100
|
+
repo_item.destroy
|
99
101
|
else
|
102
|
+
#raise "delete_repo_item failed. You don't have the permission to delete the repo_item '#{repo_item.name}'"
|
100
103
|
return false
|
101
104
|
end
|
102
105
|
end
|
103
106
|
|
104
107
|
# Create the file (file) in the directory (source_folder)
|
105
|
-
# Param file can be a File, or a instance of
|
108
|
+
# Param file can be a File, or a instance of RepoFile
|
106
109
|
# Return the object of the file created if it is ok
|
107
110
|
# Return false if the file is not created (no authorisation)
|
108
111
|
def create_file(file, source_folder = nil)
|
109
112
|
# If he want to create a file in a directory, we have to check if he have the authorisation
|
110
113
|
if can_create?(source_folder)
|
111
114
|
if file.class.name == 'File'
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
elsif file.class.name == '
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
else
|
121
|
-
return false
|
115
|
+
repo_file = RepoFile.new
|
116
|
+
repo_file.file = file
|
117
|
+
repo_file.owner = self
|
118
|
+
repo_file.save
|
119
|
+
elsif file.class.name == 'RepoFile'
|
120
|
+
repo_file = file
|
121
|
+
repo_file.owner = self
|
122
|
+
repo_file.save
|
122
123
|
end
|
123
124
|
|
124
|
-
#
|
125
|
-
if source_folder
|
126
|
-
|
125
|
+
# We have to look if it is ok to add the file here
|
126
|
+
if source_folder == nil || source_folder.add(file)
|
127
|
+
return repo_file
|
128
|
+
else
|
129
|
+
# The add didn't works, we delete the file
|
130
|
+
file.destroy
|
131
|
+
#raise "create_file failed. The file '#{name}' already exist in folder '#{source_folder.name}'"
|
132
|
+
return false
|
127
133
|
end
|
128
|
-
|
129
|
-
return app_file
|
130
134
|
else
|
135
|
+
#raise "create_file failed. You don't have the permission to create a file in the folder '#{source_folder.name}'"
|
131
136
|
return false
|
132
137
|
end
|
133
138
|
end
|
@@ -136,25 +141,25 @@ module RepositoryManager
|
|
136
141
|
# Return false if the entity has not the authorisation to share this rep
|
137
142
|
# Return true if the entity can share this rep with all the authorisations
|
138
143
|
# Return an Array if the entity can share but with restriction
|
139
|
-
# Return true if the
|
140
|
-
def get_authorisations(
|
141
|
-
# If
|
142
|
-
return true if
|
144
|
+
# Return true if the repo_item is nil (he as all authorisations on his own rep)
|
145
|
+
def get_authorisations(repo_item = nil)
|
146
|
+
# If repo_item is nil, he can do what he want
|
147
|
+
return true if repo_item == nil
|
143
148
|
|
144
|
-
# If the
|
145
|
-
if
|
149
|
+
# If the member is the owner, he can do what he want !
|
150
|
+
if repo_item.owner == self
|
146
151
|
# You can do what ever you want :)
|
147
152
|
return true
|
148
|
-
# Find if a
|
149
|
-
elsif s = self.
|
150
|
-
# Ok, give an array with the permission of the actual
|
153
|
+
# Find if a sharing of this rep exist for the self instance
|
154
|
+
elsif s = self.sharings.where(repo_item_id: repo_item.id).first
|
155
|
+
# Ok, give an array with the permission of the actual sharing
|
151
156
|
# (we can't share with more permission then we have)
|
152
157
|
return {can_share: s.can_share, can_read: s.can_read, can_create: s.can_create, can_update: s.can_update, can_delete: s.can_delete}
|
153
158
|
else
|
154
|
-
# We look at the ancestor if there is a
|
155
|
-
ancestor_ids =
|
156
|
-
# Check the nearest
|
157
|
-
if s = self.
|
159
|
+
# We look at the ancestor if there is a sharing
|
160
|
+
ancestor_ids = repo_item.ancestor_ids
|
161
|
+
# Check the nearest sharing if it exist
|
162
|
+
if s = self.sharings.where(repo_item_id: ancestor_ids).last
|
158
163
|
return {can_share: s.can_share, can_read: s.can_read, can_create: s.can_create, can_update: s.can_update, can_delete: s.can_delete}
|
159
164
|
end
|
160
165
|
end
|
@@ -162,93 +167,96 @@ module RepositoryManager
|
|
162
167
|
return false
|
163
168
|
end
|
164
169
|
|
165
|
-
# Download a
|
170
|
+
# Download a repo_item if the object can_read it
|
166
171
|
# If it is a file, he download the file
|
167
|
-
# If it is a folder, we check witch
|
172
|
+
# If it is a folder, we check witch repo_item is in it, and witch he can_read
|
168
173
|
# We zip all the content that the object has access.
|
169
|
-
def download(
|
170
|
-
if can_download?(
|
171
|
-
|
174
|
+
def download(repo_item)
|
175
|
+
if can_download?(repo_item)
|
176
|
+
repo_item.download(self)
|
172
177
|
else
|
178
|
+
#raise "download failed. You don't have the permission to download the repo_item '#{repo_item.name}'"
|
173
179
|
false
|
174
180
|
end
|
175
181
|
end
|
176
182
|
|
177
|
-
#Return the authorisations of the
|
178
|
-
def
|
179
|
-
|
183
|
+
#Return the authorisations of the sharing (can_add, can_remove)
|
184
|
+
def get_sharing_authorisations(sharing)
|
185
|
+
sharing.get_authorisations(self)
|
180
186
|
end
|
181
187
|
|
182
188
|
# Return true if you can share the repo, else false
|
183
|
-
# You can give the authorisations or the
|
184
|
-
def can_share?(
|
185
|
-
can_do?('share',
|
189
|
+
# You can give the authorisations or the repo_item as params
|
190
|
+
def can_share?(repo_item, authorisations = nil)
|
191
|
+
can_do?('share', repo_item, authorisations)
|
186
192
|
end
|
187
193
|
|
188
194
|
# Return true if you can read the repo, else false
|
189
|
-
def can_read?(
|
190
|
-
can_do?('read',
|
195
|
+
def can_read?(repo_item, authorisations = nil)
|
196
|
+
can_do?('read', repo_item, authorisations)
|
191
197
|
end
|
192
198
|
|
193
199
|
# Return true if you can download the repo, else false
|
194
200
|
# Read = Download for the moment
|
195
|
-
def can_download?(
|
196
|
-
can_do?('read',
|
201
|
+
def can_download?(repo_item, authorisations = nil)
|
202
|
+
can_do?('read', repo_item, authorisations)
|
197
203
|
end
|
198
204
|
|
199
205
|
# Return true if you can create in the repo, false else
|
200
|
-
def can_create?(
|
201
|
-
can_do?('create',
|
206
|
+
def can_create?(repo_item, authorisations = nil)
|
207
|
+
can_do?('create', repo_item, authorisations)
|
202
208
|
end
|
203
209
|
|
204
210
|
# Return true if you can edit the repo, false else
|
205
|
-
def can_update?(
|
206
|
-
can_do?('update',
|
211
|
+
def can_update?(repo_item, authorisations = nil)
|
212
|
+
can_do?('update', repo_item, authorisations)
|
207
213
|
end
|
208
214
|
|
209
215
|
# Return true if you can delete the repo, false else
|
210
|
-
def can_delete?(
|
211
|
-
can_do?('delete',
|
216
|
+
def can_delete?(repo_item, authorisations = nil)
|
217
|
+
can_do?('delete', repo_item, authorisations)
|
212
218
|
end
|
213
219
|
|
214
|
-
# Return true if you can add
|
215
|
-
def can_add_to?(
|
216
|
-
can_do_to?('add',
|
220
|
+
# Return true if you can add a member in this sharing, false else
|
221
|
+
def can_add_to?(sharing)
|
222
|
+
can_do_to?('add', sharing)
|
217
223
|
end
|
218
224
|
|
219
|
-
# Return true if you can remove
|
220
|
-
def can_remove_from?(
|
221
|
-
can_do_to?('remove',
|
225
|
+
# Return true if you can remove a member in this sharing, false else
|
226
|
+
def can_remove_from?(sharing)
|
227
|
+
can_do_to?('remove', sharing)
|
222
228
|
end
|
223
229
|
|
224
|
-
# You can here add new
|
225
|
-
# Param
|
226
|
-
def
|
227
|
-
authorisations =
|
228
|
-
if can_add_to?(
|
229
|
-
|
230
|
-
|
230
|
+
# You can here add new members in the sharing
|
231
|
+
# Param member could be an object or an array of object
|
232
|
+
def add_members_to(sharing, members, options = nil)
|
233
|
+
authorisations = get_sharing_authorisations(sharing)
|
234
|
+
if can_add_to?(sharing)
|
235
|
+
sharing_permissions = make_sharing_permissions(options, authorisations)
|
236
|
+
sharing.add_members(members, sharing_permissions)
|
231
237
|
else
|
238
|
+
#raise "add members failed. You don't have the permission to add a member in this sharing"
|
232
239
|
return false
|
233
240
|
end
|
234
241
|
end
|
235
242
|
|
236
|
-
# You can here add new
|
237
|
-
# Param
|
238
|
-
def
|
239
|
-
if can_remove_from?(
|
240
|
-
|
243
|
+
# You can here add new members in the sharing
|
244
|
+
# Param member could be an object or an array of object
|
245
|
+
def remove_members_from(sharing, members)
|
246
|
+
if can_remove_from?(sharing)
|
247
|
+
sharing.remove_members(members)
|
241
248
|
else
|
249
|
+
#raise "remove members failed. You don't have the permission to remove a member on this sharing"
|
242
250
|
return false
|
243
251
|
end
|
244
252
|
end
|
245
253
|
|
246
254
|
private
|
247
255
|
|
248
|
-
# Return if you can do or not this action in the
|
249
|
-
def can_do_to?(what,
|
256
|
+
# Return if you can do or not this action in the sharing
|
257
|
+
def can_do_to?(what, sharing, authorisations = nil)
|
250
258
|
if authorisations == nil
|
251
|
-
authorisations =
|
259
|
+
authorisations = sharing.get_authorisations(self)
|
252
260
|
end
|
253
261
|
case what
|
254
262
|
when 'add'
|
@@ -259,10 +267,10 @@ module RepositoryManager
|
|
259
267
|
end
|
260
268
|
|
261
269
|
# Return if you can do or not this action (what)
|
262
|
-
def can_do?(what,
|
270
|
+
def can_do?(what, repo_item, authorisations = nil)
|
263
271
|
#If we pass no authorisations we have to get it
|
264
272
|
if authorisations === nil
|
265
|
-
authorisations = get_authorisations(
|
273
|
+
authorisations = get_authorisations(repo_item)
|
266
274
|
end
|
267
275
|
|
268
276
|
case what
|
@@ -282,12 +290,12 @@ module RepositoryManager
|
|
282
290
|
|
283
291
|
end
|
284
292
|
|
285
|
-
# Correct the
|
286
|
-
def
|
293
|
+
# Correct the repo_item_permissions with the authorisations
|
294
|
+
def make_repo_item_permissions(wanted_permissions, authorisations)
|
287
295
|
# If it is an array, we have restriction in the permissions
|
288
296
|
if authorisations.kind_of?(Hash) && wanted_permissions
|
289
|
-
# Built the
|
290
|
-
# We remove the permission if we can't
|
297
|
+
# Built the sharing with the accepted permissions
|
298
|
+
# We remove the permission if we can't sharing it
|
291
299
|
if wanted_permissions[:can_read] == true && authorisations[:can_read] == false
|
292
300
|
wanted_permissions[:can_read] = false
|
293
301
|
end
|
@@ -300,15 +308,18 @@ module RepositoryManager
|
|
300
308
|
if wanted_permissions[:can_delete] == true && authorisations[:can_delete] == false
|
301
309
|
wanted_permissions[:can_delete] = false
|
302
310
|
end
|
311
|
+
if wanted_permissions[:can_share] == true && authorisations[:can_share] == false
|
312
|
+
wanted_permissions[:can_share] = false
|
313
|
+
end
|
303
314
|
end
|
304
315
|
return wanted_permissions
|
305
316
|
end
|
306
317
|
|
307
|
-
# Correct the
|
308
|
-
def
|
318
|
+
# Correct the sharing_permissions with the authorisations
|
319
|
+
def make_sharing_permissions(wanted_permissions, authorisations)
|
309
320
|
# If it is an array, we have restriction in the permissions
|
310
321
|
if authorisations.kind_of?(Hash) && wanted_permissions
|
311
|
-
# Built the
|
322
|
+
# Built the sharing with the accepted permissions
|
312
323
|
# We remove the permission if we can't share it
|
313
324
|
if wanted_permissions[:can_add] == true && authorisations[:can_add] == false
|
314
325
|
wanted_permissions[:can_add] = false
|
data/repository-manager.gemspec
CHANGED
@@ -10,9 +10,9 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.authors = ['Yves Baumann']
|
11
11
|
s.email = ['texicitys@gmail.com']
|
12
12
|
s.homepage = 'https://github.com/Texicitys/repository-manager'
|
13
|
-
s.summary = "Ruby on Rails plugin (gem) for managing repositories (files/folders/permissions/
|
14
|
-
s.description = "This project is based on the need for a repository manager system for Collaide. A system for easily create/delete files and folders in a repository. For
|
15
|
-
Each instance (users, groups, etc..) can have it own repositories (with files and folders). It can manage them easily (edit, remove, add, etc) and
|
13
|
+
s.summary = "Ruby on Rails plugin (gem) for managing repositories (files/folders/permissions/sharings)."
|
14
|
+
s.description = "This project is based on the need for a repository manager system for Collaide. A system for easily create/delete files and folders in a repository. For sharing these repositories easily with other object with a flexible and complete authorisations management.
|
15
|
+
Each instance (users, groups, etc..) can have it own repositories (with files and folders). It can manage them easily (edit, remove, add, etc) and sharing them with other instance."
|
16
16
|
|
17
17
|
#s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
|
18
18
|
s.files = `git ls-files`.split("\n")
|
@@ -27,6 +27,5 @@ Each instance (users, groups, etc..) can have it own repositories (with files an
|
|
27
27
|
s.add_development_dependency 'rspec-rails', '~> 2.0'
|
28
28
|
s.add_runtime_dependency 'ancestry'
|
29
29
|
s.add_runtime_dependency 'carrierwave'
|
30
|
-
s.add_runtime_dependency '
|
31
|
-
s.add_runtime_dependency 'rubyzip'
|
30
|
+
s.add_runtime_dependency 'rubyzip'#, '< 1.0.0'#, :require => 'zip/zip'
|
32
31
|
end
|
@@ -1,11 +1,4 @@
|
|
1
|
-
|
2
|
-
enumerize:
|
3
|
-
repository:
|
4
|
-
type:
|
5
|
-
file: "File"
|
6
|
-
directory: "Directory"
|
7
|
-
|
8
|
-
# Files in the config/locales directory are used for internationalization
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
9
2
|
# and are automatically loaded by Rails. If you want to use locales other
|
10
3
|
# than English, add the necessary files in this directory.
|
11
4
|
#
|
Binary file
|
@@ -1,11 +1,11 @@
|
|
1
|
-
class CreateUsers < ActiveRecord::Migration
|
2
|
-
def change
|
3
|
-
create_table :users do |t|
|
4
|
-
t.string :nickname
|
5
|
-
t.string :password
|
6
|
-
t.string :email
|
7
|
-
|
8
|
-
t.timestamps
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
1
|
+
class CreateUsers < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :users do |t|
|
4
|
+
t.string :nickname
|
5
|
+
t.string :password
|
6
|
+
t.string :email
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
class CreateGroups < ActiveRecord::Migration
|
2
|
-
def change
|
3
|
-
create_table :groups do |t|
|
4
|
-
t.string :name
|
5
|
-
t.text :description
|
6
|
-
|
7
|
-
t.timestamps
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
1
|
+
class CreateGroups < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :groups do |t|
|
4
|
+
t.string :name
|
5
|
+
t.text :description
|
6
|
+
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
class CreateGroupsUsers < ActiveRecord::Migration
|
2
|
-
def change
|
3
|
-
create_join_table :groups, :users
|
4
|
-
end
|
5
|
-
end
|
1
|
+
class CreateGroupsUsers < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_join_table :groups, :users
|
4
|
+
end
|
5
|
+
end
|