bornhack-website/src/teams/models.py

413 lines
13 KiB
Python
Raw Normal View History

2018-07-02 21:52:52 +00:00
import logging
from django.conf import settings
2018-07-02 21:52:52 +00:00
from django.contrib.postgres.fields import DateTimeRangeField
from django.core.exceptions import ValidationError
from django.db import models
from django.urls import reverse_lazy
from django.utils.text import slugify
2018-08-14 18:13:46 +00:00
from utils.models import CampRelatedModel, CreatedUpdatedModel, UUIDModel
2018-07-02 21:52:52 +00:00
logger = logging.getLogger("bornhack.%s" % __name__)
2019-06-16 12:32:24 +00:00
TEAM_GUIDE_TEMPLATE = """
## Preparations
2017-11-25 21:35:48 +00:00
...
## Camp setup
2017-11-25 21:35:48 +00:00
...
## During camp
2017-11-25 21:35:48 +00:00
...
## Takedown
2017-11-25 21:35:48 +00:00
...
## Notes for next year
2017-11-25 21:35:48 +00:00
1. Remember to take notes
1. ...
"""
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
class Team(CampRelatedModel):
camp = models.ForeignKey(
2019-06-16 12:32:24 +00:00
"camps.Camp", related_name="teams", on_delete=models.PROTECT
)
2017-04-02 16:04:57 +00:00
2019-06-16 12:32:24 +00:00
name = models.CharField(max_length=255, help_text="The team name")
2017-04-02 16:04:57 +00:00
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
slug = models.SlugField(
max_length=255,
blank=True,
2019-06-16 12:32:24 +00:00
help_text="Url slug for this team. Leave blank to generate based on team name",
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
)
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
shortslug = models.SlugField(
2019-06-16 12:32:24 +00:00
help_text="Abbreviated version of the slug. Used in places like IRC channel names where space is limited"
)
2017-04-02 16:04:57 +00:00
description = models.TextField()
permission_set = models.CharField(
max_length=100,
blank=True,
default="",
help_text="The name of this Teams set of permissions. Must be a value from camps.models.Permission.Meta.permissions.",
)
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
needs_members = models.BooleanField(
2019-06-16 12:32:24 +00:00
default=True, help_text="Check to indicate that this team needs more members"
)
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
members = models.ManyToManyField(
2019-06-16 12:32:24 +00:00
"auth.User", related_name="teams", through="teams.TeamMember"
)
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
# mailing list related fields
2019-06-16 12:32:24 +00:00
mailing_list = models.EmailField(blank=True)
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
mailing_list_archive_public = models.BooleanField(
2019-06-16 12:32:24 +00:00
default=False, help_text="Check if the mailing list archive is public"
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
)
mailing_list_nonmember_posts = models.BooleanField(
default=False,
2019-06-16 12:32:24 +00:00
help_text="Check if the mailinglist allows non-list-members to post",
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
)
# IRC related fields
public_irc_channel_name = models.CharField(
blank=True,
null=True,
unique=True,
max_length=50,
2019-06-16 12:32:24 +00:00
help_text="The public IRC channel for this team. Will be shown on the team page so people know how to reach the team. Leave empty if the team has no public IRC channel.",
)
public_irc_channel_bot = models.BooleanField(
default=False,
2019-06-16 12:32:24 +00:00
help_text="Check to make the bot join the teams public IRC channel. Leave unchecked to disable the IRC bot for this channel.",
)
public_irc_channel_managed = models.BooleanField(
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
default=False,
2019-06-16 12:32:24 +00:00
help_text="Check to make the bot manage the teams public IRC channel by registering it with NickServ and setting +Oo for all teammembers.",
)
public_irc_channel_fix_needed = models.BooleanField(
default=False,
2019-06-16 12:32:24 +00:00
help_text="Used to indicate to the IRC bot that this teams public IRC channel is in need of a permissions and ACL fix.",
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
)
private_irc_channel_name = models.CharField(
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
blank=True,
null=True,
unique=True,
max_length=50,
2019-06-16 12:32:24 +00:00
help_text="The private IRC channel for this team. Will be shown to team members on the team page. Leave empty if the team has no private IRC channel.",
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
)
private_irc_channel_bot = models.BooleanField(
default=False,
2019-06-16 12:32:24 +00:00
help_text="Check to make the bot join the teams private IRC channel. Leave unchecked to disable the IRC bot for this channel.",
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
)
private_irc_channel_managed = models.BooleanField(
default=False,
2019-06-16 12:32:24 +00:00
help_text="Check to make the bot manage the private IRC channel by registering it with NickServ, setting +I and maintaining the ACL.",
)
private_irc_channel_fix_needed = models.BooleanField(
default=False,
2019-06-16 12:32:24 +00:00
help_text="Used to indicate to the IRC bot that this teams private IRC channel is in need of a permissions and ACL fix.",
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
)
2018-07-02 21:52:52 +00:00
shifts_enabled = models.BooleanField(
default=False,
2019-06-16 12:32:24 +00:00
help_text="Does this team have shifts? This enables defining shifts for this team.",
2018-07-02 21:52:52 +00:00
)
class Meta:
2019-06-16 12:32:24 +00:00
ordering = ["name"]
unique_together = (("name", "camp"), ("slug", "camp"))
2017-11-25 21:35:48 +00:00
guide = models.TextField(
blank=True,
help_text="HowTo guide for this year (and next year)",
verbose_name="team guide (Markdown)",
default=TEAM_GUIDE_TEMPLATE,
)
def __str__(self):
2019-06-16 12:32:24 +00:00
return "{} ({})".format(self.name, self.camp)
def get_absolute_url(self):
2019-06-16 12:32:24 +00:00
return reverse_lazy(
"teams:general",
kwargs={"camp_slug": self.camp.slug, "team_slug": self.slug},
)
def save(self, **kwargs):
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
# generate slug if needed
if not self.pk or not self.slug:
slug = slugify(self.name)
self.slug = slug
# set shortslug if needed
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
if not self.shortslug:
self.shortslug = self.slug
super().save(**kwargs)
2017-04-02 16:04:57 +00:00
def clean(self):
# make sure the public irc channel name is prefixed with a # if it is set
if self.public_irc_channel_name and self.public_irc_channel_name[0] != "#":
self.public_irc_channel_name = "#%s" % self.public_irc_channel_name
# make sure the private irc channel name is prefixed with a # if it is set
if self.private_irc_channel_name and self.private_irc_channel_name[0] != "#":
self.private_irc_channel_name = "#%s" % self.private_irc_channel_name
# make sure the channel names are not reserved
2019-06-16 12:32:24 +00:00
if (
self.public_irc_channel_name == settings.IRCBOT_PUBLIC_CHANNEL
or self.public_irc_channel_name == settings.IRCBOT_VOLUNTEER_CHANNEL
):
raise ValidationError("The public IRC channel name is reserved")
if (
self.private_irc_channel_name == settings.IRCBOT_PUBLIC_CHANNEL
or self.private_irc_channel_name == settings.IRCBOT_VOLUNTEER_CHANNEL
):
raise ValidationError("The private IRC channel name is reserved")
# make sure public_irc_channel_name is not in use as public or private irc channel for another team, case insensitive
if self.public_irc_channel_name:
2019-06-16 12:32:24 +00:00
if (
Team.objects.filter(
private_irc_channel_name__iexact=self.public_irc_channel_name
)
.exclude(pk=self.pk)
.exists()
or Team.objects.filter(
public_irc_channel_name__iexact=self.public_irc_channel_name
)
.exclude(pk=self.pk)
.exists()
):
raise ValidationError(
"The public IRC channel name is already in use on another team!"
)
# make sure private_irc_channel_name is not in use as public or private irc channel for another team, case insensitive
if self.private_irc_channel_name:
2019-06-16 12:32:24 +00:00
if (
Team.objects.filter(
private_irc_channel_name__iexact=self.private_irc_channel_name
)
.exclude(pk=self.pk)
.exists()
or Team.objects.filter(
public_irc_channel_name__iexact=self.private_irc_channel_name
)
.exclude(pk=self.pk)
.exists()
):
raise ValidationError(
"The private IRC channel name is already in use on another team!"
)
2017-04-02 16:04:57 +00:00
@property
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
def memberships(self):
"""
Returns all TeamMember objects for this team.
Use self.members.all() to get User objects for all members,
or use self.memberships.all() to get TeamMember objects for all members.
"""
2019-06-16 12:32:24 +00:00
return TeamMember.objects.filter(team=self)
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
@property
def approved_members(self):
"""
Returns only approved members (returns User objects, not TeamMember objects)
"""
2019-06-16 12:32:24 +00:00
return self.members.filter(teammember__approved=True)
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
@property
def unapproved_members(self):
"""
Returns only unapproved members (returns User objects, not TeamMember objects)
"""
2019-06-16 12:32:24 +00:00
return self.members.filter(teammember__approved=False)
2017-04-02 16:04:57 +00:00
@property
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
def responsible_members(self):
"""
Return only approved and responsible members
Used to handle permissions for team management
"""
return self.members.filter(
2019-06-16 12:32:24 +00:00
teammember__approved=True, teammember__responsible=True
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
)
2017-07-11 20:50:31 +00:00
@property
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
def regular_members(self):
"""
Return only approved and not responsible members with
an approved public_credit_name.
Used on the people pages.
"""
return self.members.filter(
2019-06-16 12:32:24 +00:00
teammember__approved=True, teammember__responsible=False
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
)
2017-07-11 20:50:31 +00:00
@property
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
def unnamed_members(self):
"""
Returns only approved and not responsible members,
without an approved public_credit_name.
"""
return self.members.filter(
teammember__approved=True,
teammember__responsible=False,
2019-06-16 12:32:24 +00:00
profile__public_credit_name_approved=False,
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
)
2017-07-11 20:50:31 +00:00
2017-04-02 16:04:57 +00:00
2017-05-23 19:21:47 +00:00
class TeamMember(CampRelatedModel):
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
user = models.ForeignKey(
2019-06-16 12:32:24 +00:00
"auth.User",
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
on_delete=models.PROTECT,
help_text="The User object this team membership relates to",
)
team = models.ForeignKey(
2019-06-16 12:32:24 +00:00
"teams.Team",
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
on_delete=models.PROTECT,
2019-06-16 12:32:24 +00:00
help_text="The Team this membership relates to",
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
)
approved = models.BooleanField(
2019-06-16 12:32:24 +00:00
default=False, help_text="True if this membership is approved. False if not."
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
)
responsible = models.BooleanField(
default=False,
2019-06-16 12:32:24 +00:00
help_text="True if this teammember is responsible for this Team. False if not.",
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
)
irc_acl_fix_needed = models.BooleanField(
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
default=False,
2019-06-16 12:32:24 +00:00
help_text="Maintained by the IRC bot, manual editing should not be needed. Will be set to true when a teammember sets or changes NickServ username, and back to false after the ACL has been fixed by the bot.",
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
)
class Meta:
2019-06-16 12:32:24 +00:00
ordering = ["-responsible", "-approved"]
def __str__(self):
2019-06-16 12:32:24 +00:00
return "{} is {} {} member of team {}".format(
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
self.user,
2019-06-16 12:32:24 +00:00
"" if self.approved else "an unapproved",
"" if not self.responsible else "a responsible",
self.team,
)
2017-04-02 16:04:57 +00:00
2017-05-23 19:21:47 +00:00
@property
def camp(self):
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
""" All CampRelatedModels must have a camp FK or a camp property """
2017-05-23 19:21:47 +00:00
return self.team.camp
2019-06-16 12:32:24 +00:00
camp_filter = "team__camp"
2017-11-23 22:09:14 +00:00
class TeamTask(CampRelatedModel):
team = models.ForeignKey(
2019-06-16 12:32:24 +00:00
"teams.Team",
related_name="tasks",
2018-03-04 15:26:35 +00:00
on_delete=models.PROTECT,
2019-06-16 12:32:24 +00:00
help_text="The team this task belongs to",
2017-11-23 22:09:14 +00:00
)
2019-06-16 12:32:24 +00:00
name = models.CharField(max_length=100, help_text="Short name of this task")
2017-11-23 22:09:14 +00:00
slug = models.SlugField(
2019-06-16 12:32:24 +00:00
max_length=255, blank=True, help_text="url slug, leave blank to autogenerate"
2017-11-23 22:09:14 +00:00
)
description = models.TextField(
2019-06-16 12:32:24 +00:00
help_text="Description of the task. Markdown is supported."
2017-11-23 22:09:14 +00:00
)
when = DateTimeRangeField(
blank=True,
null=True,
2019-06-16 12:32:24 +00:00
help_text="When does this task need to be started and/or finished?",
)
completed = models.BooleanField(
2019-06-16 12:32:24 +00:00
help_text="Check to mark this task as completed.", default=False
)
2017-11-23 22:09:14 +00:00
class Meta:
2019-06-16 12:32:24 +00:00
ordering = ["completed", "when", "name"]
unique_together = (("name", "team"), ("slug", "team"))
2017-11-23 22:09:14 +00:00
2017-11-25 12:02:32 +00:00
def get_absolute_url(self):
2019-06-16 12:32:24 +00:00
return reverse_lazy(
"teams:task_detail",
kwargs={
"camp_slug": self.team.camp.slug,
"team_slug": self.team.slug,
"slug": self.slug,
},
)
2017-11-25 12:02:32 +00:00
2017-11-23 22:09:14 +00:00
@property
def camp(self):
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
""" All CampRelatedModels must have a camp FK or a camp property """
2017-11-23 22:09:14 +00:00
return self.team.camp
2019-06-16 12:32:24 +00:00
camp_filter = "team__camp"
2017-11-23 22:09:14 +00:00
def save(self, **kwargs):
Merge teamcomms branch. Refactor team app and add events app. * Primary commit towards improved team communications. Add new events app to handle team notifications when various events happen, with a Type model which contain event types and a Routing model which controls routing of events to teams. Add shortslug for Camp and Team models. events.handler.py contains the code for sending irc and email notifications for teams. The first two eventtypes have been added in datamigrations, 'ticket_created' and 'public_credit_name_changed', and the tickets and profile apps have been adjusted accordingly. Team IRC channels can be marked as managed and if so the IRC bot will register the team channel with ChanServ if possible. Team IRC channels can be marked as private and the bot will set invite only and maintain an ACL with team members. Users can set their NickServ username in their profile to get on the ACL. Rework all team views and templates. Remove TeamArea model and make Team have an FK to Camp directly. Add docstrings a whole bunch of places. Move signal handlers to apps.py and signal_handlers.py in a few apps. Add basic team mailing list handling, more work to be done. Update bootstrap-devsite script to add more teammembers and add some team event routing for the two eventtypes we have. * default to the console backend for email unless we specifically ask for realworld email * fix signal for public_credit_name approval irc message * fix name display on /people/ page * fix the text on people pages when all non-responsible team members are anonymous * handle cases where we fallback to the area responsible properly * readd removed property, it is used in team_detail view * make it possible to filter profiles by public_credit_name_approved * add method for sending IRC messages in ircbot.utils.add_irc_message(), extend periodic bot method to do more than check for outgoing messages so rename it, refactor chanserv and nickserv handling code, create methods to check and join/part IRC channels as needed, maintain channel ACLs for private channels, do not autojoin any channels when instatiating the bot instead rely on the new check_irc_channels() method to join them, rename profile presave signal, add checking for changed nickserv usernames for acl handling, add teammember.irc_channel_acl_ok boolean to track ACL state, add missing help_text properties to TeamMember fields, rename teammember postsave signal, add teammember deleted signal, readd wrongly deleted EnsureTeamMemberResponsibleMixin * add a few missing early returns
2018-04-09 21:11:05 +00:00
# generate slug if needed
2017-11-23 22:09:14 +00:00
if not self.slug:
2017-11-25 12:02:32 +00:00
self.slug = slugify(self.name)
2017-11-23 22:09:14 +00:00
super().save(**kwargs)
2018-07-02 21:52:52 +00:00
2018-08-14 18:13:46 +00:00
class TaskComment(UUIDModel, CreatedUpdatedModel):
2019-06-16 12:32:24 +00:00
task = models.ForeignKey(
"teams.TeamTask", on_delete=models.PROTECT, related_name="comments"
)
author = models.ForeignKey("teams.TeamMember", on_delete=models.PROTECT)
2018-08-14 18:13:46 +00:00
comment = models.TextField()
2018-07-02 21:52:52 +00:00
class TeamShift(CampRelatedModel):
class Meta:
ordering = ("shift_range",)
2018-07-02 21:52:52 +00:00
team = models.ForeignKey(
2019-06-16 12:32:24 +00:00
"teams.Team",
related_name="shifts",
2018-07-02 21:52:52 +00:00
on_delete=models.PROTECT,
2019-06-16 12:32:24 +00:00
help_text="The team this shift belongs to",
2018-07-02 21:52:52 +00:00
)
shift_range = DateTimeRangeField()
2019-06-16 12:32:24 +00:00
team_members = models.ManyToManyField(TeamMember, blank=True)
2018-07-02 21:52:52 +00:00
2019-06-16 12:32:24 +00:00
people_required = models.IntegerField(default=1)
2018-07-02 21:52:52 +00:00
2017-11-24 21:06:23 +00:00
@property
2018-07-02 21:52:52 +00:00
def camp(self):
""" All CampRelatedModels must have a camp FK or a camp property """
return self.team.camp
2019-06-16 12:32:24 +00:00
camp_filter = "team__camp"
2018-08-05 16:21:30 +00:00
def __str__(self):
return "{} team shift from {} to {}".format(
2019-06-16 12:32:24 +00:00
self.team.name, self.shift_range.lower, self.shift_range.upper
2018-08-05 16:21:30 +00:00
)
2017-11-24 21:06:23 +00:00
2018-08-08 12:36:31 +00:00
@property
def users(self):
return [member.user for member in self.team_members.all()]