From: Gustavo Martin Morcuende Date: Sun, 13 May 2012 16:51:11 +0000 (+0200) Subject: First module: office X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=6ceca099aea83677b918d6cdddf953a66c9ffbaa;p=mobi%2F.git First module: office Getting ready: layout, i18n I have to write a new form for this module which will let us create a new office. Right now without javascript, but if I want it to seem "professional" I will have to finish using javascript... --- diff --git a/apps/companyfront/config/app.yml b/apps/companyfront/config/app.yml index f88da69..5b598b9 100644 --- a/apps/companyfront/config/app.yml +++ b/apps/companyfront/config/app.yml @@ -2,4 +2,14 @@ # http://www.symfony-project.org/reference/1_4/en/11-App # default values -#all: +all: + max_jobs_on_category: 3 + + sf_guard_plugin: + remember_key_expiration_age: 2592000 # 30 days in seconds + remember_cookie_name: mobicomRemember # used by sfGuardSecurityUser.class.php + success_signin_url: @homepage # the plugin uses the referer as default + success_signout_url: @sf_guard_signin # used by BasesfGuardAuthActions.class.php. After logout we are redirected to this page + signin_url_path: login # used by sfGuardRememberMeFilter.class.php. The Remember cookie must not be used when using the login page + remember_cookie_path: /companyfront.php # used by sfGuardSecurityUser.class.php. The scope of the Remeber cookie + diff --git a/apps/companyfront/config/routing.yml b/apps/companyfront/config/routing.yml index 4f466dd..746237e 100644 --- a/apps/companyfront/config/routing.yml +++ b/apps/companyfront/config/routing.yml @@ -6,6 +6,12 @@ homepage: url: / param: { module: default, action: index } +office_index: + url: /office/index + class: sfDoctrineRoute + param: { module: office, action: index } + options: { model: Office, type: object } + # generic rules # please, remove them by adding more specific rules default_index: diff --git a/apps/companyfront/config/view.yml b/apps/companyfront/config/view.yml index 407733d..5db0828 100644 --- a/apps/companyfront/config/view.yml +++ b/apps/companyfront/config/view.yml @@ -12,9 +12,9 @@ default: #language: en #robots: index, follow - stylesheets: [main.css] + stylesheets: [inadminpanel/style.css, inadminpanel/niceforms-default.css, jquery.treeTable.css] - javascripts: [] + javascripts: [jquery-1.6.2.min.js, jquery.treeTable.js, inadminpanel/ddaccordion.js] has_layout: true layout: layout diff --git a/apps/companyfront/modules/office/actions/actions.class.php b/apps/companyfront/modules/office/actions/actions.class.php new file mode 100644 index 0000000..ce035a7 --- /dev/null +++ b/apps/companyfront/modules/office/actions/actions.class.php @@ -0,0 +1,79 @@ +offices = Doctrine_Core::getTable('Office') + ->createQuery('a') + ->execute(); + } + + public function executeShow(sfWebRequest $request) + { + $this->office = Doctrine_Core::getTable('Office')->find(array($request->getParameter('id'))); + $this->forward404Unless($this->office); + } + + public function executeNew(sfWebRequest $request) + { + $this->form = new OfficeForm(); + } + + public function executeCreate(sfWebRequest $request) + { + $this->forward404Unless($request->isMethod(sfRequest::POST)); + + $this->form = new OfficeForm(); + + $this->processForm($request, $this->form); + + $this->setTemplate('new'); + } + + public function executeEdit(sfWebRequest $request) + { + $this->forward404Unless($office = Doctrine_Core::getTable('Office')->find(array($request->getParameter('id'))), sprintf('Object office does not exist (%s).', $request->getParameter('id'))); + $this->form = new OfficeForm($office); + } + + public function executeUpdate(sfWebRequest $request) + { + $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT)); + $this->forward404Unless($office = Doctrine_Core::getTable('Office')->find(array($request->getParameter('id'))), sprintf('Object office does not exist (%s).', $request->getParameter('id'))); + $this->form = new OfficeForm($office); + + $this->processForm($request, $this->form); + + $this->setTemplate('edit'); + } + + public function executeDelete(sfWebRequest $request) + { + $request->checkCSRFProtection(); + + $this->forward404Unless($office = Doctrine_Core::getTable('Office')->find(array($request->getParameter('id'))), sprintf('Object office does not exist (%s).', $request->getParameter('id'))); + $office->delete(); + + $this->redirect('office/index'); + } + + protected function processForm(sfWebRequest $request, sfForm $form) + { + $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); + if ($form->isValid()) + { + $office = $form->save(); + + $this->redirect('office/edit?id='.$office->getId()); + } + } +} diff --git a/apps/companyfront/modules/office/i18n/office_form.es.xml b/apps/companyfront/modules/office/i18n/office_form.es.xml new file mode 100644 index 0000000..7cbdd30 --- /dev/null +++ b/apps/companyfront/modules/office/i18n/office_form.es.xml @@ -0,0 +1,67 @@ + + + + + + Company Administrator User Id: + Id del Usuario Administrador de Empresa: + + + Company Id: + Id de la Empresa: + + + Longitude (180 to -180): + Longitud (180 a -180): + + + Latitude (90 to -90): + Latitud (90 a -90): + + + Address: + Direccion: + + + Wrong Longitude + Longitud erronea + + + The longitude field is required + Se requiere el campo longitud + + + Longitude "%value%" must not exceed the %max% value + La longitud "%value%" no debe exceder el valor %max% + + + Longitude "%value%" must be equal or higher than %min% + La longitud "%value%" debe ser igual o mayor que %min% + + + Wrong Latitude + Latitud erronea + + + The latitude field is required + Se requiere el campo latitud + + + Latitude "%value%" must not exceed the %max% value + La latitud "%value%" no debe exceder el valor %max% + + + Latitude "%value%" must be equal or higher than %min% + La latitud "%value%" debe ser igual o mayor que %min% + + + Invalid address field + Campo calle erroneo + + + Address "%value%" must have %max_length% characters or less + La direccion "%value%" debe tener %max_length% characters o menos + + + + diff --git a/apps/companyfront/modules/office/templates/_form.php b/apps/companyfront/modules/office/templates/_form.php new file mode 100644 index 0000000..0792e22 --- /dev/null +++ b/apps/companyfront/modules/office/templates/_form.php @@ -0,0 +1,74 @@ + + + +
isMultipart() and print 'enctype="multipart/form-data" ' ?>> +getObject()->isNew()): ?> + + + + + + + + + + renderGlobalErrors() ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ renderHiddenFields(false) ?> +  Back to list + getObject()->isNew()): ?> +  getObject()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?> + + +
renderLabel() ?> + renderError() ?> + +
renderLabel() ?> + renderError() ?> + +
renderLabel() ?> + renderError() ?> + +
renderLabel() ?> + renderError() ?> + +
renderLabel() ?> + renderError() ?> + +
renderLabel() ?> + renderError() ?> + +
renderLabel() ?> + renderError() ?> + +
+
diff --git a/apps/companyfront/modules/office/templates/editSuccess.php b/apps/companyfront/modules/office/templates/editSuccess.php new file mode 100644 index 0000000..8e1c570 --- /dev/null +++ b/apps/companyfront/modules/office/templates/editSuccess.php @@ -0,0 +1,3 @@ +

Edit Office

+ + $form)) ?> diff --git a/apps/companyfront/modules/office/templates/indexSuccess.php b/apps/companyfront/modules/office/templates/indexSuccess.php new file mode 100644 index 0000000..a2b7a2d --- /dev/null +++ b/apps/companyfront/modules/office/templates/indexSuccess.php @@ -0,0 +1,32 @@ +

Offices List

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdCompanyCityOffice gpsOffice street addressOffice zipCreated atUpdated at
getId() ?>getCompanyId() ?>getCityId() ?>getOfficeGps() ?>getOfficeStreetAddress() ?>getOfficeZip() ?>getCreatedAt() ?>getUpdatedAt() ?>
+ + New diff --git a/apps/companyfront/modules/office/templates/newSuccess.php b/apps/companyfront/modules/office/templates/newSuccess.php new file mode 100644 index 0000000..9113985 --- /dev/null +++ b/apps/companyfront/modules/office/templates/newSuccess.php @@ -0,0 +1,3 @@ +

New Office

+ + $form)) ?> diff --git a/apps/companyfront/modules/office/templates/showSuccess.php b/apps/companyfront/modules/office/templates/showSuccess.php new file mode 100644 index 0000000..637f502 --- /dev/null +++ b/apps/companyfront/modules/office/templates/showSuccess.php @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id:getId() ?>
Company:getCompanyId() ?>
City:getCityId() ?>
Office gps:getOfficeGps() ?>
Office street address:getOfficeStreetAddress() ?>
Office zip:getOfficeZip() ?>
Created at:getCreatedAt() ?>
Updated at:getUpdatedAt() ?>
+ +
+ +Edit +  +List diff --git a/apps/companyfront/templates/layout.php b/apps/companyfront/templates/layout.php index b37659b..9302c0e 100644 --- a/apps/companyfront/templates/layout.php +++ b/apps/companyfront/templates/layout.php @@ -3,12 +3,123 @@ - + + Mobi - Mobile Ads + + - +
+
+ +
Welcome Admin | Logout
+
+
+ +
+ + +
+ + + +
+
+
+
+ + +
diff --git a/test/functional/companyfront/officeActionsTest.php b/test/functional/companyfront/officeActionsTest.php new file mode 100644 index 0000000..c9bc6fe --- /dev/null +++ b/test/functional/companyfront/officeActionsTest.php @@ -0,0 +1,19 @@ + + get('/office/index')-> + + with('request')->begin()-> + isParameter('module', 'office')-> + isParameter('action', 'index')-> + end()-> + + with('response')->begin()-> + isStatusCode(200)-> + checkElement('body', '!/This is a temporary page/')-> + end() +; diff --git a/web/companyfront.php b/web/companyfront.php new file mode 100644 index 0000000..55c54b7 --- /dev/null +++ b/web/companyfront.php @@ -0,0 +1,6 @@ +dispatch();