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 Publication.delete_all()
19 repo = Repository.find(:first, :conditions => ['project_id = ?', Setting.plugin_redmine_publications[:project]] )
21 Rails.logger.info('[INFO] Importing changes from ' << repo.url)
22 Rails.logger.info('[INFO] Change list: ' << repo.changes.find(:all).inspect )
25 repo.changes.find(:all).each do |change|
26 Rails.logger.info('[INFO] Importing change ' << change.path)
27 match = change.path.match(regexp)
29 Publication.find_or_create_by_name(:name => match[1],
30 :source_file => change.path, :repository_id => repo.id)
31 @repo_status += [{:path => change.path, :match => match[1], :matched => true}]
33 @repo_status += [{:path => change.path, :match => nil, :matched => false}]
37 respond_to do |format|
39 format.xml { render :xml => @repo_status}
40 format.json { render :json => @repo_status }
45 @publication = Publication.find_by_name(params[:pub])
47 joins = "JOIN issue_publications ON (issues.id = issue_publications.issue_id)"
48 conditions = ['issue_publications.publication_id = ? ', @publication.id ]
49 @issues = Issue.all(:joins => joins, :conditions => conditions)
52 fmt.json { render :json => @issues, :callback => params[:callback] }
59 @project = Project.find(params[:project_id])