Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions buzz/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def after_install():
create_event_categories()
create_talk_proposal_statuses()
create_custom_fields()
create_administrator_team()


def on_migrate():
Expand All @@ -181,6 +182,12 @@ def on_migrate():
create_custom_fields()


def create_administrator_team():
"""Give a site without teams one owned by Administrator, so /b opens to the manager dashboard."""
if not frappe.db.exists("Buzz Team"):
create_default_team_for("Administrator")


def after_app_install(app_name: str):
if app_name == "zoom_integration":
create_zoom_integration_custom_fields()
Expand Down
1 change: 1 addition & 0 deletions buzz/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ buzz.patches.make_sponsor_logos_public
buzz.patches.set_event_venue_name
buzz.patches.move_sponsorship_tier_price_to_prices
buzz.patches.move_ticket_type_price_to_prices
buzz.patches.create_administrator_team
5 changes: 5 additions & 0 deletions buzz/patches/create_administrator_team.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from buzz.install import create_administrator_team


def execute():
create_administrator_team()
31 changes: 31 additions & 0 deletions buzz/test_default_team_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from frappe.tests import IntegrationTestCase

from buzz.events.doctype.buzz_team.test_buzz_team import create_user, payload_for
from buzz.install import create_administrator_team
from buzz.patches.assign_default_team import execute as backfill_teams
from buzz.patches.create_default_teams import execute as create_default_teams
from buzz.patches.create_default_teams import get_enabled_event_managers
Expand Down Expand Up @@ -163,3 +164,33 @@ def test_a_site_without_teamless_rows_gets_no_fallback_team(self):
backfill_teams()

self.assertEqual(frappe.db.count("Buzz Team"), teams)


class TestCreateAdministratorTeam(IntegrationTestCase):
def setUp(self):
frappe.set_user("Administrator")

def clear_teams(self):
frappe.db.savepoint("before_clearing_teams")
self.addCleanup(frappe.db.rollback, save_point="before_clearing_teams")
for doctype in ("Buzz Team Membership", "Buzz Team Settings", "Buzz Team"):
frappe.db.delete(doctype)

def test_a_site_without_teams_gets_one_owned_by_administrator(self):
self.clear_teams()

create_administrator_team()

team = frappe.db.get_value(
"Buzz Team Membership", {"user": "Administrator", "team_role": "Owner"}, "team"
)
self.assertTrue(team)
self.assertEqual(frappe.db.count("Buzz Team"), 1)

def test_a_site_with_teams_gets_no_new_team(self):
self.clear_teams()
frappe.get_doc({"doctype": "Buzz Team", "team_name": "Existing Team"}).insert()

create_administrator_team()

self.assertEqual(frappe.db.count("Buzz Team"), 1)
Loading