Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cf-online-api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KS Pardubický kraj
cf-online-api
Commits
862473fc
Verified
Commit
862473fc
authored
3 years ago
by
Andrej Ramašeuski
Browse files
Options
Downloads
Patches
Plain Diff
Base events managenent
parent
87e5cfc0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#6908
passed
3 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/CF/Controller/Events.pm
+40
-2
40 additions, 2 deletions
lib/CF/Controller/Events.pm
sql/9/up.sql
+33
-0
33 additions, 0 deletions
sql/9/up.sql
with
73 additions
and
2 deletions
lib/CF/Controller/Events.pm
+
40
−
2
View file @
862473fc
...
...
@@ -36,7 +36,7 @@ sub get ($c) {
my
$formatted
=
$event
->
format
();
$formatted
->
{
acl
}
=
[]
;
$formatted
->
{
stream_url
}
=
$event
->
stream_url
||
'
/hls/
'
.
$event
->
uuid
.
'
.m3u8
';
//
'
/hls/
'
.
$event
->
uuid
.
'
.m3u8
';
my
$roles
=
$event
->
user_roles
(
$c
->
user
);
...
...
@@ -110,10 +110,48 @@ sub delete ($c) {
$c
->
render
(
status
=>
204
,
text
=>
'');
}
sub
role_add
($c) {
$c
->
openapi
->
valid_input
or
return
;
my
$args
=
$c
->
req
->
json
;
my
$event
=
$c
->
_get
('
chairman
')
||
return
;
my
$subject
=
$c
->
schema
->
resultset
('
EventACLSubject
')
->
find_or_new
({
class
=>
$args
->
{
subject_class
},
key
=>
$args
->
{
subject_value
},
name
=>
$args
->
{
subject_name
}
||
$args
->
{
subject_value
},
},
{
key
=>
'
class_key
'
});
if
(
$subject
->
in_storage
)
{
if
(
$args
->
{
subject_name
}
&&
$args
->
{
subject_name
}
ne
$subject
->
name
)
{
$subject
->
update
({
updated
=>
\
'
now()
',
name
=>
$args
->
{
subject_name
},
});
}
}
else
{
$subject
->
insert
;
}
my
$acl
=
$event
->
find_or_create_related
('
acls
',
{
subject_id
=>
$subject
->
id
,
role
=>
$args
->
{
role
},
});
$c
->
render
(
status
=>
201
,
openapi
=>
{
id
=>
$acl
->
id
},
);
}
sub
_get
($c, $role='') {
my
$event
=
$c
->
schema
->
resultset
('
Event
')
->
find
({
$c
->
stash
->
{
id
}
id
=>
$c
->
stash
->
{
id
}
});
return
$c
->
error
(
404
,
'
Event not found
')
if
!
$event
||
$event
->
deleted
;
...
...
This diff is collapsed.
Click to expand it.
sql/9/up.sql
0 → 100644
+
33
−
0
View file @
862473fc
create
table
"events_acl_subjects"
(
"id"
integer
not
null
default
nextval
(
'uid_seq'
),
"updated"
timestamp
(
0
)
not
null
default
now
(),
"class"
varchar
(
8
)
not
null
,
"key"
text
not
null
,
"name"
text
,
primary
key
(
"id"
),
unique
(
"class"
,
"key"
)
);
create
table
"events_acl"
(
"id"
integer
not
null
default
nextval
(
'uid_seq'
),
"event_id"
integer
not
null
,
"subject_id"
integer
not
null
,
"role"
text
,
primary
key
(
"id"
),
unique
(
"event_id"
,
"subject_id"
,
"role"
),
foreign
key
(
"event_id"
)
references
"events"
(
"id"
)
on
update
cascade
on
delete
cascade
,
foreign
key
(
"subject_id"
)
references
"events_acl_subjects"
(
"id"
)
on
update
cascade
on
delete
cascade
);
create
view
"events_acl_view"
as
(
select
"events_acl"
.
"id"
,
"events_acl"
.
"event_id"
,
"events_acl_subjects"
.
"class"
as
"subject_class"
,
"events_acl_subjects"
.
"key"
as
"subject_key"
,
"events_acl_subjects"
.
"name"
as
"subject_name"
,
"events_acl"
.
"role"
from
"events_acl"
join
"events_acl_subjects"
on
(
"events_acl"
.
"subject_id"
=
"events_acl_subjects"
.
"id"
)
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment