2

我检查了 IRC 的 redmine 并且无法获得帮助。我在天气上很矛盾,不能把它贴在 Superuser、ServerFault 或这里,但由于我的问题是面向技术编程的,我决定在这里寻求帮助。

我们有一个 Mercurial 存储库系统,其布局基于满足我们需求的项目。我编写了一些 shell 脚本,它们可以很好地管理存储库并将它们放在正确的位置等。我正在尝试调用这些脚本并从 Redmine 向它们传递参数。我正在编辑 app/controllers/projects_controller.rb(第 75 -> 87 行)

我已经设法提取了项目参数和当前用户,但是我添加了两个自定义字段(使用 Redmine Administration 中的自定义字段)并且我正在尝试访问这些自定义字段的值。有谁知道我怎么能得到这些?

我目前的工作测试声明如下:

 system "echo '#{@project.identifier}, #{User.current}' >> /tmp/rm.log"
4

2 回答 2

3

使用 CustomField 模型。例如,

  # Find the first Custom Field
  cf = CustomField.first
  # Get the name
  puts cf.name
  # Find out if this Custom Field is for all projects
  cf.is_for_all?
  # If not, find out which projects are using it
  cf.projects

为了解决这个问题,我刚刚安装了 Redmine-1.0.0 并在源代码和脚本/控制台中四处寻找。

于 2010-07-19T01:59:49.817 回答
1
use DBI;

$dbServer='';
$user='';
$pass='';
$ident=$ARGV[0];

my $dsn = "dbi:mysql:database=redmine;host=$dbServer;port=3306";
my $dbh = DBI->connect($dsn, "$user","$pass") or die "Can't connet to the Database: $DBI::errstr\n";
my $sth = $dbh->prepare("SELECT value FROM custom_values c INNER JOIN projects p ON c.customized_id=p.id WHERE p.identifier='$ident' LIMIT 1");
$sth -> execute();
my @row=$sth->fetchrow_array();
my $serverParams=@row[0];

Calling the above script (instead of echoing in the original), and then passing in the project identifier which we already have, the custom parameter can be used in whatever way nessacary. This code it to grab a single custom field (i was only using one.)

于 2010-07-19T18:59:04.573 回答