Changeset 68
- Timestamp:
- 07/14/08 09:25:04 (2 years ago)
- Files:
-
- trunk/apps/main/config/routing.yml (modified) (1 diff)
- trunk/apps/main/modules/applications/actions/actions.class.php (modified) (8 diffs)
- trunk/apps/main/modules/applications/templates/connectAsDeveloperSuccess.php (modified) (3 diffs)
- trunk/data/migrations/005_m1.php (added)
- trunk/lib/form/ActivationForm.class.php (copied) (copied from trunk/lib/form/user/ActivationForm.class.php)
- trunk/lib/form/ApplicationCompanyForm.class.php (copied) (copied from trunk/lib/form/application/ApplicationCompanyForm.class.php)
- trunk/lib/form/ApplicationDeveloperForm.class.php (copied) (copied from trunk/lib/form/application/ApplicationDeveloperForm.class.php) (1 diff)
- trunk/lib/form/ApplicationForm.class.php (copied) (copied from trunk/lib/form/application/ApplicationForm.class.php) (2 diffs)
- trunk/lib/form/BlogPostForm.class.php (copied) (copied from trunk/lib/form/blog/BlogPostForm.class.php)
- trunk/lib/form/CompanyForm.class.php (copied) (copied from trunk/lib/form/company/CompanyForm.class.php)
- trunk/lib/form/CompanyPersonForm.class.php (copied) (copied from trunk/lib/form/company/CompanyPersonForm.class.php)
- trunk/lib/form/CountrySelectorForm.class.php (copied) (copied from trunk/lib/form/l10n/CountrySelectorForm.class.php)
- trunk/lib/form/EventForm.class.php (copied) (copied from trunk/lib/form/event/EventForm.class.php)
- trunk/lib/form/JobForm.class.php (copied) (copied from trunk/lib/form/job/JobForm.class.php)
- trunk/lib/form/LocalEventForm.class.php (copied) (copied from trunk/lib/form/localEvent/LocalEventForm.class.php)
- trunk/lib/form/RecommendationForm.class.php (copied) (copied from trunk/lib/form/user/RecommendationForm.class.php)
- trunk/lib/form/RegisterForm.class.php (copied) (copied from trunk/lib/form/user/RegisterForm.class.php)
- trunk/lib/form/ResendActivationForm.class.php (copied) (copied from trunk/lib/form/user/ResendActivationForm.class.php)
- trunk/lib/form/SigninForm.class.php (copied) (copied from trunk/lib/form/user/SigninForm.class.php)
- trunk/lib/form/application (deleted)
- trunk/lib/form/blog (deleted)
- trunk/lib/form/company (deleted)
- trunk/lib/form/event (deleted)
- trunk/lib/form/job (deleted)
- trunk/lib/form/l10n (deleted)
- trunk/lib/form/localEvent (deleted)
- trunk/lib/form/user (deleted)
- trunk/lib/utils/sfValidatedThumb.class.php (added)
- trunk/plugins (modified) (1 prop)
- trunk/test/functional/main/applicationsActionsTest.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/apps/main/config/routing.yml
r50 r68 120 120 application_add: 121 121 url: /application/add 122 param: { module: applications, action: add}122 param: { module: applications, action: edit } 123 123 124 124 application_edit: trunk/apps/main/modules/applications/actions/actions.class.php
r66 r68 9 9 { 10 10 11 public function executeAdd(sfWebRequest $request)12 {13 $this->forward('applications', 'edit');14 }15 16 11 public function executeCountries(sfWebRequest $request) 17 12 { … … 21 16 public function executeEdit(sfWebRequest $request) 22 17 { 23 $creation = false; 24 25 if (!$application = $this->getFromSlug()) 18 if (!is_null($request->getParameter('slug'))) 19 { 20 $application = $this->getFromSlug(); 21 22 $this->forward404If(is_null($application), sprintf('App with slug "%s" not found', $request->getParameter('slug'))); 23 24 if (!$this->getUser()->isAdmin() && $application->getSubmitterId() != $this->getUser()->getId()) 25 { 26 $this->getUser()->setFlash('warning', $this->__('You are not allowed to edit this record')); 27 $this->redirect('@application_page?slug='.$application->getSlug()); 28 } 29 30 $this->setTemplate('edit'); 31 $message = $this->__('Application updated'); 32 $redirect = '@application_page?slug=%s'; 33 $creation = false; 34 } 35 else 26 36 { 27 37 $application = new Application(); 38 $this->setTemplate('add'); 39 $message = $this->__('Application added'); 40 $redirect = '@application_connect_as_developer?slug=%s'; 28 41 $creation = true; 29 $this->setTemplate('add');30 }31 32 if (!$creation && !$this->getUser()->isAdmin() && $application->getSubmitterId() != $this->getUser()->getId())33 {34 $this->getUser()->setFlash('warning', $this->__('You are not allowed to edit this record'));35 $this->redirect('@application_page?slug='.$application->getSlug());36 42 } 37 43 … … 53 59 } 54 60 61 /* @var $application Application */ 55 62 $application = $this->form->getObject(); 56 63 57 // Process uploaded image file 58 $this->processUploadedImage($this->form->getValue('screenshot_path'), $application); 64 /* @var $thumb sfValidatedThumb */ 65 $thumb = $this->form->getValue('screenshot_path'); 66 $thumb->makeThumb( 67 sfConfig::get('app_applications_screenshot_width', 200), 68 sfConfig::get('app_applications_screenshot_height', 140), 69 sfConfig::get('app_applications_screenshot_mime', 'image/jpeg'), 70 sfConfig::get('app_applications_screenshot_quality', 90) 71 ); 72 $thumb_name = md5($application->getName()).'.jpg'; 73 $thumb->save(sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . 74 sfConfig::get('app_applications_upload_dir', 'applications') . DIRECTORY_SEPARATOR . 75 $thumb_name); 76 77 $application->setScreenshotPath($thumb_name); 78 $application->save(); 59 79 60 80 parent::purgeObjectRelatedCache($application); 61 81 62 if (isset($creation) && true === $creation)63 {64 $message = $this->__('Application added');65 $redirect = '@application_connect_as_developer?slug='.$application->getSlug();66 }67 else68 {69 $message = $this->__('Application updated');70 $redirect = '@application_page?slug='.$application->getSlug();71 }72 73 82 $this->getUser()->setFlash('notice', $message); 74 $this->getUser()->setAttribute('from_app_creation', $creation, 'symfonians');75 $this->redirect( $redirect);83 $this->getUser()->setAttribute('from_app_creation', is_null($request->getParameter('slug')), 'symfonians'); 84 $this->redirect(sprintf($redirect, $application->getSlug())); 76 85 } 77 86 } … … 102 111 $this->connection = ApplicationDeveloperPeer::retrieveByPK($this->getRequestParameter('id')); 103 112 $this->forward404Unless($this->connection, 'ApplicationDeveloper not found'); 113 $this->form = new ApplicationDeveloperForm($this->connection); 104 114 105 115 if ($request->isMethod('post')) … … 147 157 $this->connection = new ApplicationDeveloper(); 148 158 $this->application = $this->getFromSlug(); 159 $this->form = new ApplicationDeveloperForm($this->connection); 149 160 150 161 // Checks if a relation already exists for this person … … 162 173 if ($request->isMethod('post')) 163 174 { 164 $this->updateDeveloperConnectionFromRequest(); 165 parent::purgeObjectRelatedCache($this->connection); 166 167 $this->getUser()->setFlash('notice', $this->__('You have been marked as implied with this application')); 168 $this->redirect('@application_page?slug='.$this->application->getSlug()); 175 $params = array_merge($request->getParameter('connection'), 176 array('application_id' => $this->application->getId(), 177 'developer_id' => $this->getUser()->getId())); 178 $this->form->bind($params); 179 if ($this->form->isValid()) 180 { 181 $this->form->save(); 182 parent::purgeObjectRelatedCache($this->connection); 183 $this->getUser()->setFlash('notice', $this->__('You have been marked as implied with this application')); 184 $this->redirect('@application_page?slug='.$this->application->getSlug()); 185 } 169 186 } 170 187 … … 312 329 } 313 330 314 public function handleErrorEdit()315 {316 $this->application = $this->getFromSlug();317 return sfView::SUCCESS;318 }319 320 public function handleErrorEditCompanyConnection()321 {322 $this->application = $this->getFromSlug();323 $this->connection = ApplicationCompanyPeer::retrieveByPK($this->getRequestParameter('id'));324 $this->forward404Unless($this->connection, 'ApplicationCompany not found');325 $this->form_action = sprintf('@application_edit_company_connection?slug=%s&id=%d',326 $this->application->getSlug(),327 $this->connection->getId());328 $this->setTemplate('connectAsCompany');329 return sfView::SUCCESS;330 }331 332 public function handleErrorEditDeveloperConnection()333 {334 $this->application = $this->getFromSlug();335 $this->connection = ApplicationDeveloperPeer::retrieveByPK($this->getRequestParameter('id'));336 $this->forward404Unless($this->connection, 'ApplicationDeveloper not found');337 $this->form_action = sprintf('@application_edit_developer_connection?slug=%s&id=%d',338 $this->application->getSlug(),339 $this->connection->getId());340 $this->setTemplate('connectAsDeveloper');341 return sfView::SUCCESS;342 }343 344 331 /** 345 332 * Process uploaded image file and updates passed Application object with the … … 373 360 } 374 361 375 public function handleErrorConnectAsCompany()376 {377 $this->connection = new ApplicationCompany();378 $this->application = $this->getFromSlug();379 $this->form_action = sprintf('@application_connect_as_company?slug=%s',380 $this->application->getSlug());381 return sfView::SUCCESS;382 }383 384 public function handleErrorConnectAsDeveloper()385 {386 $this->connection = new ApplicationDeveloper();387 $this->application = $this->getFromSlug();388 $this->form_action = sprintf('@application_connect_as_developer?slug=%s',389 $this->application->getSlug());390 return sfView::SUCCESS;391 }392 393 protected function updateCompanyConnectionFromRequest()394 {395 $connection_data = $this->getRequestParameter('connection', array());396 397 if (isset($connection_data['started_at']) && $connection_data['started_at'] == '')398 {399 unset($connection_data['started_at']);400 }401 if (isset($connection_data['ended_at']) && $connection_data['ended_at'] == '')402 {403 unset($connection_data['ended_at']);404 }405 406 try407 {408 $this->connection->fromArray($connection_data, BasePeer::TYPE_FIELDNAME);409 $this->connection->setApplication($this->application);410 $this->connection->setSubmitterId($this->getUser()->getId());411 $this->connection->save();412 }413 catch (Exception $e)414 {415 $this->getRequest()->setError('errors', $this->__('Unable to save this relation'));416 sfContext::getInstance()->getLogger()->err('Blocking error at ApplicationCompany save time: '.$e->getMessage());417 }418 }419 420 protected function updateDeveloperConnectionFromRequest()421 {422 $connection_data = $this->getRequestParameter('connection', array());423 424 if (isset($connection_data['started_at']) && $connection_data['started_at'] == '')425 {426 unset($connection_data['started_at']);427 }428 if (isset($connection_data['ended_at']) && $connection_data['ended_at'] == '')429 {430 unset($connection_data['ended_at']);431 }432 433 try434 {435 $this->connection->fromArray($connection_data, BasePeer::TYPE_FIELDNAME);436 $this->connection->setDeveloperId($this->getUser()->getId());437 $this->connection->setApplication($this->application);438 $this->connection->save();439 }440 catch (Exception $e)441 {442 $this->getRequest()->setError('errors', $this->__('Unable to save this relation'));443 sfContext::getInstance()->getLogger()->err('Blocking error at ApplicationDeveloper save time: '.$e->getMessage());444 }445 }446 447 362 } trunk/apps/main/modules/applications/templates/connectAsDeveloperSuccess.php
r50 r68 41 41 <legend><?php echo __('Connection informations') ?></legend> 42 42 <div class="form-row required"> 43 < label for="role"><?php echo __('Your role in this project') ?></label>44 <?php echo object_input_tag($connection, 'getRole', 'name=connection[role]', $sf_params->get('connection[role]')) ?>45 <?php echo form_error('connection[role]') ?>43 <?php echo $form['role']->renderLabel(__('Your role in this project')) ?> 44 <?php echo $form['role']->render() ?> 45 <?php echo $form['role']->renderError() ?> 46 46 </div> 47 47 <div class="form-row"> 48 < label for="description"><?php echo __('Description of your work') ?></label>49 <?php echo object_textarea_tag($connection, 'getDescription', 'name=connection[description]', $sf_params->get('connection[description]')) ?>50 <?php echo form_error('connection[description]') ?>48 <?php echo $form['description']->renderLabel(__('Description of your work')) ?> 49 <?php echo $form['description']->render() ?> 50 <?php echo $form['description']->renderError() ?> 51 51 </div> 52 52 </fieldset> … … 55 55 <fieldset> 56 56 <legend><?php echo __('Timeline') ?></legend> 57 <div class="form-row"> 58 <label for="started_at"><?php echo __('Start date of activity (yyyy-mm-dd)') ?></label> 59 <?php echo object_input_date_tag($connection, 'getStartedAt', 'name=connection[started_at] format=Y-MM-dd rich=true class=date_select', $sf_params->get('connection[started_at]')) ?> 60 <?php echo form_error('connection[started_at]') ?> 61 </div> 62 <div class="form-row"> 63 <label for="ended_at"><?php echo __('End date of activity (yyyy-mm-dd)') ?></label> 64 <?php echo object_input_date_tag($connection, 'getEndedAt', 'name=connection[ended_at] format=Y-MM-dd rich=true class=date_select', $sf_params->get('connection[ended_at]')) ?> 65 <?php echo form_error('connection[ended_at]') ?> 57 <div class="date_select"> 58 <div class="form-row"> 59 <?php echo $form['started_at']->renderLabel(__('Start date of activity')) ?> 60 <?php echo $form['started_at']->render() ?> 61 <?php echo $form['started_at']->renderError() ?> 62 </div> 63 <div class="form-row"> 64 <?php echo $form['ended_at']->renderLabel(__('End date of activity')) ?> 65 <?php echo $form['ended_at']->render() ?> 66 <?php echo $form['ended_at']->renderError() ?> 67 </div> 66 68 </div> 67 69 </fieldset> … … 69 71 <div class="form-row" style="text-align:center;clear:left;"> 70 72 <p> 71 <?php echo button_to(__('Cancel'), '@application_page?slug='.$application->getSlug()) ?> 72 <?php echo submit_tag(__('Connect your profile to this application')) ?> 73 <?php echo $form['_csrf_token'] ?> 74 <input type="button" value="<?php echo __('Cancel') ?>" onclick="document.location='<?php echo url_for('@application_page?slug='.$application->getSlug()) ?>';return false"/> 75 <input type="submit" name="commit" value="<?php echo __('Connect your profile to this application') ?>"/> 73 76 </p> 74 77 </div> trunk/lib/form/ApplicationDeveloperForm.class.php
r56 r68 12 12 public function configure() 13 13 { 14 $context = sfContext::getInstance(); 15 $culture = $context->getUser()->getCulture(); 16 17 unset($this['id']); 18 19 // Widgets 20 $this->widgetSchema['started_at'] = new sfWidgetFormI18nDate(array('culture' => $culture)); 21 $this->widgetSchema['ended_at'] = new sfWidgetFormI18nDate(array('culture' => $culture)); 22 23 // Validators 24 $this->validatorSchema['started_at'] = new sfValidatorDate(array('required' => false)); 25 $this->validatorSchema['ended_at'] = new sfValidatorDate(array('required' => false)); 26 $this->validatorSchema['role'] = new sfValidatorString(array('max_length' => 255, 'required' => true)); 27 28 $this->widgetSchema->setNameFormat('connection[%s]'); 14 29 } 15 30 } trunk/lib/form/ApplicationForm.class.php
r66 r68 13 13 $context = sfContext::getInstance(); 14 14 $culture = $context->getUser()->getCulture(); 15 //sfLoader::loadHelpers('I18n');16 15 17 16 // Unset unused widgets … … 31 30 // Overriding validators 32 31 $this->validatorSchema['tags'] = new sfValidatorRegex(array('pattern' => '/[0-9\w.-_, ]/i', 'required' => false)); 33 $this->validatorSchema['screenshot_path'] = new sfValidatorFile(array('max_size' => 512000, 'required' => false)); 32 $this->validatorSchema['screenshot_path'] = new sfValidatorFile(array('max_size' => 512000, 33 'mime_types' => 'web_images', 34 'validated_file_class' => 'sfValidatedThumb', 35 'required' => false)); 34 36 $this->validatorSchema['country'] = new sfValidatorI18nChoiceCountry(array('culture' => $culture, 'required' => false)); 35 37 $this->validatorSchema['started_at'] = new sfValidatorDate(array('required' => false)); trunk/plugins
- Property svn:externals changed from
sfPropelAlternativeSchemaPlugin http://svn.symfony-project.com/plugins/sfPropelAlternativeSchemaPlugin
sfWebBrowserPlugin http://svn.symfony-project.com/plugins/sfWebBrowserPlugin
sfPagerNavigationPlugin http://svn.symfony-project.com/plugins/sfPagerNavigationPlugin
sfFeed2Plugin http://svn.symfony-project.com/plugins/sfFeed2Plugin
sfPropelMigrationsLightPlugin -r7087 http://svn.symfony-project.com/plugins/sfPropelMigrationsLightPlugin/trunk/
sfSwiftPlugin http://svn.symfony-project.com/plugins/sfSwiftPlugin/trunk
sfLucenePlugin http://svn.symfony-project.com/plugins/sfLucenePlugin/branches/1.1
sfGuardPlugin http://svn.symfony-project.com/plugins/sfGuardPlugin/branches/1.1
sfFormExtraPlugin http://svn.symfony-project.com/plugins/sfFormExtraPlugin/
to
sfPropelAlternativeSchemaPlugin http://svn.symfony-project.com/plugins/sfPropelAlternativeSchemaPlugin
sfWebBrowserPlugin http://svn.symfony-project.com/plugins/sfWebBrowserPlugin
sfPagerNavigationPlugin http://svn.symfony-project.com/plugins/sfPagerNavigationPlugin
sfFeed2Plugin http://svn.symfony-project.com/plugins/sfFeed2Plugin
sfPropelMigrationsLightPlugin http://svn.symfony-project.com/plugins/sfPropelMigrationsLightPlugin/trunk/
sfSwiftPlugin http://svn.symfony-project.com/plugins/sfSwiftPlugin/trunk
sfLucenePlugin http://svn.symfony-project.com/plugins/sfLucenePlugin/branches/1.1
sfGuardPlugin http://svn.symfony-project.com/plugins/sfGuardPlugin/branches/1.1
sfFormExtraPlugin http://svn.symfony-project.com/plugins/sfFormExtraPlugin/
sfPropelActAsTaggableBehaviorPlugin http://svn.symfony-project.com/plugins/sfPropelActAsTaggableBehaviorPlugin/trunk/
- Property svn:externals changed from
trunk/test/functional/main/applicationsActionsTest.php
r66 r68 8 8 9 9 $browser-> 10 11 // Check application home 10 12 get('/applications')-> 11 13 isStatusCode(200)-> … … 22 24 checkResponseElement('.thumbs_list h4', '/Crédinoé/', array('position' => 5))-> 23 25 26 // Check application page 24 27 click('Splitgames')-> 25 28 isStatusCode(200)-> … … 35 38 signInUser('/application/add')-> 36 39 isStatusCode(200)-> 40 41 // Create a new application 37 42 setField('application[name]', 'My test app')-> 38 43 click('Add this application')-> … … 41 46 isRequestParameter('action', 'add')-> 42 47 followRedirect()-> 48 49 // Connect as developer 43 50 isRequestParameter('module', 'applications')-> 44 51 isRequestParameter('action', 'connectAsDeveloper')-> 45 click('')->//TODO 52 checkResponseElement('p.notice', '/Application added/', array('position' => 0))-> 53 checkResponseElement('h2', '/Connect yourself to the My test app application/', array('position' => 0))-> 54 setField('connection[role]', 'My role')-> 55 setField('connection[description]', 'Mostly sleeping')-> 56 click('Connect your profile to this application')-> 57 isRequestParameter('module', 'applications')-> 58 isRequestParameter('action', 'connectAsDeveloper')-> 59 isStatusCode(302)-> 60 followRedirect()-> 61 62 // Check application details page 46 63 isRequestParameter('module', 'applications')-> 47 64 isRequestParameter('action', 'details')-> 48 65 isRequestParameter('slug', 'my-test-app')-> 49 checkResponseElement('p.notice', '/Application updated/', array('position' => 0))-> 66 checkResponseElement('p.notice', '/You have been marked as implied with this application/', array('position' => 0))-> 67 68 // Edit application 50 69 click('Edit this application informations')-> 51 70 isRequestParameter('module', 'applications')-> … … 59 78 isRequestParameter('action', 'details')-> 60 79 isRequestParameter('slug', 'my-test-app')-> 61 checkResponseElement('p.notice', '/Application updated/', array('position' => 0)) 80 checkResponseElement('p.notice', '/Application updated/', array('position' => 0))-> 81 checkResponseElement('h2', '/My edited test app/', array('position' => 0)) 62 82 ;
