mirror of
https://github.com/WeblateOrg/weblate.git
synced 2026-07-27 22:46:38 +08:00
Add workspaces as a top-level containers above projects and migrate billing to it. This does not add any new functionality just introduces the model and migrates billing to it. Issue #19535
35 lines
1.3 KiB
Python
Vendored
35 lines
1.3 KiB
Python
Vendored
# Copyright © Michal Čihař <michal@weblate.org>
|
|
#
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
"""Billing migration testing."""
|
|
|
|
from weblate.auth.data import SELECTION_ALL
|
|
from weblate.auth.models import Group, Permission, User, setup_project_groups
|
|
from weblate.billing.models import Billing, Plan
|
|
from weblate.trans.models import Project
|
|
|
|
# Create test users
|
|
user1 = User.objects.create(username="billingtest1")
|
|
user2 = User.objects.create(username="billingtest2")
|
|
user3 = User.objects.create(username="billingtest3")
|
|
|
|
# Create test billing
|
|
plan = Plan.objects.create(name="Basic plan", price=19, yearly_price=199)
|
|
billing = Billing.objects.create(plan=plan)
|
|
project = Project.objects.get(pk=1)
|
|
setup_project_groups(sender=Project, instance=project, created=True)
|
|
# This script runs before migration, against the older checked-out Weblate version.
|
|
billing.projects.add(project)
|
|
|
|
# Add user to per-project group
|
|
project.add_user(user1, "Billing")
|
|
|
|
# Create site-wide group and add both users
|
|
billing_group = Group.objects.create(
|
|
name="Global Billing", project_selection=SELECTION_ALL
|
|
)
|
|
billing_role = billing_group.roles.create(name="Test Role")
|
|
billing_role.permissions.add(Permission.objects.get(codename="billing.view"))
|
|
user1.groups.add(billing_group)
|
|
user2.groups.add(billing_group)
|