srchub

srchub Commit Details


Date:2013-07-30 19:50:05 (11 years 4 months ago)
Author:Natalie Adams
Branch:master
Commit:2f981e42e5307f4bad045149eb28a6fa5248bd8d
Parents: f62d20f0d19785335546010e2e0d312c1ee6e258
Message:Adding projectrequest files

Changes:

File differences

indefero/src/IDF/Form/ProjectRequest.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
<?php
class IDF_Form_ProjectRequest extends Pluf_Form
{
public $user = null;
public function initFields($extra=array())
{
$choices = array();
$options = array(
'git' => __('git'),
'svn' => __('Subversion'),
'mercurial' => __('mercurial'),
'mtn' => __('monotone'),
);
foreach (Pluf::f('allowed_scm', array()) as $key => $class) {
$choices[$options[$key]] = $key;
}
$this->fields['shortname'] = new Pluf_Form_Field_Varchar(
array('required' => true,
'label' => __('Name'),
'initial' => '',
'help_text' => __('This will be the name of your repo and of your project - however - you can change the project name later.'),
));
$this->fields['repotype'] = new Pluf_Form_Field_Varchar(
array('required' => true,
'label' => __('Repository type'),
'initial' => 'git',
'widget_attrs' => array('choices' => $choices),
'widget' => 'Pluf_Form_Widget_SelectInput',
));
$this->fields['desc'] = new Pluf_Form_Field_Varchar(
array('required' => true,
'label' => __('Short description'),
'help_text' => __('A one line description of the project.'),
'initial' => '',
'widget_attrs' => array('size' => '35'),
));
$this->user = $extra['user'];
}
function save($commit=true)
{
if (!$this->isValid()) {
throw new Exception(__('Cannot save the model from an invalid form.'));
}
$checksql = new Pluf_SQL(sprintf("shortname='%s'", $this->cleaned_data['shortname']));
$requestcheck = Pluf::factory("IDF_Project")->getCount(array('filter'=>$checksql->gen()));
if ($requestcheck == 1)
return false;
try
{
$request = new IDF_ProjectRequest();
$request->shortname = $this->cleaned_data['shortname'];
$request->repotype = $this->cleaned_data['repotype'];
$request->desc = $this->cleaned_data['desc'];
$request->submitter = $this->user;
$request->create();
return true;
} catch (Exception $e)
{
return false;
}
}
}
indefero/src/IDF/ProjectRequest.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
<?php
/*
* This is the model for people to request a repo
* An administrator can then approve/deny the repo
*
*
*/
class IDF_ProjectRequest extends Pluf_Model
{
public $_model = __CLASS__;
function init()
{
$this->_a['table'] = 'idf_projectrequest';
$this->_a['model'] = __CLASS__;
$this->_a['cols'] = array(
// It is mandatory to have an "id" column.
'id' =>
array(
'type' => 'Pluf_DB_Field_Sequence',
'blank' => true,
),
'shortname' =>
array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => false,
'size' => 50,
'verbose' => __('shortname'),
'unique' => true,
),
'repotype' =>
array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => false,
'size' => 25,
'verbose' => __('Repository Type'),
),
'desc' =>
array(
'type' => 'Pluf_DB_Field_Varchar',
'blank' => false,
'size' => 250,
'verbose' => __('Description'),
),
'creation_dtime' =>
array(
'type' => 'Pluf_DB_Field_Datetime',
'blank' => true,
'verbose' => __('creation date'),
),
'submitter' =>
array(
'type' => 'Pluf_DB_Field_Foreignkey',
'model' => 'Pluf_User',
'blank' => false,
'verbose' => __('submitter'),
));
}
/**
* String representation of the abstract.
*/
function __toString()
{
return $this->shortname;
}
/**
* String ready for indexation.
*/
function _toIndex()
{
return '';
}
function preSave($create=false)
{
if ($this->id == '') {
$this->creation_dtime = gmdate('Y-m-d H:i:s');
}
}
}
indefero/src/IDF/templates/idf/admin/approveprojects.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
53
54
55
56
57
58
59
60
{extends "idf/gadmin/base.html"}
{block request} class="active"{/block}
{block body}
{if $createdtext}
{$createdtext}
<br/>
<br/>
{/if}
{if $errors}
{foreach $errors as $error}
{$error}
{/foreach}
{/if}
<table>
<tr>
<th>
Short Name
</th>
<th>
Description
</th>
<th>
Repotype
</th>
<th>
Submitter
</th>
<th>
Date
</th>
<th>
Approve
</th>
</tr>
{foreach $requests as $req}
<tr>
<td>
{$req.shortname}
</td>
<td>
{$req.desc}
</td>
<td>
{$req.repotype}
</td>
<td>
{$req.get_submitter.login}
</td>
<td>
{$req.creation_dtime}
</td>
<td>
<a href="{url 'IDF_Views_Admin::projectRequestCreate'}{$req.id}/">Approve</a>
</td>
</tr>
{/foreach}
</table>
{/block}
indefero/src/IDF/templates/idf/admin/request-email.txt
1
2
3
4
5
6
7
8
9
10
Hello {$user},
You are receiving this email because you have requested a repository.
Your request for {$shortname|safe} was approved!
If you have any questions please feel free to email a member of the development team.
Yours faithfully,
The development team.
indefero/src/IDF/templates/idf/user/projectrequest.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
53
54
55
56
57
58
59
60
{extends "idf/base-simple.html"}
{block body}
{if $form.errors}
<div class="px-message-error">
<p>{trans 'Oops, please check the errors on the form.'}</p>
{if $form.get_top_errors}
{$form.render_top_errors|unsafe}
{/if}
</div>
{/if}
{if $success}
<div>
<p>
Thank you - your request has been received and will be approved by an admin shortly.
</p>
</div>
{/if}
{if $error}
<div class="px-message-error">
{$error}
</div>
{/if}
<form method="post" action=".">
<table class="form" summary="">
<tr>
<th><strong>{$form.f.shortname.labelTag}:</strong></th>
<td>{if $form.f.shortname.errors}{$form.f.shortname.fieldErrors}{/if}
{$form.f.shortname|unsafe}<br />
<span class="helptext">{$form.f.shortname.help_text}</span>
</td>
</tr>
<tr>
<th><strong>{$form.f.repotype.labelTag}:</strong></th>
<td>{if $form.f.repotype.errors}{$form.f.repotype.fieldErrors}{/if}
{$form.f.repotype|unsafe}<br />
<span class="helptext">{$form.f.repotype.help_text}</span>
</td>
</tr>
<tr>
<th><strong>{$form.f.desc.labelTag}:</strong></th>
<td>{if $form.f.desc.errors}{$form.f.desc.fieldErrors}{/if}
{$form.f.desc|unsafe}<br />
<span class="helptext">{$form.f.desc.help_text}</span>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" value="Request Project" name="submit" /></td>
</tr>
</table>
</form>
{/block}
{block context}
{/block}

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.08408s using 14 queries.