application_controller.rb 552 Bytes
Newer Older
Valery Sizov's avatar
Valery Sizov committed
1
class Groups::ApplicationController < ApplicationController
Douwe Maan's avatar
Douwe Maan committed
2
  before_action :set_title
Valery Sizov's avatar
Valery Sizov committed
3
4
5

  private
  
6
7
8
9
10
11
12
13
14
15
  def authorize_read_group!
    unless @group and can?(current_user, :read_group, @group)
      if current_user.nil?
        return authenticate_user!
      else
        return render_404
      end
    end
  end
  
Valery Sizov's avatar
Valery Sizov committed
16
  def authorize_admin_group!
17
    unless can?(current_user, :admin_group, group)
Valery Sizov's avatar
Valery Sizov committed
18
19
20
      return render_404
    end
  end
21

Douwe Maan's avatar
Douwe Maan committed
22
23
24
25
  def set_title
    @title      = group.name
    @title_url  = group_path(group)
    @sidebar    = "group"
26
  end
Valery Sizov's avatar
Valery Sizov committed
27
end