Indefero

Indefero Commit Details


Date:2010-08-11 06:58:41 (14 years 4 months ago)
Author:Loïc d'Anterroches
Branch: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:4f23ea4dd5d69012498b86c3dd0fdfeacf44e51e
Parents: 061c8065880a1294666aee3f90ada67b383bf2c0
Message:Added the ability to create a new project with another one as template.

Changes:

File differences

src/IDF/Form/Admin/ProjectCreate.php
109109
110110
111111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
112126
113127
114128
......
229243
230244
231245
246
247
248
249
250
251
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
232280
233
234
281
282
283
284
285
286
287
288
235289
236290
237291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
238307
239308
240309
'cols' => 40),
'widget' => 'Pluf_Form_Widget_TextareaInput',
));
$projects = array('--' => '--');
foreach (Pluf::factory('IDF_Project')->getList(array('order' => 'name ASC')) as $proj) {
$projects[$proj->name] = $proj->shortname;
}
$this->fields['template'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => __('Project template'),
'initial' => '--',
'help_text' => __('Use the given project to initialize the new project. Access rights and general configuration will be taken from the template project.'),
'widget' => 'Pluf_Form_Widget_SelectInput',
'widget_attrs' => array('choices' => $projects),
));
/**
* [signal]
*
$this->cleaned_data[$key] : '';
$conf->setVal($key, $this->cleaned_data[$key]);
}
if ($this->cleaned_data['template'] != '--') {
// Find the template project
$sql = new Pluf_SQL('shortname=%s',
array($this->cleaned_data['template']));
$tmpl = Pluf::factory('IDF_Project')->getOne(array('filter' => $sql->gen()));
$tmplconf = new IDF_Conf();
$tmplconf->setProject($tmpl);
// We need to get all the configuration variables we want from
// the old project and put them into the new project.
$props = array(
'labels_download_predefined',
'labels_download_one_max',
'labels_wiki_predefined',
'labels_wiki_one_max',
'labels_issue_open',
'labels_issue_closed',
'labels_issue_predefined',
'labels_issue_one_max',
'webhook_url',
'downloads_access_rights',
'review_access_rights',
'wiki_access_rights',
'source_access_rights',
'issues_access_rights',
'downloads_notification_email',
'review_notification_email',
'wiki_notification_email',
'source_notification_email',
'issues_notification_email',
);
foreach ($props as $prop) {
$conf->setVal($prop, $tmplconf->getVal($prop));
}
}
$project->created();
IDF_Form_MembersConf::updateMemberships($project,
$this->cleaned_data);
if ($this->cleaned_data['template'] == '--') {
IDF_Form_MembersConf::updateMemberships($project,
$this->cleaned_data);
} else {
// Get the membership of the template $tmpl
IDF_Form_MembersConf::updateMemberships($project,
$tmpl->getMembershipData('string'));
}
$project->membershipsUpdated();
return $project;
}
/**
* Check that the template project exists.
*/
public function clean_template()
{
if ($this->cleaned_data['template'] == '--') {
return $this->cleaned_data['template'];
}
$sql = new Pluf_SQL('shortname=%s', array($this->cleaned_data['template']));
if (Pluf::factory('IDF_Project')->getOne(array('filter' => $sql->gen())) == null) {
throw new Pluf_Form_Invalid(__('This project is not available.'));
}
return $this->cleaned_data['template'];
}
}
src/IDF/Views/Admin.php
118118
119119
120120
121
122
123
121124
122125
123126
/**
* Creation of a project.
*
* A project can use another project as template. In that case,
* everything but the data in the input at creation time is
* reused, including the wiki pages.
*/
public $projectCreate_precond = array('Pluf_Precondition::staffRequired');
public function projectCreate($request, $match)
src/IDF/templates/idf/gadmin/projects/create.html
5353
5454
5555
56
57
58
59
60
61
62
5663
5764
5865
5966
60
67
6168
6269
63
70
6471
6572
6673
6774
6875
6976
70
77
7178
7279
7380
......
119126
120127
121128
129
130
131
132
133
134
135
136
137
138
139
140
141
122142
123143
124144
125
126
127
128
129
130
131
132
133
134
135
136
</td>
</tr>
<tr>
<th>{$form.f.template.labelTag}</th>
<td>{if $form.f.template.errors}{$form.f.template.fieldErrors}{/if}
{$form.f.template|unsafe}<br />
<span class="helptext">{$form.f.template.help_text}</span>
</td>
</tr>
<tr class="no-template">
<th><strong>{$form.f.owners.labelTag}:</strong></th>
<td>
{if $form.f.owners.errors}{$form.f.owners.fieldErrors}{/if}
{$form.f.owners|unsafe}<br />
<span class="helptext">{trans 'Provide at least one owner for the project.'}</span>
<span class="helptext">{trans 'Provide at least one owner for the project or use a template.'}</span>
</td>
</tr>
<tr>
<tr class="no-template">
<th>{$form.f.members.labelTag}:</th>
<td>
{if $form.f.members.errors}{$form.f.members.fieldErrors}{/if}
{$form.f.members|unsafe}
</td>
</tr>
<tr>
<tr class="no-template">
<th>{if $form.f.private_project.errors}{$form.f.private_project.fieldErrors}{/if}
{$form.f.private_project|unsafe}
</th>
$(".svn-form").hide();
}
});
// Hide if not svn
if ($("#id_template option:selected").val() == "--") {
$(".no-template").show();
} else {
$(".no-template").hide();
}
$("#id_template").change(function () {
if ($("#id_template option:selected").val() == "--") {
$(".no-template").show();
} else {
$(".no-template").hide();
}
});
});
</script>
{/literal}{/block}
{*
$("select").change(function () {
var str = "";
$("select option:selected").each(function () {
str += $(this).text() + " ";
});
$("div").text(str);
})
.trigger('change');
*}

Archive Download the corresponding diff file

Page rendered in 0.08962s using 13 queries.