Skip to content
Snippets Groups Projects
Commit 4ca23aa6 authored by Samuel GAIST's avatar Samuel GAIST Committed by Flavio TARSETTI
Browse files

[common][signals] Pre-commit cleanup

parent a7fe9952
No related branches found
No related tags found
2 merge requests!349Cleanup common,!342Django 3 migration
......@@ -27,4 +27,4 @@
import django.dispatch
shared = django.dispatch.Signal(providing_args=['users', 'teams'])
shared = django.dispatch.Signal(providing_args=["users", "teams"])
......@@ -25,20 +25,20 @@
# #
###############################################################################
from django.dispatch import receiver
from actstream import action
from django.contrib.auth.models import User
from django.db.models import Q
from actstream import action
from django.dispatch import receiver
from beat.web.team.models import Team
from ..models import Shareable
from ..signals import shared
def send_related_sharing(verb, sender, **kwargs):
users = kwargs.get('users')
teams = kwargs.get('teams')
users = kwargs.get("users")
teams = kwargs.get("teams")
author = sender.author
......@@ -53,8 +53,9 @@ def send_related_sharing(verb, sender, **kwargs):
db_users = User.objects.filter(username__in=users)
for user in db_users:
action.send(author, verb=verb, action_object=sender, target=user, public=False)
action.send(
author, verb=verb, action_object=sender, target=user, public=False
)
if teams is not None and len(teams) > 0:
# 'teams' might be a list of names or a list of DB objects
......@@ -67,7 +68,7 @@ def send_related_sharing(verb, sender, **kwargs):
for team_full_name in teams:
try:
username, teamname = team_full_name.split('/')
username, teamname = team_full_name.split("/")
except ValueError:
username = author
teamname = team_full_name
......@@ -81,16 +82,18 @@ def send_related_sharing(verb, sender, **kwargs):
db_teams = Team.objects.filter(query)
for team in db_teams:
action.send(author, verb=verb, action_object=sender, target=team, public=False)
action.send(
author, verb=verb, action_object=sender, target=team, public=False
)
@receiver(shared)
def on_shared(sender, **kwargs):
sharing = sender.sharing
verb = 'has done nothing'
verb = "has done nothing"
public = False
if hasattr(sender, 'author'):
if hasattr(sender, "author"):
if sharing == Shareable.PUBLIC:
verb = "has made public"
public = True
......@@ -117,4 +120,3 @@ def on_shared(sender, **kwargs):
verb = "was privatized"
action.send(sender, verb=verb, public=public)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment