diff -r 839ade185c761e3d9e224021fe352c38b7e89eb0 -r b16f77b940b56ff283a298e5d127bfa50d5b1f59 indefero/src/IDF/Form/ProjectRequest.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/indefero/src/IDF/Form/ProjectRequest.php Tue Jul 30 19:50:05 2013 -0500 @@ -0,0 +1,72 @@ + __('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; + } + } + +} \ No newline at end of file diff -r 839ade185c761e3d9e224021fe352c38b7e89eb0 -r b16f77b940b56ff283a298e5d127bfa50d5b1f59 indefero/src/IDF/ProjectRequest.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/indefero/src/IDF/ProjectRequest.php Tue Jul 30 19:50:05 2013 -0500 @@ -0,0 +1,85 @@ +_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'); + } + + } +} \ No newline at end of file diff -r 839ade185c761e3d9e224021fe352c38b7e89eb0 -r b16f77b940b56ff283a298e5d127bfa50d5b1f59 indefero/src/IDF/templates/idf/admin/approveprojects.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/indefero/src/IDF/templates/idf/admin/approveprojects.html Tue Jul 30 19:50:05 2013 -0500 @@ -0,0 +1,60 @@ +{extends "idf/gadmin/base.html"} +{block request} class="active"{/block} + +{block body} +{if $createdtext} +{$createdtext} +
+
+{/if} +{if $errors} +{foreach $errors as $error} +{$error} +{/foreach} +{/if} + + + + + + + + + +{foreach $requests as $req} + + + + + + + + +{/foreach} +
+ Short Name + + Description + + Repotype + + Submitter + + Date + + Approve +
+ {$req.shortname} + + {$req.desc} + + {$req.repotype} + + {$req.get_submitter.login} + + {$req.creation_dtime} + + Approve +
+ +{/block} \ No newline at end of file diff -r 839ade185c761e3d9e224021fe352c38b7e89eb0 -r b16f77b940b56ff283a298e5d127bfa50d5b1f59 indefero/src/IDF/templates/idf/admin/request-email.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/indefero/src/IDF/templates/idf/admin/request-email.txt Tue Jul 30 19:50:05 2013 -0500 @@ -0,0 +1,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. + diff -r 839ade185c761e3d9e224021fe352c38b7e89eb0 -r b16f77b940b56ff283a298e5d127bfa50d5b1f59 indefero/src/IDF/templates/idf/user/projectrequest.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/indefero/src/IDF/templates/idf/user/projectrequest.html Tue Jul 30 19:50:05 2013 -0500 @@ -0,0 +1,60 @@ +{extends "idf/base-simple.html"} +{block body} + +{if $form.errors} +
+

{trans 'Oops, please check the errors on the form.'}

+ {if $form.get_top_errors} + {$form.render_top_errors|unsafe} + {/if} +
+{/if} +{if $success} +
+

+ Thank you - your request has been received and will be approved by an admin shortly. +

+
+{/if} +{if $error} +
+{$error} +
+{/if} + +
+ + + + + + + + + + + + + + + + + +
{$form.f.shortname.labelTag}:{if $form.f.shortname.errors}{$form.f.shortname.fieldErrors}{/if} + {$form.f.shortname|unsafe}
+ {$form.f.shortname.help_text} +
{$form.f.repotype.labelTag}:{if $form.f.repotype.errors}{$form.f.repotype.fieldErrors}{/if} + {$form.f.repotype|unsafe}
+ {$form.f.repotype.help_text} +
{$form.f.desc.labelTag}:{if $form.f.desc.errors}{$form.f.desc.fieldErrors}{/if} + {$form.f.desc|unsafe}
+ {$form.f.desc.help_text} +
 
+ +
+ +{/block} +{block context} + + +{/block} \ No newline at end of file