fix the irc acl method, indentation and too early return

This commit is contained in:
Thomas Steen Rasmussen 2018-04-13 21:29:19 +02:00
parent 43aefc880a
commit a978ccb6ea

View file

@ -309,15 +309,15 @@ class Plugin(object):
Loops over TeamMember objects and adds ACL entries as needed Loops over TeamMember objects and adds ACL entries as needed
Loops over Team objects and fixes permissions and ACLS as needed Loops over Team objects and fixes permissions and ACLS as needed
""" """
# first find all TeamMember objects which needs a loving hand
missing_acls = TeamMember.objects.filter( missing_acls = TeamMember.objects.filter(
irc_acl_fix_needed=True irc_acl_fix_needed=True
).exclude( ).exclude(
user__profile__nickserv_username='' user__profile__nickserv_username=''
) )
if not missing_acls: # loop over them and fix what needs to be fixed
return if missing_acls:
logger.debug("Found %s memberships which need IRC ACL fixing.." % missing_acls.count()) logger.debug("Found %s memberships which need IRC ACL fixing.." % missing_acls.count())
for membership in missing_acls: for membership in missing_acls:
# add to team public channel? # add to team public channel?
@ -347,10 +347,12 @@ class Plugin(object):
membership.irc_acl_fix_neede=False membership.irc_acl_fix_neede=False
membership.save() membership.save()
# loop over teams where the private channel needs fixing
for team in Team.objects.filter(private_irc_channel_fix_needed=True): for team in Team.objects.filter(private_irc_channel_fix_needed=True):
logger.debug("Team %s private IRC channel %s needs ACL fixing" % (team, team.private_irc_channel_name)) logger.debug("Team %s private IRC channel %s needs ACL fixing" % (team, team.private_irc_channel_name))
self.bot.setup_private_channel(team.private_irc_channel_name) self.bot.setup_private_channel(team.private_irc_channel_name)
# loop over teams where the public channel needs fixing
for team in Team.objects.filter(public_irc_channel_fix_needed=True): for team in Team.objects.filter(public_irc_channel_fix_needed=True):
logger.debug("Team %s public IRC channel %s needs ACL fixing" % (team, team.public_irc_channel_name)) logger.debug("Team %s public IRC channel %s needs ACL fixing" % (team, team.public_irc_channel_name))
self.bot.setup_public_channel(team.public_irc_channel_name) self.bot.setup_public_channel(team.public_irc_channel_name)