File tree Expand file tree Collapse file tree 1 file changed +23
-5
lines changed
src/placeos-rest-api/controllers/signage Expand file tree Collapse file tree 1 file changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -40,14 +40,20 @@ module PlaceOS::Api
4040 @[AC ::Route ::Filter (:before_action , except: [:index , :create ])]
4141 def check_access_level
4242 return if user_support?
43+ ensure_access
44+ end
4345
44- # find the org zone
45- org_zone_id = authority.config[" org_zone" ]?.try(& .as_s?)
46- raise Error ::Forbidden .new unless org_zone_id
46+ # find the org zone
47+ getter org_zone_id : String do
48+ zone_id = authority.config[" org_zone" ]?.try(& .as_s?)
49+ raise Error ::Forbidden .new unless zone_id
50+ zone_id
51+ end
4752
53+ def ensure_access (admin : Bool = false )
4854 access = check_access(current_user.groups, [org_zone_id])
49- return if access.can_manage?
50-
55+ granted = admin ? access.admin? : access.can_manage?
56+ return if granted
5157 raise Error ::Forbidden .new
5258 end
5359
@@ -124,5 +130,17 @@ module PlaceOS::Api
124130 raise Error ::ModelValidation .new(new_revision.errors) unless new_revision.save
125131 new_revision
126132 end
133+
134+ # approve a playlist for publication on displays
135+ @[AC ::Route ::POST (" /:id/media/approve" )]
136+ def approve_media : ::PlaceOS ::Model ::Playlist ::Revision
137+ ensure_access(admin: true )
138+ revision = media_revisions(1 ).first?
139+ raise Error ::NotFound .new(" no media in playlist" ) unless revision
140+
141+ revision.approver = current_user
142+ raise Error ::ModelValidation .new(revision.errors) unless revision.save
143+ revision
144+ end
127145 end
128146end
You can’t perform that action at this time.
0 commit comments