1 class PublicationsController < ApplicationController
4 # before_filter :authorize, :only => [:issues]
7 @publications = Publication.all
10 format.xml { render :xml => @publications }
11 format.json { render :json => @publications }
16 regexp = Regexp.new(Setting.plugin_redmine_publications[:pattern])
17 repo = Repository.find(:first, :conditions => ['project_id = ?', Setting.plugin_redmine_publications[:project]] )
19 Rails.logger.info('[INFO] Importing changes from ' << repo.url)
20 Rails.logger.info('[INFO] Change list: ' << repo.changes.find(:all).inspect )
23 repo.changes.find(:all).each do |change|
24 Rails.logger.info('[INFO] Importing change ' << change.path)
25 match = change.path.match(regexp)
27 Publication.find_or_create_by_name(:name => match[1],
28 :source_file => change.path, :repository_id => repo.id)
29 @repo_status += [{:path => change.path, :match => match[1], :matched => true}]
31 @repo_status += [{:path => change.path, :match => nil, :matched => false}]
35 respond_to do |format|
37 format.xml { render :xml => @repo_status}
38 format.json { render :json => @repo_status }
43 @publication = Publication.find_by_name(params[:pub])
45 joins = "JOIN issue_publications ON (issues.id = issue_publications.issue_id)"
46 conditions = ['issue_publications.publication_id = ? ', @publication.id ]
47 @issues = Issue.all(:joins => joins, :conditions => conditions)
50 fmt.json { render :json => @issues, :callback => params[:callback] }
57 @project = Project.find(params[:project_id])