Indefero

Indefero Commit Details


Date:2008-09-02 09:45:49 (16 years 3 months ago)
Author:Loic d'Anterroches
Branch:dev, develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3
Commit:3a3aa9c7303321dadcc11fc9b0150b0fbb31447d
Parents: 2d271f6b69de881074ce4feb6bea64af1ed82eba
Message:Added the administration of the repository.

It is now possible to select the repository type and a possible remote
repository for subversion in the administration area.
Changes:

File differences

src/IDF/Form/SourceConf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008 CĂ©ondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
/**
* Configuration of the source.
*/
class IDF_Form_SourceConf extends Pluf_Form
{
public $conf = null;
public function initFields($extra=array())
{
$this->conf = $extra['conf'];
$this->fields['scm'] = new Pluf_Form_Field_Varchar(
array('required' => true,
'label' => __('Repository type'),
'initial' => $this->conf->getVal('scm', 'git'),
'widget_attrs' => array('choices' =>
array(
__('git') => 'git',
__('Subversion') => 'svn',
)
),
'widget' => 'Pluf_Form_Widget_SelectInput',
));
$this->fields['svn_remote_url'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => __('Remote Subversion repository'),
'initial' => $this->conf->getVal('svn_remote_url', ''),
'widget_attrs' => array('size' => '30'),
));
$this->fields['svn_username'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => __('Repository username'),
'initial' => $this->conf->getVal('svn_username', ''),
'widget_attrs' => array('size' => '15'),
));
$this->fields['svn_password'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => __('Repository password'),
'initial' => $this->conf->getVal('svn_password', ''),
'widget' => 'Pluf_Form_Widget_PasswordInput',
));
}
public function clean_svn_remote_url()
{
$url = trim($this->cleaned_data['svn_remote_url']);
if (strlen($url) == 0) return $url;
// we accept only starting with http(s):// to avoid people
// trying to access the local filesystem.
if (!preg_match('#^(http|https)://#', $url)) {
throw new Pluf_Form_Invalid(__('Only a remote repository available throught http or https are allowed. For example "http://somewhere.com/sv/trunk.'));
}
return $url;
}
public function clean()
{
if ($this->cleaned_data['scm'] == 'git') {
foreach (array('svn_remote_url', 'svn_username', 'svn_password')
as $key) {
$this->cleaned_data[$key] = '';
}
}
return $this->cleaned_data;
}
}
src/IDF/Views/Project.php
249249
250250
251251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
252297
),
$request);
}
/**
* Administrate the source control.
*/
public $adminSource_precond = array('IDF_Precondition::projectOwner');
public function adminSource($request, $match)
{
$prj = $request->project;
$title = sprintf(__('%s Source'), (string) $prj);
$extra = array(
'conf' => $request->conf,
);
if ($request->method == 'POST') {
$form = new IDF_Form_SourceConf($request->POST, $extra);
if ($form->isValid()) {
foreach ($form->cleaned_data as $key=>$val) {
$request->conf->setVal($key, $val);
}
$request->user->setMessage(__('The project source configuration has been saved.'));
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Project::adminSource',
array($prj->shortname));
return new Pluf_HTTP_Response_Redirect($url);
}
} else {
$params = array();
$keys = array('scm', 'svn_remote_url',
'svn_username', 'svn_password');
foreach ($keys as $key) {
$_val = $request->conf->getVal($key, false);
if ($_val !== false) {
$params[$key] = $_val;
}
}
if (count($params) == 0) {
$params = null; //Nothing in the db, so new form.
}
$form = new IDF_Form_SourceConf($params, $extra);
}
return Pluf_Shortcuts_RenderToResponse('admin/source.html',
array(
'page_title' => $title,
'form' => $form,
),
$request);
}
}
src/IDF/conf/views.php
242242
243243
244244
245
246
247
248
249
250
245251
246252
247253
'model' => 'IDF_Views_Project',
'method' => 'adminDownloads');
$ctl[] = array('regex' => '#^/p/(\w+)/admin/source/$#',
'base' => $base,
'priority' => 4,
'model' => 'IDF_Views_Project',
'method' => 'adminSource');
$ctl[] = array('regex' => '#^/p/(\w+)/admin/members/$#',
'base' => $base,
'priority' => 4,
src/IDF/templates/admin/base.html
33
44
55
6
76
87
8
9
910
1011
1112
{block subtabs}
<div id="sub-tabs">
<a {if $inSummary}class="active" {/if}href="{url 'IDF_Views_Project::admin', array($project.shortname)}">{trans 'Project Summary'}</a> |
<a {if $inMembers}class="active" {/if}href="{url 'IDF_Views_Project::adminMembers', array($project.shortname)}">{trans 'Project Members'}</a> |
<a {if $inIssueTracking}class="active" {/if}href="{url 'IDF_Views_Project::adminIssues', array($project.shortname)}">{trans 'Issue Tracking'}</a> |
<a {if $inDownloads}class="active" {/if}href="{url 'IDF_Views_Project::adminDownloads', array($project.shortname)}">{trans 'Downloads'}</a> |
<a {if $inSource}class="active" {/if}href="{url 'IDF_Views_Project::adminSource', array($project.shortname)}">{trans 'Source'}</a> |
<a {if $inMembers}class="active" {/if}href="{url 'IDF_Views_Project::adminMembers', array($project.shortname)}">{trans 'Project Members'}</a> |
<a {if $inTabs}class="active" {/if}href="{url 'IDF_Views_Project::adminTabs', array($project.shortname)}">{trans 'Tabs Access'}</a>
</div>
{/block}
src/IDF/templates/admin/source.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{extends "admin/base.html"}
{block docclass}yui-t1{assign $inSource = true}{/block}
{block body}
{if $form.errors}
<div class="px-message-error">
<p>{trans 'The form contains some errors. Please correct them to update the source configuration.'}</p>
{if $form.get_top_errors}
{$form.render_top_errors|unsafe}
{/if}
</div>
{/if}
<form method="post" action=".">
<table class="form" summary="">
<tr>
<th><strong>{$form.f.scm.labelTag}:</strong></th>
<td>{if $form.f.scm.errors}{$form.f.scm.fieldErrors}{/if}
{$form.f.scm|unsafe}
</td>
</tr>
<tr>
<th>{$form.f.svn_remote_url.labelTag}:</th>
<td>{if $form.f.svn_remote_url.errors}{$form.f.svn_remote_url.fieldErrors}{/if}
{$form.f.svn_remote_url|unsafe}
</td>
</tr>
<tr>
<th>{$form.f.svn_username.labelTag}:</th>
<td>{if $form.f.svn_username.errors}{$form.f.svn_username.fieldErrors}{/if}
{$form.f.svn_username|unsafe}
</td>
</tr>
<tr>
<th>{$form.f.svn_password.labelTag}:</th>
<td>{if $form.f.svn_password.errors}{$form.f.svn_password.fieldErrors}{/if}
{$form.f.svn_password|unsafe}
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="submit" value="{trans 'Save Changes'}" name="submit" />
</td>
</tr>
</table>
</form>
{/block}
{block context}
<div class="issue-submit-info">
<p><strong>{trans 'Instructions:'}</strong></p>
<p>{blocktrans}You can select the type of repository you want. In the case of subversion, you can use optionally a remote repository instead of the local one.{/blocktrans}</p>
</div>
{/block}

Archive Download the corresponding diff file

Page rendered in 0.09424s using 13 queries.