fixed #685
* the admin controller loads the testing community as the default for new restaurants * the Community model encapsulates the testing community fetching * the view accepts not setting a default community
This commit is contained in:
parent
9932add0a3
commit
97018268ee
@ -18,7 +18,12 @@ class Controller_admin_restaurants extends Crunchbutton_Controller_Account
|
||||
/* @var $view Cana_View */
|
||||
|
||||
$communities = Community::q('select * from community');
|
||||
$community = $this->restaurant->community()->items()[0];
|
||||
if (count($this->restaurant->community()->items())) {
|
||||
$community = $this->restaurant->community()->items()[0];
|
||||
} else {
|
||||
$community = new Crunchbutton_Community();
|
||||
$community = $community->getTest();
|
||||
}
|
||||
|
||||
$view->communities = $communities;
|
||||
$view->community = $community;
|
||||
@ -35,8 +40,7 @@ class Controller_admin_restaurants extends Crunchbutton_Controller_Account
|
||||
$this->restaurant = $restaurant;
|
||||
|
||||
if (c::getPagePiece(2) == 'new') {
|
||||
c::view()->display('admin/restaurants/restaurant');
|
||||
|
||||
$this->_restaurantForm();
|
||||
} elseif ($restaurant->id_restaurant) {
|
||||
c::view()->restaurant = $restaurant;
|
||||
switch (c::getPagePiece(3)) {
|
||||
|
||||
@ -75,4 +75,16 @@ class Crunchbutton_Community extends Cana_Table {
|
||||
->idVar('id_community')
|
||||
->load($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Testing community
|
||||
*
|
||||
* @return Crunchbutton_Community
|
||||
*/
|
||||
public function getTest()
|
||||
{
|
||||
$row = $this->q('SELECT * FROM community WHERE name="Testing" ')->current();
|
||||
return $row;
|
||||
}
|
||||
|
||||
}
|
||||
@ -230,7 +230,7 @@ input.notification {width: 400px;}
|
||||
<select name="id_community" class="dataset-restaurant">
|
||||
<? foreach ($this->communities as $community) : ?>
|
||||
<? /* @var $community Crunchbutton_Community */ ?>
|
||||
<option value="<?=$community->id_community?>" <?=_selectedCommunity($this->community, $community)?>>
|
||||
<option value="<?=$community->id_community?>" <?=($this->community) ? _selectedCommunity($this->community, $community) : ''?>>
|
||||
<?=$community->name?>
|
||||
</option>
|
||||
<? endforeach ; ?>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user