Changeset 79 for trunk

Show
Ignore:
Timestamp:
10/09/08 14:39:31 (1 year ago)
Author:
nperriault
Message:

[1.1] Updated functional tests, migrated Job form

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/apps/main/config/filters.yml

    r48 r79  
    1212  class:    conditionalCacheFilter 
    1313 
    14 highlight: 
    15   class:    sfLuceneHighlightFilter 
     14#highlight: 
     15#  class:    sfLuceneHighlightFilter 
    1616 
    1717cache:     ~ 
  • trunk/apps/main/config/routing.yml

    r75 r79  
    203203job_add: 
    204204  url:   /job/add 
    205   param: { module: jobs, action: add
     205  param: { module: jobs, action: edit
    206206 
    207207job_edit: 
  • trunk/apps/main/lib/myUser.class.php

    r66 r79  
    2727    return parent::getGuardUser(); 
    2828  } 
    29    
     29 
    3030  /** 
    31    * Returns current session storage instance  
     31   * Returns current session storage instance 
    3232   * 
    3333   * @return sfSessionStorage 
     
    3636  { 
    3737    return $this->storage; 
     38  } 
     39 
     40  /** 
     41   * Retrieves related user companies 
     42   * 
     43   * @return array 
     44   */ 
     45  public function getRelatedCompanies() 
     46  { 
     47    return $this->getGuardUser()->getCompaniesArray($this->isAdmin() ? 'all' : 'related'); 
    3848  } 
    3949 
  • trunk/apps/main/modules/jobs/actions/actions.class.php

    r75 r79  
    99{ 
    1010 
    11   public function executeAdd() 
    12   { 
    13     $this->job = new Job(); 
    14     if ($this->getRequest()->getMethod() == sfRequest::POST) 
    15     { 
    16       $this->updateFromRequest(); 
     11  public function executeEdit($request) 
     12  { 
     13    if (!is_null($request->getParameter('slug'))) 
     14    { 
     15      $this->job = $this->getFromSlug(); 
     16 
     17      if (!$this->getUser()->isAdmin() && $this->job->getContactId() != $this->getUser()->getId()) 
     18      { 
     19        $this->getUser()->setFlash('warning', $this->__('You are not allowed to edit this record')); 
     20        $this->redirect('@job_page?slug='.$this->job->getSlug()); 
     21      } 
     22    } 
     23    else 
     24    { 
     25      $this->job = new Job(); 
     26      $this->setTemplate('add'); 
     27    } 
     28 
     29    $this->job->setContactId($this->getUser()->getId()); 
     30    $this->form = new JobForm($this->job, array('userCompanies' => $this->getUser()->getRelatedCompanies())); 
     31 
     32    if ($request->isMethod('post') && $this->form->bindAndSave($request->getParameter('job'))) 
     33    { 
    1734      parent::purgeObjectRelatedCache($this->job); 
    18       $this->getUser()->setFlash('notice', $this->getI18N()->__('Job offer published')); 
    19       $this->redirect('@job_page?slug='.$this->job->getSlug()); 
    20     } 
    21   } 
    22  
    23   public function executeEdit() 
    24   { 
    25     $this->job = $this->getFromSlug(); 
    26  
    27     if (!$this->getUser()->isAdmin() && $this->job->getContactId() != $this->getUser()->getId()) 
    28     { 
    29       $this->getUser()->setFlash('warning', $this->getI18N()->__('You are not allowed to edit this record')); 
    30       $this->redirect('@job_page?slug='.$this->job->getSlug()); 
    31     } 
    32  
    33     if ($this->getRequest()->getMethod() == sfRequest::POST) 
    34     { 
    35       $this->updateFromRequest(); 
    36       parent::purgeObjectRelatedCache($this->job); 
    37       $this->getUser()->setFlash('notice', $this->getI18N()->__('Job offer has been updated')); 
    38       $this->redirect('@job_page?slug='.$this->job->getSlug()); 
     35 
     36      $this->getUser()->setFlash('notice', $this->__('Job offer has been updated')); 
     37      $this->redirect('@job_page?slug='.$this->form->getObject()->getSlug()); 
    3938    } 
    4039  } 
     
    4847    if (!is_null($this->job->getExpiresAt()) && $this->job->getExpiresAt(null) < time()) 
    4948    { 
    50       $this->getUser()->setFlash('warning', $this->getI18N()->__('This job offer is perempted')); 
     49      $this->getUser()->setFlash('warning', $this->__('This job offer is perempted')); 
    5150    } 
    5251  } 
     
    5756    if (!$this->getUser()->isAdmin() && $this->getUser()->getId() != $this->job->getContactId()) 
    5857    { 
    59       $this->getUser()->setFlash('warning', $this->getI18N()->__('You are not allowed to delete this job offer')); 
     58      $this->getUser()->setFlash('warning', $this->__('You are not allowed to delete this job offer')); 
    6059    } 
    6160    else 
     
    6362      parent::purgeObjectRelatedCache($this->job); 
    6463      $this->job->delete(); 
    65       $this->getUser()->setFlash('notice', $this->getI18N()->__('Job offer has been deleted')); 
     64      $this->getUser()->setFlash('notice', $this->__('Job offer has been deleted')); 
    6665    } 
    6766    $this->redirect('@jobs_home'); 
     
    150149  } 
    151150 
    152   public function handleErrorAdd() 
    153   { 
    154     $this->job = new Job(); 
    155     return sfView::SUCCESS; 
    156   } 
    157  
    158   public function handleErrorEdit() 
    159   { 
    160     $this->job = $this->getFromSlug(); 
    161     return sfView::SUCCESS; 
    162   } 
    163  
    164151  protected function renderHomeAsFeed(Criteria $c) 
    165152  { 
     
    221208    $this->feed = $feed; 
    222209  } 
    223  
    224   protected function updateFromRequest() 
    225   { 
    226     $job_data = $this->getRequestParameter('job', array()); 
    227     if (!isset($job_data['teleworking'])) 
    228     { 
    229       $job_data['teleworking'] = false; 
    230     } 
    231     if (isset($job_data['expires_at']) && $job_data['expires_at'] == '') 
    232     { 
    233       unset($job_data['expires_at']); 
    234     } 
    235     try 
    236     { 
    237       if (!$this->getUser()->isAdmin() or ($this->getUser()->isAdmin() && $this->job->isNew())) 
    238       { 
    239         $this->job->setContactId($this->getUser()->getId()); 
    240       } 
    241       $this->job->fromArray($job_data, BasePeer::TYPE_FIELDNAME); 
    242       return $this->job->save(); 
    243     } 
    244     catch (Exception $e) 
    245     { 
    246       $this->getRequest()->setError('errors', $this->getI18N()->__('Unable to save this record')); 
    247       sfContext::getInstance()->getLogger()->err('Blocking error at job save time: '.$e->getMessage()); 
    248       return sfView::SUCCESS; 
    249     } 
    250   } 
    251210} 
  • trunk/apps/main/modules/jobs/templates/_form.php

    r64 r79  
    1010</p> 
    1111 
    12 <form action="<?php echo url_for($form_route) ?>" method="post" enctype="multipart/form-data"
     12<form action="<?php echo url_for($form_route) ?>" method="post"
    1313  <div class="fiftypercent"> 
    1414    <fieldset> 
    1515      <legend><?php echo __('Basic informations') ?></legend> 
    1616      <div class="form-row required"> 
    17         <label for="title"><?php echo __('Job title') ?></label
    18         <?php echo object_input_tag($job, 'getTitle', 'name=job[title]', $sf_params->get('job[title]')) ?> 
    19         <?php echo form_error('job[title]') ?> 
     17        <?php echo $form['title']->renderLabel(__('Job title')) ?
     18        <?php echo $form['title']->render() ?> 
     19        <?php echo $form['title']->renderError() ?> 
    2020      </div> 
    2121      <div class="form-row required"> 
    22         <label for="summary"><?php echo __('Summary') ?></label
    23         <?php echo object_textarea_tag($job, 'getSummary', 'name=job[summary] rows=13', $sf_params->get('job[summary]')) ?> 
    24         <?php echo form_error('job[summary]') ?> 
     22        <?php echo $form['summary']->renderLabel(__('Summary')) ?
     23        <?php echo $form['summary']->render() ?> 
     24        <?php echo $form['summary']->renderError() ?> 
    2525      </div> 
    2626      <div class="form-row"> 
    27         <label for="budget"><?php echo __('Budget') ?></label
    28         <?php echo object_input_tag($job, 'getBudget', 'name=job[budget]', $sf_params->get('job[budget]')) ?> 
    29         <?php echo form_error('job[budget]') ?> 
     27        <?php echo $form['budget']->renderLabel(__('Budget')) ?
     28        <?php echo $form['budget']->render() ?> 
     29        <?php echo $form['budget']->renderError() ?> 
    3030      </div> 
    3131      <div class="form-row"> 
    32         <?php echo object_checkbox_tag($job, 'getTeleworking', 'name=job[teleworking]', $sf_params->get('job[teleworking]')) ?> 
    33         <label for="teleworking" class="inline"> 
    34           <?php echo __('Possible teleworking?') ?> 
    35         </label> 
    36         <?php echo form_error('job[teleworking]') ?> 
     32        <?php echo $form['teleworking']->render() ?> 
     33        <?php echo $form['teleworking']->renderLabel(__('Possible teleworking?'), array('class' => 'inline')) ?> 
     34        <?php echo $form['teleworking']->renderError() ?> 
    3735      </div> 
    3836    </fieldset> 
     
    4240      <legend><?php echo __('Contact informations') ?></legend> 
    4341      <div class="form-row"> 
    44         <label for="company_id"><?php echo __('Is the job offered by a company you\'re related to?') ?></label> 
    45         <?php echo select_tag('job[company_id]', 
    46                                     options_for_select($sf_user->getGuardUser()->getCompaniesArray($sf_user->isAdmin() ? 'all' : 'related'), 
    47                                                        $sf_request->getParameter('job[company_id]', $job->getCompanyId()), 
    48                                                        array('include_custom' => __('No')))) ?> 
    49         <?php echo form_error('job[company_id]') ?> 
     42        <?php echo $form['company_id']->renderLabel(__('Is the job offered by a company you\'re related to?')) ?> 
     43        <?php echo $form['company_id']->render() ?> 
     44        <?php echo $form['company_id']->renderError() ?> 
    5045        <p class="form-help"> 
    5146          <?php echo __('If you don\'t select a company you will be directly contacted by applicants.') ?> 
    5247          <?php echo __('Your company is not listed above? %add_link%.', 
    53                         array('%add_link%' => link_to(__('Add it now'), 
    54                                                       '@company_add'))) ?> 
     48                        array('%add_link%' => link_to(__('Add it now'), '@company_add'))) ?> 
    5549        </p> 
    5650      </div> 
     
    6155      <legend><?php echo __('Localization') ?></legend> 
    6256      <div class="form-row"> 
    63         <label for="city"><?php echo __('City') ?></label
    64         <?php echo object_input_tag($job, 'getCity', 'name=job[city]', $sf_params->get('job[city]')) ?> 
    65         <?php echo form_error('job[city]') ?> 
     57        <?php echo $form['city']->renderLabel(__('City')) ?
     58        <?php echo $form['city']->render() ?> 
     59        <?php echo $form['city']->renderError() ?> 
    6660        <div class="form_help"> 
    6761          <?php echo __('Please enter only one city name. If you have job offers on distinct locations, please post one job offer per location.') ?> 
     
    6963      </div> 
    7064      <div class="form-row"> 
    71         <label for="state"><?php echo __('State (if applicable)') ?></label
    72         <?php echo object_input_tag($job, 'getState', 'name=job[state]', $sf_params->get('job[state]')) ?> 
    73         <?php echo form_error('job[state]') ?> 
     65        <?php echo $form['state']->renderLabel(__('State (if applicable)')) ?
     66        <?php echo $form['state']->render() ?> 
     67        <?php echo $form['state']->renderError() ?> 
    7468      </div> 
    7569      <div class="form-row"> 
    76         <label for="country"><?php echo __('Country') ?></label
    77         <?php echo object_select_country_tag($job, 'getCountry', 'name=job[country] include_custom='.__('Select a country'), $sf_params->getRawValue()->get('job[country]')) ?> 
    78         <?php echo form_error('job[country]') ?> 
     70        <?php echo $form['country']->renderLabel(__('Country')) ?
     71        <?php echo $form['country']->render() ?> 
     72        <?php echo $form['country']->renderError() ?> 
    7973      </div> 
    8074      <div class="form-row"> 
    81         <label for="expires_at"><?php echo __('Job offer expiration date (yyyy-mm-dd)') ?></label> 
    82         <?php echo object_input_date_tag($job, 'getExpiresAt', 'name=job[expires_at] format=Y-MM-dd rich=true class=date_select', $sf_params->get('job[expires_at]')) ?> 
    83         <?php echo form_error('job[expires_at]') ?> 
     75        <div class="date_select"> 
     76          <?php echo $form['expires_at']->renderLabel(__('Job offer expiration date (yyyy-mm-dd)')) ?> 
     77          <?php echo $form['expires_at']->render() ?> 
     78          <?php echo $form['expires_at']->renderError() ?> 
     79        </div> 
    8480      </div> 
    8581    </fieldset> 
     
    8783  <div class="form-row" style="text-align:center;clear:left;"> 
    8884    <p> 
    89       <?php echo submit_tag($submit_label) ?> 
     85      <?php echo $form['_csrf_token'] ?> 
     86      <?php echo $form['id'] ?> 
     87      <input type="submit" value="<?php echo $submit_label ?>"/> 
    9088    </p> 
    9189  </div> 
  • trunk/apps/main/modules/jobs/templates/addSuccess.php

    r2 r79  
    55 
    66<?php include_partial('jobs/form', 
    7                       array('job'          => $job, 
     7                      array('job'          => $form->getObject(), 
     8                            'form'         => $form, 
    89                            'title'        => $page_title, 
    910                            'form_route'   => '@job_add', 
  • trunk/apps/main/modules/jobs/templates/editSuccess.php

    r2 r79  
    55 
    66<?php include_partial('jobs/form', 
    7                       array('job'          => $job, 
     7                      array('job'          => $form->getObject(), 
     8                            'form'         => $form, 
    89                            'title'        => $page_title, 
    9                             'form_route'   => '@job_edit?slug='.$job->getSlug(), 
     10                            'form_route'   => '@job_edit?slug='.$form->getObject()->getSlug(), 
    1011                            'submit_label' => __('Update this job offer'))) ?> 
  • trunk/apps/main/modules/mail/actions/actions.class.php

    r56 r79  
    88class mailActions extends myActions 
    99{ 
    10    
     10 
    1111  public function executeContact(sfWebRequest $request) 
    1212  { 
    1313    $this->message = $request->getAttribute('message'); 
    1414  } 
    15    
     15 
    1616  public function executeForgotPassword(sfWebRequest $request) 
    1717  { 
    1818    $this->password = $request->getAttribute('password'); 
    1919  } 
    20    
     20 
    2121  public function executeRegister(sfWebRequest $request) 
    2222  { 
     
    2424    $this->activation = $request->getAttribute('activation'); 
    2525  } 
    26    
     26 
    2727  public function executeResendActivation(sfWebRequest $request) 
    2828  { 
    2929    $this->activation = $request->getAttribute('activation'); 
    3030  } 
    31    
     31 
    3232  public function executeCompanyContact(sfWebRequest $request) 
    3333  { 
     
    3636    $this->company = $request->getAttribute('company'); 
    3737  } 
    38    
     38 
    3939  public function executePersonContact(sfWebRequest $request) 
    4040  { 
     
    4343    $this->message = $request->getAttribute('message'); 
    4444  } 
    45    
     45 
    4646  public function executeRecommendationReceived(sfWebRequest $request) 
    4747  { 
     
    5050    $this->recommendation = $request->getAttribute('recommendation'); 
    5151  } 
    52    
     52 
     53  public function executeTest() 
     54  { 
     55 
     56  } 
     57 
    5358} 
  • trunk/apps/main/templates/_messages.php

    r75 r79  
    66    <?php echo $activeForm->renderGlobalErrors() ?> 
    77  </div> 
    8   <?php elseif (count($activeForm->getErrorSchema())): ?> 
     8  <?php elseif (count($activeForm->getErrorSchema()) > 0): ?> 
    99  <div class="global-form-errors"> 
    1010    <h4><?php echo __('Errors have been encountered') ?></h4> 
  • trunk/lib/form/JobForm.class.php

    r75 r79  
    99{ 
    1010  /** 
     11   * @var array of Company 
     12   */ 
     13  protected $userCompanies = array(); 
     14 
     15  /** 
     16   * Constructor 
     17   * 
     18   * @param Job $job 
     19   * @param array $userCompanies 
     20   */ 
     21  public function __construct(Job $job, $options = array(), $CSRFSecret = null) 
     22  { 
     23    if (isset($options['userCompanies'])) 
     24    { 
     25      $this->userCompanies = $options['userCompanies']; 
     26      unset($options['userCompanies']); 
     27    } 
     28 
     29    parent::__construct($job, $options, $CSRFSecret); 
     30  } 
     31 
     32  /** 
    1133   * Form configuration 
    1234   * 
     
    1436  public function configure() 
    1537  { 
     38    // Unset unused widgets 
     39    unset($this['created_at'], 
     40          $this['updated_at'], 
     41          $this['contact_id'], 
     42          $this['slug']); 
     43 
     44    $this->initWidgets(); 
     45    $this->initValidators(); 
     46  } 
     47 
     48  /** 
     49   * Intitialize widgets 
     50   * 
     51   */ 
     52  public function initWidgets() 
     53  { 
     54    $this->widgetSchema['country']    = new ExtendedWidgetFormI18nSelectCountry(array('culture' => $this->culture, 'add_label_option' => __('Select a country'))); 
     55    $this->widgetSchema['expires_at'] = new sfWidgetFormI18nDate(array('culture' => $this->culture)); 
     56  } 
     57 
     58  /** 
     59   * Initialize validators 
     60   * 
     61   */ 
     62  public function initValidators() 
     63  { 
     64    $this->validatorSchema['country']    = new sfValidatorI18nChoiceCountry(array('culture' => $this->culture, 'required' => false)); 
     65    $this->validatorSchema['expires_at'] = new sfValidatorDate(array('required' => false)); 
    1666  } 
    1767} 
  • trunk/lib/model/Job.php

    r49 r79  
    44 * 
    55 * @package lib.model 
    6  */  
     6 */ 
    77class Job extends BaseJob 
    88{ 
    99 
    1010  protected $place = null; 
    11    
     11 
    1212  public function getCountryName() 
    1313  { 
     
    1818    } 
    1919  } 
    20    
     20 
    2121  public function getIsActive() 
    2222  { 
    2323    return !$this->getExpiresAt() or $this->getExpiresAt(null) > time(); 
    2424  } 
    25    
     25 
    2626  public function getPlace() 
    2727  { 
     
    5656    return $this->place; 
    5757  } 
    58    
     58 
    5959  public function getOwnerName() 
    6060  { 
     
    7272    } 
    7373  } 
    74    
     74 
    7575  public function save($con = null) 
    7676  { 
     
    7878    $modified = $this->isModified(); 
    7979    $affectedRows = parent::save($con); 
    80      
     80 
    8181    if ($this->getCompanyId() && !$this->getCompany()->getAllowContact()) 
    8282    { 
    8383      $this->getCompany()->setAllowContact(true); 
    8484      $this->getCompany()->save(); 
    85       //sfContext::getInstance()->getLogger()->info(sprintf('Company "%s" has now email contact enabled',  
    86         //                                    $this->getCompany()->getName())); 
    8785    } 
    88      
     86 
    8987    // Create "company created" event object 
    9088    if ($modified) 
     
    116114      $event->save(); 
    117115    } 
    118      
     116 
    119117    return $affectedRows; 
    120118  } 
     
    125123                     'to'   => JobPeer::SLUG); 
    126124 
    127 sfPropelBehavior::add('Job',  
    128                       array('sfPropelActAsSluggableBehavior' =>  
    129                               array('columns'   => $columns_map,  
    130                                     'separator' => '-',  
     125sfPropelBehavior::add('Job', 
     126                      array('sfPropelActAsSluggableBehavior' => 
     127                              array('columns'   => $columns_map, 
     128                                    'separator' => '-', 
    131129                                    'permanent' => true), 
    132                             'sfPropelActAsLocalizableBehavior' =>  
     130                            'sfPropelActAsLocalizableBehavior' => 
    133131                              array('location_getter' => 'getPlace'))); 
    134132 
  • trunk/lib/utils/SymfoniansTestBrowser.class.php

    r75 r79  
    157157  { 
    158158    self::$test->comment('Loading fixtures...'); 
    159  
    160     $t = new sfPropelLoadDataTask(self::$configuration->getEventDispatcher(), new sfAnsiColorFormatter()); 
    161     $t->run(array('application' => self::$configuration->getApplication())); 
    162  
    163     self::$test->comment('Fixtures loaded.'); 
     159     
     160    try 
     161    { 
     162      $t = new sfPropelLoadDataTask(self::$configuration->getEventDispatcher(), new sfAnsiColorFormatter()); 
     163      $t->run(array('application' => self::$configuration->getApplication())); 
     164 
     165      self::$test->comment('Fixtures loaded.'); 
     166    } 
     167    catch (PropelException $e) 
     168    { 
     169      self::$test->fail('Unable to load fixtures: '.$e->getMessage()); 
     170    } 
    164171  } 
    165172 
  • trunk/lib/validator/sfValidatorSchemaLicence.class.php

    r75 r79  
    1313  protected function doClean($values) 
    1414  { 
    15     //parent::doClean($values); 
    16  
    17     $errorSchema = new sfValidatorErrorSchema($this); 
    18  
    1915    if ($values['is_opensource'] && 0 === strlen(trim($values['licence']))) 
    2016    { 
  • 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 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/
      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
      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/
  • trunk/test/functional/main/applicationsActionsTest.php

    r75 r79  
    173173  isRequestParameter('action', 'home')-> 
    174174  isRequestParameter('page', 2)-> 
    175   checkResponseElement('p.navigation a', '/1/')-> 
     175  checkResponseElement('p.navigation', '/1/')-> 
    176176  click('1')-> 
    177177  isStatusCode(200)-> 
  • trunk/web

    • Property svn:externals changed from
      sf http://svn.symfony-project.com/branches/1.1/data/web/sf
      sfLucenePlugin http://svn.symfony-project.com/plugins/sfLucenePlugin/branches/1.1/web
      to
      sf http://svn.symfony-project.com/branches/1.1/data/web/sf