Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adds migrations for "resource_type" field in contact table to keep tr…

…ack of the resources being requested. Also, adds tests to verify this
  • Loading branch information...
commit ad93c9f019bc1861787472227a913190df4390c5 1 parent c90ae14
@bshaffer authored
View
2  apps/frontend/modules/resource/templates/_resource_contact_owner_form.php
@@ -46,7 +46,7 @@
</div>
</li>
<li>
- <input type="submit" value="Send my info" class="button"/>
+ <input type="submit" value="Send my info" id="resource-contact-submit" class="button"/>
<p>By clicking the "Send my info" button, you agree to Donate Nashville's <a href="<?php echo url_for('terms_of_service')?>" target="_blank">Terms of Service</a>.</p>
</li>
</ul>
View
2  apps/frontend/templates/layout.php
@@ -31,7 +31,7 @@
<div class="grid_6">&nbsp;</div>
<div class="grid_5">
<div class="twitter-single header right">
- <?php include_component('default', 'twitter') ?>
+ <?php //include_component('default', 'twitter') ?>
</div>
</div>
</div>
View
18 config/doctrine/schema.yml
@@ -88,21 +88,14 @@ InfoResource:
url:
type: string(255)
-ResourceParticipant:
- columns:
- participant_id:
- type: integer
- notnull: true
- resource_id:
- type: integer
- notnull: true
- relations:
-
Contact:
columns:
resource_id:
type: integer
length: 8
+ resource_type:
+ type: string
+ length: 255
email:
type: string
length: 255
@@ -115,8 +108,3 @@ Contact:
length: 100
notes:
type: clob
- relations:
- Resource:
- local: resource_id
- foreignAlias: Contacts
- onDelete: CASCADE
View
35 lib/filter/doctrine/base/BaseContactFormFilter.class.php
@@ -13,19 +13,21 @@
public function setup()
{
$this->setWidgets(array(
- 'resource_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Resource'), 'add_empty' => true)),
- 'email' => new sfWidgetFormFilterInput(array('with_empty' => false)),
- 'name' => new sfWidgetFormFilterInput(),
- 'phone' => new sfWidgetFormFilterInput(),
- 'notes' => new sfWidgetFormFilterInput(),
+ 'resource_id' => new sfWidgetFormFilterInput(),
+ 'resource_type' => new sfWidgetFormFilterInput(),
+ 'email' => new sfWidgetFormFilterInput(array('with_empty' => false)),
+ 'name' => new sfWidgetFormFilterInput(),
+ 'phone' => new sfWidgetFormFilterInput(),
+ 'notes' => new sfWidgetFormFilterInput(),
));
$this->setValidators(array(
- 'resource_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Resource'), 'column' => 'id')),
- 'email' => new sfValidatorPass(array('required' => false)),
- 'name' => new sfValidatorPass(array('required' => false)),
- 'phone' => new sfValidatorPass(array('required' => false)),
- 'notes' => new sfValidatorPass(array('required' => false)),
+ 'resource_id' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
+ 'resource_type' => new sfValidatorPass(array('required' => false)),
+ 'email' => new sfValidatorPass(array('required' => false)),
+ 'name' => new sfValidatorPass(array('required' => false)),
+ 'phone' => new sfValidatorPass(array('required' => false)),
+ 'notes' => new sfValidatorPass(array('required' => false)),
));
$this->widgetSchema->setNameFormat('contact_filters[%s]');
@@ -45,12 +47,13 @@ public function getModelName()
public function getFields()
{
return array(
- 'id' => 'Number',
- 'resource_id' => 'ForeignKey',
- 'email' => 'Text',
- 'name' => 'Text',
- 'phone' => 'Text',
- 'notes' => 'Text',
+ 'id' => 'Number',
+ 'resource_id' => 'Number',
+ 'resource_type' => 'Text',
+ 'email' => 'Text',
+ 'name' => 'Text',
+ 'phone' => 'Text',
+ 'notes' => 'Text',
);
}
}
View
6 lib/form/doctrine/ContactResourceOwnerForm.php
@@ -13,12 +13,12 @@ class ContactResourceOwnerForm extends BaseContactForm
public function configure()
{
$this->setWidget('resource_id', new sfWidgetFormInputHidden());
+ $this->setWidget('resource_type', new sfWidgetFormInputHidden());
if ($resource = $this->getOption('resource'))
{
- // Doesn't currently work - limitation of concrete inheritance
-
- // $this->setDefault('resource_id', $resource['id']);
+ $this->setDefault('resource_id', $resource['id']);
+ $this->setDefault('resource_type', $resource->getType());
}
$this->widgetSchema->setNameFormat('contact[%s]');
View
26 lib/form/doctrine/base/BaseContactForm.class.php
@@ -15,21 +15,23 @@
public function setup()
{
$this->setWidgets(array(
- 'id' => new sfWidgetFormInputHidden(),
- 'resource_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Resource'), 'add_empty' => true)),
- 'email' => new sfWidgetFormInputText(),
- 'name' => new sfWidgetFormInputText(),
- 'phone' => new sfWidgetFormInputText(),
- 'notes' => new sfWidgetFormTextarea(),
+ 'id' => new sfWidgetFormInputHidden(),
+ 'resource_id' => new sfWidgetFormInputText(),
+ 'resource_type' => new sfWidgetFormInputText(),
+ 'email' => new sfWidgetFormInputText(),
+ 'name' => new sfWidgetFormInputText(),
+ 'phone' => new sfWidgetFormInputText(),
+ 'notes' => new sfWidgetFormTextarea(),
));
$this->setValidators(array(
- 'id' => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
- 'resource_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Resource'), 'required' => false)),
- 'email' => new sfValidatorString(array('max_length' => 255)),
- 'name' => new sfValidatorString(array('max_length' => 255, 'required' => false)),
- 'phone' => new sfValidatorString(array('max_length' => 100, 'required' => false)),
- 'notes' => new sfValidatorString(array('required' => false)),
+ 'id' => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
+ 'resource_id' => new sfValidatorInteger(array('required' => false)),
+ 'resource_type' => new sfValidatorString(array('max_length' => 255, 'required' => false)),
+ 'email' => new sfValidatorString(array('max_length' => 255)),
+ 'name' => new sfValidatorString(array('max_length' => 255, 'required' => false)),
+ 'phone' => new sfValidatorString(array('max_length' => 100, 'required' => false)),
+ 'notes' => new sfValidatorString(array('required' => false)),
));
$this->widgetSchema->setNameFormat('contact[%s]');
View
50 lib/migration/doctrine/1275147738_remove_resource_participant_add_resource_type.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * This class has been auto-generated by the Doctrine ORM Framework
+ */
+class RemoveResourceParticipantAddResourceTypeMigration extends Doctrine_Migration_Base
+{
+ public function up()
+ {
+ $this->dropTable('resource_participant');
+ $this->addColumn('contact', 'resource_type', 'string', '255', array(
+ ));
+ }
+
+ public function down()
+ {
+ $this->createTable('resource_participant', array(
+ 'id' =>
+ array(
+ 'type' => 'integer',
+ 'length' => '8',
+ 'autoincrement' => '1',
+ 'primary' => '1',
+ ),
+ 'participant_id' =>
+ array(
+ 'type' => 'integer',
+ 'notnull' => '1',
+ 'length' => '8',
+ ),
+ 'resource_id' =>
+ array(
+ 'type' => 'integer',
+ 'notnull' => '1',
+ 'length' => '8',
+ ),
+ ), array(
+ 'type' => '',
+ 'indexes' =>
+ array(
+ ),
+ 'primary' =>
+ array(
+ 0 => 'id',
+ ),
+ 'collate' => '',
+ 'charset' => '',
+ ));
+ $this->removeColumn('contact', 'resource_type');
+ }
+}
View
23 lib/migration/doctrine/1275147739_remove_contact_indexes.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * This class has been auto-generated by the Doctrine ORM Framework
+ */
+class RemoveContactIndexesMigration extends Doctrine_Migration_Base
+{
+ public function up()
+ {
+ $this->dropForeignKey('contact', 'contact_resource_id_resource_id');
+ }
+
+ public function down()
+ {
+ $this->createForeignKey('contact', 'contact_resource_id_resource_id', array(
+ 'name' => 'contact_resource_id_resource_id',
+ 'local' => 'resource_id',
+ 'foreign' => 'id',
+ 'foreignTable' => 'resource',
+ 'onUpdate' => '',
+ 'onDelete' => 'CASCADE',
+ ));
+ }
+}
View
4 lib/model/doctrine/InfoResource.class.php
@@ -12,4 +12,8 @@
*/
class InfoResource extends BaseInfoResource
{
+ public function getType()
+ {
+ return 'info';
+ }
}
View
35 lib/model/doctrine/base/BaseContact.class.php
@@ -6,24 +6,24 @@
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property integer $resource_id
+ * @property string $resource_type
* @property string $email
* @property string $name
* @property string $phone
* @property clob $notes
- * @property Resource $Resource
*
- * @method integer getResourceId() Returns the current record's "resource_id" value
- * @method string getEmail() Returns the current record's "email" value
- * @method string getName() Returns the current record's "name" value
- * @method string getPhone() Returns the current record's "phone" value
- * @method clob getNotes() Returns the current record's "notes" value
- * @method Resource getResource() Returns the current record's "Resource" value
- * @method Contact setResourceId() Sets the current record's "resource_id" value
- * @method Contact setEmail() Sets the current record's "email" value
- * @method Contact setName() Sets the current record's "name" value
- * @method Contact setPhone() Sets the current record's "phone" value
- * @method Contact setNotes() Sets the current record's "notes" value
- * @method Contact setResource() Sets the current record's "Resource" value
+ * @method integer getResourceId() Returns the current record's "resource_id" value
+ * @method string getResourceType() Returns the current record's "resource_type" value
+ * @method string getEmail() Returns the current record's "email" value
+ * @method string getName() Returns the current record's "name" value
+ * @method string getPhone() Returns the current record's "phone" value
+ * @method clob getNotes() Returns the current record's "notes" value
+ * @method Contact setResourceId() Sets the current record's "resource_id" value
+ * @method Contact setResourceType() Sets the current record's "resource_type" value
+ * @method Contact setEmail() Sets the current record's "email" value
+ * @method Contact setName() Sets the current record's "name" value
+ * @method Contact setPhone() Sets the current record's "phone" value
+ * @method Contact setNotes() Sets the current record's "notes" value
*
* @package skeleton
* @subpackage model
@@ -39,6 +39,10 @@ public function setTableDefinition()
'type' => 'integer',
'length' => 8,
));
+ $this->hasColumn('resource_type', 'string', 255, array(
+ 'type' => 'string',
+ 'length' => 255,
+ ));
$this->hasColumn('email', 'string', 255, array(
'type' => 'string',
'length' => 255,
@@ -60,9 +64,6 @@ public function setTableDefinition()
public function setUp()
{
parent::setUp();
- $this->hasOne('Resource', array(
- 'local' => 'resource_id',
- 'foreign' => 'id',
- 'onDelete' => 'CASCADE'));
+
}
}
View
79 lib/model/doctrine/base/BaseResource.class.php
@@ -23,46 +23,43 @@
* @property string $phone_2
* @property string $email
* @property sfGuardUser $User
- * @property Doctrine_Collection $Contacts
*
- * @method integer getOwnerId() Returns the current record's "owner_id" value
- * @method enum getTransactionType() Returns the current record's "transaction_type" value
- * @method string getTitle() Returns the current record's "title" value
- * @method clob getDescription() Returns the current record's "description" value
- * @method enum getPrivacy() Returns the current record's "privacy" value
- * @method boolean getIsFulfilled() Returns the current record's "is_fulfilled" value
- * @method string getNeighborhood() Returns the current record's "neighborhood" value
- * @method string getContactName() Returns the current record's "contact_name" value
- * @method string getAddress1() Returns the current record's "address_1" value
- * @method string getAddress2() Returns the current record's "address_2" value
- * @method string getCity() Returns the current record's "city" value
- * @method string getState() Returns the current record's "state" value
- * @method string getZip() Returns the current record's "zip" value
- * @method string getCounty() Returns the current record's "county" value
- * @method string getPhone1() Returns the current record's "phone_1" value
- * @method string getPhone2() Returns the current record's "phone_2" value
- * @method string getEmail() Returns the current record's "email" value
- * @method sfGuardUser getUser() Returns the current record's "User" value
- * @method Doctrine_Collection getContacts() Returns the current record's "Contacts" collection
- * @method Resource setOwnerId() Sets the current record's "owner_id" value
- * @method Resource setTransactionType() Sets the current record's "transaction_type" value
- * @method Resource setTitle() Sets the current record's "title" value
- * @method Resource setDescription() Sets the current record's "description" value
- * @method Resource setPrivacy() Sets the current record's "privacy" value
- * @method Resource setIsFulfilled() Sets the current record's "is_fulfilled" value
- * @method Resource setNeighborhood() Sets the current record's "neighborhood" value
- * @method Resource setContactName() Sets the current record's "contact_name" value
- * @method Resource setAddress1() Sets the current record's "address_1" value
- * @method Resource setAddress2() Sets the current record's "address_2" value
- * @method Resource setCity() Sets the current record's "city" value
- * @method Resource setState() Sets the current record's "state" value
- * @method Resource setZip() Sets the current record's "zip" value
- * @method Resource setCounty() Sets the current record's "county" value
- * @method Resource setPhone1() Sets the current record's "phone_1" value
- * @method Resource setPhone2() Sets the current record's "phone_2" value
- * @method Resource setEmail() Sets the current record's "email" value
- * @method Resource setUser() Sets the current record's "User" value
- * @method Resource setContacts() Sets the current record's "Contacts" collection
+ * @method integer getOwnerId() Returns the current record's "owner_id" value
+ * @method enum getTransactionType() Returns the current record's "transaction_type" value
+ * @method string getTitle() Returns the current record's "title" value
+ * @method clob getDescription() Returns the current record's "description" value
+ * @method enum getPrivacy() Returns the current record's "privacy" value
+ * @method boolean getIsFulfilled() Returns the current record's "is_fulfilled" value
+ * @method string getNeighborhood() Returns the current record's "neighborhood" value
+ * @method string getContactName() Returns the current record's "contact_name" value
+ * @method string getAddress1() Returns the current record's "address_1" value
+ * @method string getAddress2() Returns the current record's "address_2" value
+ * @method string getCity() Returns the current record's "city" value
+ * @method string getState() Returns the current record's "state" value
+ * @method string getZip() Returns the current record's "zip" value
+ * @method string getCounty() Returns the current record's "county" value
+ * @method string getPhone1() Returns the current record's "phone_1" value
+ * @method string getPhone2() Returns the current record's "phone_2" value
+ * @method string getEmail() Returns the current record's "email" value
+ * @method sfGuardUser getUser() Returns the current record's "User" value
+ * @method Resource setOwnerId() Sets the current record's "owner_id" value
+ * @method Resource setTransactionType() Sets the current record's "transaction_type" value
+ * @method Resource setTitle() Sets the current record's "title" value
+ * @method Resource setDescription() Sets the current record's "description" value
+ * @method Resource setPrivacy() Sets the current record's "privacy" value
+ * @method Resource setIsFulfilled() Sets the current record's "is_fulfilled" value
+ * @method Resource setNeighborhood() Sets the current record's "neighborhood" value
+ * @method Resource setContactName() Sets the current record's "contact_name" value
+ * @method Resource setAddress1() Sets the current record's "address_1" value
+ * @method Resource setAddress2() Sets the current record's "address_2" value
+ * @method Resource setCity() Sets the current record's "city" value
+ * @method Resource setState() Sets the current record's "state" value
+ * @method Resource setZip() Sets the current record's "zip" value
+ * @method Resource setCounty() Sets the current record's "county" value
+ * @method Resource setPhone1() Sets the current record's "phone_1" value
+ * @method Resource setPhone2() Sets the current record's "phone_2" value
+ * @method Resource setEmail() Sets the current record's "email" value
+ * @method Resource setUser() Sets the current record's "User" value
*
* @package skeleton
* @subpackage model
@@ -161,10 +158,6 @@ public function setUp()
'foreign' => 'id',
'onDelete' => 'CASCADE'));
- $this->hasMany('Contact as Contacts', array(
- 'local' => 'id',
- 'foreign' => 'resource_id'));
-
$timestampable0 = new Doctrine_Template_Timestampable(array(
));
$locatable0 = new Doctrine_Template_Locatable(array(
View
23 test/functional/frontend/needStuffTest.php
@@ -59,15 +59,24 @@
->matches(sprintf('/%s/', $resource['title']))
->checkForm('ContactResourceOwnerForm')
->end()
-
- ->call('/stuff/'.$resource->id.'/message', 'post', array('contact'=>array(
- 'email'=>'lacyrhoades@gmail.com',
- 'name'=>'Lacy',
- 'phone'=>'12345',
- 'notes'=>'Takin notes!'
- )))
+
+ ->setField('contact[email]', 'lacyrhoades@gmail.com')
+ ->setField('contact[name]', 'Lacy')
+ ->setField('contact[phone]', '12345')
+ ->setField('contact[notes]', 'Takin notes!')
+
+ ->click('#resource-contact-submit')
+
+ ->with('form')->begin()
+ ->hasErrors(false)
+ ->end()
->with('mailer')->begin()
->hasSent(true)
->withMessage($resource->User->username)
+ ->end()
+
+ ->with('doctrine')->begin()
+ ->check('Contact', array('resource_id' => $resource['id'], 'resource_type' => $resource['type']))
+ ->end()
;
Please sign in to comment.
Something went wrong with that request. Please try again.