comanage-dev - Re: [comanage-dev] Fwd: [JIRA] (CO-242) Error in inviting a person to a co
Subject: COmanage Developers List
List archive
- From: Scott Koranda <>
- To: Benn Oshrin <>
- Cc: comanage-dev <>
- Subject: Re: [comanage-dev] Fwd: [JIRA] (CO-242) Error in inviting a person to a co
- Date: Fri, 17 Feb 2012 17:14:50 -0600
> On 2/17/12 5:30 PM, Scott Koranda wrote:
>
> >As discussed on the call today I have added an add() method to
> >the CoPeopleController class that overrides the add() method
> >in the parent StandardController class.
> >
> >A diff is attached.
> >
> >I have tested this patch and it correctly updates the
> >CoPeople and CoOrgIdentityLink tables.
> >
> >Benn can you please look at the diff and let me know what if
> >anything you want changed or if I have overlooked some side
> >effect?
>
> Can we simplify this to only update ['*_id']['required']?
Yes.
New diff attached. Please comment.
> I'm
> thinking of a scenario where we change the 'rule' or some other
> aspect of validation in the model and don't remember to change it
> here.
>
> Also, on the same note, it'd be good to add a comment near $validate
> in the model mentioning that it may be overridden by the controller
> in add().
Done, included in diff.
>
> Nitpicking, there's an extra newline after the call to parent::add().
Fixed.
Thanks,
Scott
Index: Controller/CoPeopleController.php
===================================================================
--- Controller/CoPeopleController.php (revision 229)
+++ Controller/CoPeopleController.php (working copy)
@@ -249,6 +249,34 @@
}
/**
+ * Add the person identified by the Org Identity to the identified CO.
+ * - precondition: org_identity_id and co_id set in $this->request->params
+ *
+ * @since COmanage Registry v0.4
+ * @return void
+ */
+
+ function add() {
+ // The parent add() method is overridden here so that for non REST calls
+ // the validation can be relaxed to allow the normal saveAll() call
+ // in the parent add() method to complete without a validation error.
+ // If the validation is not relaxed so that co_person_id and
org_identity_id
+ // are not required then the validation of all the tables before any
updates
+ // will cause a validation error for the model CoOrgIdentityLink.
+
+ if(!$this->restful) {
+ $this->loadModel('CoOrgIdentityLink');
+
+ // dynamically relax the validation for the CoOrgIdentityLink model
+ $this->CoOrgIdentityLink->validate['co_person_id']['required'] = false;
+ $this->CoOrgIdentityLink->validate['org_identity_id']['required'] =
false;
+ }
+
+ // call the add() method for the parent StandardController class
+ parent::add();
+ }
+
+ /**
* Authorization for this Controller, called by Auth component
* - precondition: Session.Auth holds data used for authz decisions
* - postcondition: $permissions set with calculated permissions
Index: Model/CoOrgIdentityLink.php
===================================================================
--- Model/CoOrgIdentityLink.php (revision 229)
+++ Model/CoOrgIdentityLink.php (working copy)
@@ -47,6 +47,9 @@
public $order = array("CoOrgIdentityLink.id");
// Validation rules for table elements
+ //
+ // 'required' => true for co_person_id and org_identity_id
+ // may be temporarily overridden during add() method of CoPeopleController.
public $validate = array(
'co_person_id' => array(
'rule' => 'numeric',
- [comanage-dev] Fwd: [JIRA] (CO-242) Error in inviting a person to a co, Benn Oshrin, 02/16/2012
- Re: [comanage-dev] Fwd: [JIRA] (CO-242) Error in inviting a person to a co, Scott Koranda, 02/16/2012
- Re: [comanage-dev] Fwd: [JIRA] (CO-242) Error in inviting a person to a co, Benn Oshrin, 02/16/2012
- Re: [comanage-dev] Fwd: [JIRA] (CO-242) Error in inviting a person to a co, Scott Koranda, 02/17/2012
- Re: [comanage-dev] Fwd: [JIRA] (CO-242) Error in inviting a person to a co, Benn Oshrin, 02/17/2012
- Re: [comanage-dev] Fwd: [JIRA] (CO-242) Error in inviting a person to a co, Scott Koranda, 02/17/2012
- Re: [comanage-dev] Fwd: [JIRA] (CO-242) Error in inviting a person to a co, Benn Oshrin, 02/18/2012
- Re: [comanage-dev] Fwd: [JIRA] (CO-242) Error in inviting a person to a co, Scott Koranda, 02/18/2012
- Re: [comanage-dev] Fwd: [JIRA] (CO-242) Error in inviting a person to a co, Benn Oshrin, 02/18/2012
- Re: [comanage-dev] Fwd: [JIRA] (CO-242) Error in inviting a person to a co, Scott Koranda, 02/17/2012
- Re: [comanage-dev] Fwd: [JIRA] (CO-242) Error in inviting a person to a co, Benn Oshrin, 02/17/2012
- Re: [comanage-dev] Fwd: [JIRA] (CO-242) Error in inviting a person to a co, Scott Koranda, 02/17/2012
- Re: [comanage-dev] Fwd: [JIRA] (CO-242) Error in inviting a person to a co, Benn Oshrin, 02/16/2012
- Re: [comanage-dev] Fwd: [JIRA] (CO-242) Error in inviting a person to a co, Scott Koranda, 02/16/2012
Archive powered by MHonArc 2.6.16.