Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Django DASF Message Broker
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DASF Data Analytics Software Framework
Django DASF Message Broker
Commits
7988af58
Verified
Commit
7988af58
authored
2 years ago
by
Philipp S. Sommer
Browse files
Options
Downloads
Patches
Plain Diff
minor fix for permissions
parent
cf5018f8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1
implement dynamic topic creation
Pipeline
#151207
failed
2 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dasf_broker/admin.py
+16
-5
16 additions, 5 deletions
dasf_broker/admin.py
dasf_broker/consumers.py
+4
-4
4 additions, 4 deletions
dasf_broker/consumers.py
dasf_broker/models.py
+2
-2
2 additions, 2 deletions
dasf_broker/models.py
with
22 additions
and
11 deletions
dasf_broker/admin.py
+
16
−
5
View file @
7988af58
...
...
@@ -29,6 +29,7 @@ Admin interfaces.
from
django.contrib
import
admin
# noqa: F401
from
guardian.admin
import
GuardedModelAdmin
from
guardian.shortcuts
import
get_users_with_perms
from
dasf_broker
import
models
# noqa: F401
...
...
@@ -39,12 +40,22 @@ class DASFTopicAdmin(GuardedModelAdmin):
search_fields
=
[
"
slug
"
,
"
consumer__username
"
,
"
consumer__email
"
,
"
consumer__first_name
"
,
"
consumer__last_name
"
,
]
list_display
=
[
"
slug
"
,
"
consumer
"
,
"
is_public
"
,
"
is_response_topic
"
]
list_display
=
[
"
slug
"
,
"
get_consumers
"
,
"
get_producers
"
,
"
is_public
"
,
"
is_response_topic
"
,
]
list_filter
=
[
"
is_public
"
,
"
is_response_topic
"
]
@admin.display
(
description
=
"
Consumer(s)
"
)
# type: ignore
def
get_consumers
(
self
,
obj
:
models
.
DASFTopic
):
return
"
,
"
.
join
(
map
(
str
,
get_users_with_perms
(
obj
,
"
can_consume
"
)))
@admin.display
(
description
=
"
Producer(s)
"
)
# type: ignore
def
get_producers
(
self
,
obj
:
models
.
DASFTopic
):
return
"
,
"
.
join
(
map
(
str
,
get_users_with_perms
(
obj
,
"
can_produce
"
)))
This diff is collapsed.
Click to expand it.
dasf_broker/consumers.py
+
4
−
4
View file @
7988af58
...
...
@@ -90,7 +90,7 @@ class TopicProducer(JsonWebsocketConsumer):
topic
=
DASFTopic
.
objects
.
create
(
slug
=
self
.
dasf_topic_slug
,
consumer
=
self
.
user
)
assign_perm
(
"
can_p
ublish
"
,
self
.
user
,
topic
)
assign_perm
(
"
can_p
roduce
"
,
self
.
user
,
topic
)
elif
not
app_settings
.
DASF_CREATE_TOPIC_ON_MESSAGE
:
ack
[
"
result
"
]
=
f
"
Topic
{
self
.
dasf_topic_slug
}
does not exist.
"
else
:
...
...
@@ -99,7 +99,7 @@ class TopicProducer(JsonWebsocketConsumer):
if
(
topic
is
not
None
and
topic
.
is_public
or
self
.
user
.
has_perm
(
"
dasf_broker.can_p
ublish
"
,
topic
)
or
self
.
user
.
has_perm
(
"
dasf_broker.can_p
roduce
"
,
topic
)
):
# create a topic for the response
...
...
@@ -113,7 +113,7 @@ class TopicProducer(JsonWebsocketConsumer):
for
user
in
get_users_with_perms
(
topic
,
"
dasf_broker.can_consume
"
):
assign_perm
(
"
can_p
ublish
"
,
user
,
response_topic
)
assign_perm
(
"
can_p
roduce
"
,
user
,
response_topic
)
async_to_sync
(
self
.
channel_layer
.
group_send
)(
f
"
dasf_topic_
{
self
.
dasf_topic_slug
}
"
,
...
...
@@ -156,7 +156,7 @@ class TopicConsumer(JsonWebsocketConsumer):
if
(
topic
is
not
None
and
topic
.
is_public
or
self
.
user
.
has_perm
(
"
dasf_broker.can_p
ublish
"
,
topic
)
or
self
.
user
.
has_perm
(
"
dasf_broker.can_p
roduce
"
,
topic
)
):
if
topic
.
is_response_topic
:
topic
.
delete
()
...
...
This diff is collapsed.
Click to expand it.
dasf_broker/models.py
+
2
−
2
View file @
7988af58
...
...
@@ -38,8 +38,8 @@ class DASFTopic(models.Model):
class
Meta
:
permissions
=
(
(
"
can_p
ublish
"
,
"
Can publish
data
to the topic.
"
),
(
"
can_consume
"
,
"
Can consume messages to th
is
topic.
"
),
(
"
can_p
roduce
"
,
"
Can publish
messages
to the topic
(Producer)
.
"
),
(
"
can_consume
"
,
"
Can consume messages to th
e
topic
(Consumer)
.
"
),
)
slug
=
models
.
SlugField
(
...
...
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