Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tenant.extra_email field to be used by add-on packages #228

Merged
merged 5 commits into from
Apr 23, 2024
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
15 changes: 14 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ development server. To workaround this issue, first generate an SSL certificate:

Then use the ``runerver_plus`` command to start Kiwi TCMS development server with HTTPS::

PYTHONPATH=../Kiwi/ KIWI_TENANTS_DOMAIN=tenant.example.bg ./manage.py runserver_plus --cert-file ssl/host.crt
PYTHONPATH=../Kiwi/ KIWI_TENANTS_DOMAIN=tenant.example.bg ./manage.py runserver_plus --cert-file ssl/host.crt --key-file ssl/host.key

Then point your browser to https://tenant.example.bg:8000/.
The SSL warning from the browser is expected!
Expand All @@ -145,6 +145,19 @@ You can use ``/etc/hosts`` to configure DNS resolution during development::
Changelog
---------

v2.7.0 (24 Apr 2024)
~~~~~~~~~~~~~~~~~~~~

- Add the ``Tenant.extra_emails`` field for storing information like
technical email, billing email, etc. To be used by add-on tools
- Add the ``initialize_tenants`` management command
- Update local development instructions
- Enable code formatting with ``black``
- Start testing using upstream Postgres container
- Execute CodeQL on pull request and branches
- Adjust tests for Django 5.0


v2.6.1 (08 Mar 2024)
~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_install_requires(path):

setup(
name="kiwitcms-tenants",
version="2.6.1",
version="2.7.0",
description="Multi-tenant support for Kiwi TCMS",
long_description=get_long_description(),
author="Kiwi TCMS",
Expand Down
1 change: 1 addition & 0 deletions tcms_tenants/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class TenantAdmin(admin.ModelAdmin):
"publicly_readable",
"paid_until",
"owner",
"extra_emails",
"organization",
)
search_fields = ("name", "schema_name", "organization")
Expand Down
4 changes: 4 additions & 0 deletions tcms_tenants/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class Meta:
organization = forms.CharField(
max_length=64, required=False, widget=forms.HiddenInput
)
extra_emails = forms.CharField(
max_length=256, required=False, widget=forms.HiddenInput
)


class InviteUsersForm(forms.Form): # pylint: disable=must-inherit-from-model-form
Expand Down Expand Up @@ -75,6 +78,7 @@ class UpdateTenantForm(NewTenantForm):
enabled_fields = (
"name",
"publicly_readable",
"extra_emails",
)

def __init__( # pylint: disable=too-many-arguments
Expand Down
4 changes: 4 additions & 0 deletions tcms_tenants/management/commands/initialize_tenants.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def handle(self, *args, **kwargs):
superuser.pk,
"--organization",
"Testing department",
"--extra_emails",
superuser.email,
"--domain-domain",
domain,
"--domain-is_primary",
Expand All @@ -64,6 +66,8 @@ def handle(self, *args, **kwargs):
superuser.pk,
"--organization",
"Kiwi TCMS",
"--extra_emails",
superuser.email,
"--domain-domain",
"empty.example.org",
"--domain-is_primary",
Expand Down
20 changes: 20 additions & 0 deletions tcms_tenants/migrations/0006_tenant_extra_emails.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 5.0.4 on 2024-04-23 19:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("tcms_tenants", "0005_rename_on_trial_to_public_read"),
]

operations = [
migrations.AddField(
model_name="tenant",
name="extra_emails",
field=models.CharField(
blank=True, db_index=True, max_length=256, null=True
),
),
]
6 changes: 5 additions & 1 deletion tcms_tenants/models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Copyright (c) 2019-2021 Alexander Todorov <[email protected]>
# Copyright (c) 2019-2024 Alexander Todorov <[email protected]>

# Licensed under the GPL 3.0: https://www.gnu.org/licenses/gpl-3.0.txt

import os

from django.db import models
from django.conf import settings

from django_tenants.models import TenantMixin, DomainMixin


Expand All @@ -22,6 +23,9 @@ class Tenant(TenantMixin):
settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="tenant_owner"
)
organization = models.CharField(max_length=64, null=True, blank=True, db_index=True)
extra_emails = models.CharField(
null=True, blank=True, db_index=True, max_length=256
)

def __str__(self):
return f"[{self.schema_name}] {self.name}"
Expand Down
Loading