From a8cba2cbeafe594e5af91234e49dff8f263f5786 Mon Sep 17 00:00:00 2001
From: Diego Cepeda
Date: Fri, 15 Dec 2023 10:38:16 -0600
Subject: [PATCH] add a team description field [MYSQL SCHEMA CHANGE]
---
db/schema.v0.sql | 1 +
src/oncall/__init__.py | 2 +-
src/oncall/api/v0/team.py | 9 +++++----
src/oncall/api/v0/teams.py | 7 ++++---
src/oncall/ui/static/js/oncall.js | 5 +++++
src/oncall/ui/templates/base.html | 3 +++
src/oncall/ui/templates/index.html | 7 ++++++-
7 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/db/schema.v0.sql b/db/schema.v0.sql
index 81c9b38e..9afdc60a 100644
--- a/db/schema.v0.sql
+++ b/db/schema.v0.sql
@@ -7,6 +7,7 @@ USE `oncall`;
CREATE TABLE IF NOT EXISTS `team` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
+ `description` TEXT,
`slack_channel` VARCHAR(255),
`slack_channel_notifications` VARCHAR(255),
`email` VARCHAR(255),
diff --git a/src/oncall/__init__.py b/src/oncall/__init__.py
index 34c5111c..0b167e61 100644
--- a/src/oncall/__init__.py
+++ b/src/oncall/__init__.py
@@ -1 +1 @@
-__version__ = "2.0.5"
+__version__ = "2.1.5"
diff --git a/src/oncall/api/v0/team.py b/src/oncall/api/v0/team.py
index e006508b..bcc4b162 100644
--- a/src/oncall/api/v0/team.py
+++ b/src/oncall/api/v0/team.py
@@ -14,7 +14,7 @@
from ...constants import TEAM_DELETED, TEAM_EDITED, SUPPORTED_TIMEZONES
# Columns which may be modified
-cols = set(['name', 'slack_channel', 'slack_channel_notifications', 'email', 'scheduling_timezone',
+cols = set(['name', 'description', 'slack_channel', 'slack_channel_notifications', 'email', 'scheduling_timezone',
'iris_plan', 'iris_enabled', 'override_phone_number', 'api_managed_roster'])
@@ -58,7 +58,7 @@ def populate_team_rosters(cursor, team_dict):
def on_get(req, resp, team):
'''
Get team info by name. By default, only finds active teams. Allows selection of
- fields, including: users, admins, services, and rosters. If no ``fields`` is
+ fields, including: users, admins, services, descriptions, and rosters. If no ``fields`` is
specified in the query string, it defaults to all fields.
**Example request**
@@ -86,6 +86,7 @@ def on_get(req, resp, team):
"id": 5501,
"iris_plan": null,
"name": "team-foo",
+ "description": "this is an important team!",
"rosters": {
"roster-foo": {
"id": 4186,
@@ -148,7 +149,7 @@ def on_get(req, resp, team):
connection = db.connect()
cursor = connection.cursor(db.DictCursor)
cursor.execute('''SELECT `id`, `name`, `email`, `slack_channel`, `slack_channel_notifications`,
- `scheduling_timezone`, `iris_plan`, `iris_enabled`, `override_phone_number`, `api_managed_roster`
+ `scheduling_timezone`, `iris_plan`, `iris_enabled`, `override_phone_number`, `api_managed_roster`, `description`
FROM `team` WHERE `name`=%s AND `active` = %s''', (team, active))
results = cursor.fetchall()
if not results:
@@ -172,7 +173,7 @@ def on_get(req, resp, team):
@login_required
def on_put(req, resp, team):
'''
- Edit a team's information. Allows edit of: 'name', 'slack_channel', 'slack_channel_notifications', 'email', 'scheduling_timezone',
+ Edit a team's information. Allows edit of: 'name', 'description', 'slack_channel', 'slack_channel_notifications', 'email', 'scheduling_timezone',
'iris_plan', 'iris_enabled', 'override_phone_number', 'api_managed_roster'
**Example request:**
diff --git a/src/oncall/api/v0/teams.py b/src/oncall/api/v0/teams.py
index 4a96037f..a5c6a390 100755
--- a/src/oncall/api/v0/teams.py
+++ b/src/oncall/api/v0/teams.py
@@ -176,6 +176,7 @@ def on_post(req, resp):
raise HTTPBadRequest('invalid slack notifications channel',
'slack channel notifications name needs to start with #')
email = data.get('email')
+ description = data.get('description')
iris_plan = data.get('iris_plan')
iris_enabled = data.get('iris_enabled', False)
override_number = data.get('override_phone_number')
@@ -202,9 +203,9 @@ def on_post(req, resp):
try:
cursor.execute('''INSERT INTO `team` (`name`, `slack_channel`, `slack_channel_notifications`, `email`, `scheduling_timezone`,
- `iris_plan`, `iris_enabled`, `override_phone_number`)
- VALUES (%s, %s, %s, %s, %s, %s, %s, %s)''',
- (team_name, slack, slack_notifications, email, scheduling_timezone, iris_plan, iris_enabled, override_number))
+ `iris_plan`, `iris_enabled`, `override_phone_number`, `description`)
+ VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)''',
+ (team_name, slack, slack_notifications, email, scheduling_timezone, iris_plan, iris_enabled, override_number, description))
team_id = cursor.lastrowid
query = '''
diff --git a/src/oncall/ui/static/js/oncall.js b/src/oncall/ui/static/js/oncall.js
index 66e7e126..785f6e93 100644
--- a/src/oncall/ui/static/js/oncall.js
+++ b/src/oncall/ui/static/js/oncall.js
@@ -800,6 +800,7 @@ var oncall = {
$cta = $modal.find('.modal-cta'),
name = $form.find('#team-name').val().trim(),
email = $form.find('#team-email').val(),
+ description = $form.find('#team-description').val(),
slack = $form.find('#team-slack').val(),
slack_notifications = $form.find('#team-slack-notifications').val(),
timezone = $form.find('#team-timezone').val(),
@@ -839,6 +840,7 @@ var oncall = {
$cta = $modal.find('.modal-cta'),
name = $form.find('#team-name').val(),
email = $form.find('#team-email').val(),
+ description = $form.find('#team-description').val(),
slack = $form.find('#team-slack').val(),
slack_notifications = $form.find('#team-slack-notifications').val(),
timezone = $form.find('#team-timezone').val(),
@@ -866,6 +868,7 @@ var oncall = {
blankModel = {
name: name,
email: email,
+ description: description,
slack_channel: slack,
slack_channel_notifications: slack_notifications,
scheduling_timezone: timezone,
@@ -3099,6 +3102,7 @@ var oncall = {
$teamSlack = $modalForm.find('#team-slack'),
$teamSlackNotifications = $modalForm.find('#team-slack-notifications'),
$teamTimezone = $modalForm.find('#team-timezone'),
+ $teamDescription = $modalForm.find('#team-description'),
$teamNumber = $modalForm.find('#team-override-phone'),
$teamIrisPlan = $modalForm.find('#team-irisplan'),
$teamIrisEnabled = $modalForm.find('#team-iris-enabled'),
@@ -3114,6 +3118,7 @@ var oncall = {
$teamEmail.val($btn.attr('data-modal-email'));
$teamSlack.val($btn.attr('data-modal-slack'));
$teamSlackNotifications.val($btn.attr('data-modal-slack-notifications'));
+ $teamDescription.val($btn.attr('data-modal-description'));
$teamNumber.val($btn.attr('data-modal-override-phone'));
$teamIrisPlan.val($btn.attr('data-modal-irisplan'));
$teamIrisEnabled.prop('checked', $btn.attr('data-modal-iris-enabled') === '1');
diff --git a/src/oncall/ui/templates/base.html b/src/oncall/ui/templates/base.html
index cc53b1f1..a42551bd 100644
--- a/src/oncall/ui/templates/base.html
+++ b/src/oncall/ui/templates/base.html
@@ -142,6 +142,9 @@
{% endfor %}
+
+
+
Advanced
diff --git a/src/oncall/ui/templates/index.html b/src/oncall/ui/templates/index.html
index fba2fcb4..3fe5abd2 100644
--- a/src/oncall/ui/templates/index.html
+++ b/src/oncall/ui/templates/index.html
@@ -303,7 +303,7 @@