Class: DashboardController

Inherits:
ApplicationController show all
Defined in:
app/controllers/dashboard_controller.rb

Instance Method Summary collapse

Instance Method Details

#homeObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/dashboard_controller.rb', line 15

def home
  respond_to do |format|
    format.atom do
      if params[:api_key].present? && api_key = ApiKey.active.find_by_access_token(params[:api_key])
        @user = api_key.user
        @versions = @user.all_subscribed_versions.where.not(project_id: @user.muted_project_ids).where.not(published_at: nil).newest_first.includes(:project).paginate(per_page: 100, page: page_number)
      else
        raise ActiveRecord::RecordNotFound
      end
    end
    format.html do
      redirect_to root_path
    end
  end
end

#indexObject



4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/dashboard_controller.rb', line 4

def index
  @orgs = current_user.adminable_github_orgs.order(:login)
  @org = @orgs.find{|org| org. == params[:org] }
  @repos = current_user.adminable_github_repositories.order('fork ASC, pushed_at DESC').paginate(per_page: 30, page: page_number)
  if @org
    @repos = @repos.from_org(@org)
  else
    @repos =  @repos.from_org(nil)
  end
end

#mutedObject



31
32
33
# File 'app/controllers/dashboard_controller.rb', line 31

def muted
  @projects = current_user.muted_projects.paginate(page: page_number)
end

#syncObject



35
36
37
38
39
# File 'app/controllers/dashboard_controller.rb', line 35

def sync
  current_user.update_column(:currently_syncing, true)
  current_user.update_repo_permissions_async
  redirect_to_back_or_default repositories_path
end

#unwatchObject



51
52
53
54
55
# File 'app/controllers/dashboard_controller.rb', line 51

def unwatch
  github_repository = GithubRepository.find(params[:github_repository_id])
  current_user.unsubscribe_from_repo(github_repository)
  redirect_to_back_or_default repositories_path
end

#watchObject



41
42
43
44
45
46
47
48
49
# File 'app/controllers/dashboard_controller.rb', line 41

def watch
  github_repository = GithubRepository.find(params[:github_repository_id])
  if current_user.can_watch?(github_repository)
    current_user.subscribe_to_repo(github_repository)
    redirect_to_back_or_default repositories_path
  else
    redirect_to pricing_path, notice: 'You need to upgrade your plan to track more repositories'
  end
end