Commit 5c02a6e47f22d9715a052c93e3028a9e161077ed
Exists in
master
and in
29 other branches
Merge branch 'ai2990' of https://gitlab.com/brauliobo/noosfero into brauliobo/noosfero-ai2990
Showing
1 changed file
with
13 additions
and
7 deletions
Show diff stats
app/models/theme.rb
| @@ -42,14 +42,20 @@ class Theme | @@ -42,14 +42,20 @@ class Theme | ||
| 42 | end | 42 | end |
| 43 | 43 | ||
| 44 | def approved_themes(owner) | 44 | def approved_themes(owner) |
| 45 | - Dir.glob(File.join(system_themes_dir, '*')).select do |item| | ||
| 46 | - if File.exists?( File.join(item, 'theme.yml') ) | ||
| 47 | - config = YAML.load_file(File.join(item, 'theme.yml')) | ||
| 48 | - (config['owner_type'] == owner.class.base_class.name) && | ||
| 49 | - (config['owner_id'] == owner.id) || config['public'] | 45 | + Dir.glob(File.join(system_themes_dir, '*')).map do |item| |
| 46 | + next unless File.exists? File.join(item, 'theme.yml') | ||
| 47 | + id = File.basename item | ||
| 48 | + config = YAML.load_file File.join(item, 'theme.yml') | ||
| 49 | + | ||
| 50 | + approved = config['public'] | ||
| 51 | + unless approved | ||
| 52 | + approved = config['owner_type'] == owner.class.base_class.name || config['owner_type'] == owner.class.name | ||
| 53 | + approved &&= config['owner_id'] == owner.id if config['owner_id'].present? | ||
| 50 | end | 54 | end |
| 51 | - end.map do |desc| | ||
| 52 | - new(File.basename(desc)) | 55 | + |
| 56 | + [id, config] if approved | ||
| 57 | + end.compact.map do |id, config| | ||
| 58 | + new id, config | ||
| 53 | end | 59 | end |
| 54 | end | 60 | end |
| 55 | 61 |