mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-07-15 11:12:38 -04:00
Add a "can_edit" field to the Item_Model's REST output. It's
applicable to the current user.
This commit is contained in:
@@ -951,6 +951,7 @@ class Item_Model extends ORM_MPTT {
|
||||
$data["resize_url"] = $tmp;
|
||||
}
|
||||
$data["thumb_url"] = $this->thumb_url(true);
|
||||
$data["can_edit"] = access::can("edit", $this);
|
||||
|
||||
// Elide some internal-only data that is going to cause confusion in the client.
|
||||
foreach (array("relative_path_cache", "relative_url_cache", "left_ptr", "right_ptr",
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class Item_Model_Test extends Gallery_Unit_Test_Case {
|
||||
public function teardown() {
|
||||
identity::set_active_user(identity::admin_user());
|
||||
}
|
||||
|
||||
public function saving_sets_created_and_updated_dates_test() {
|
||||
$item = test::random_photo();
|
||||
$this->assert_true(!empty($item->created));
|
||||
@@ -376,6 +380,15 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
|
||||
$this->assert_true(!array_key_exists("album_cover_item", $result));
|
||||
}
|
||||
|
||||
public function as_restful_array_with_edit_bit_test() {
|
||||
$response = item::root()->as_restful_array(true);
|
||||
$this->assert_true($response["can_edit"]);
|
||||
|
||||
identity::set_active_user(identity::guest());
|
||||
$response = item::root()->as_restful_array(true);
|
||||
$this->assert_false($response["can_edit"]);
|
||||
}
|
||||
|
||||
public function first_photo_becomes_album_cover() {
|
||||
$album = test::random_album();
|
||||
$photo = test::random_photo($album);
|
||||
|
||||
Reference in New Issue
Block a user