dashboard/constants.py
ZANATA_SLUGS = ('ZNTAPUB', 'ZNTAFED', 'ZNTAJBS', 'ZNTARHT', 'ZNTAVDR')
dashboard/models.py
class Package(ModelMixin, models.Model):
    """
    Packages Model
    """
    package_id = models.AutoField(primary_key=True)
    package_name = models.CharField(max_length=1000, unique=True, verbose_name="Package Name")
    upstream_name = models.CharField(max_length=1000, null=True, blank=True,
                                     verbose_name="Upstream Name")
    downstream_name = models.CharField(max_length=1000, null=True, blank=True,
                                       verbose_name="Downstream Name")
    component = models.CharField(max_length=200, null=True, blank=True, verbose_name="Component")
    upstream_url = models.URLField(max_length=2000, unique=True, verbose_name="Upstream URL")
    upstream_l10n_url = models.URLField(max_length=2000, null=True, blank=True,
                                        verbose_name="Upstream Localization URL")
    platform_slug = models.ForeignKey(
        Platform, on_delete=models.PROTECT,
        to_field='platform_slug', verbose_name="Translation Platform"
    )
    platform_name = models.CharField(max_length=1000, null=True, blank=True,
                                     verbose_name="Package Name at Translation Platform")
    # translation platform project http url
    platform_url = models.URLField(max_length=500, null=True, blank=True,
                                   verbose_name="Translation Platform Project URL")
    products = ArrayField(
        models.CharField(max_length=400, blank=True),
        default=list, null=True, verbose_name="Release Streams"
    )
    package_details_json_str = models.TextField(null=True, blank=True)
    details_json_last_updated = models.DateTimeField(null=True)
    package_name_mapping_json_str = models.TextField(null=True, blank=True)
    name_map_last_updated = models.DateTimeField(null=True, blank=True)
    release_branch_mapping = models.TextField(null=True, blank=True)
    release_branch_map_last_updated = models.DateTimeField(null=True, blank=True)
    package_latest_builds = models.TextField(null=True, blank=True)
    package_latest_builds_last_updated = models.DateTimeField(null=True, blank=True)
    stats_diff = models.TextField(null=True, blank=True)
    stats_diff_last_updated = models.DateTimeField(null=True, blank=True)
    platform_last_updated = models.DateTimeField(null=True, blank=True)
    upstream_last_updated = models.DateTimeField(null=True, blank=True)
    downstream_last_updated = models.DateTimeField(null=True, blank=True)
    translation_file_ext = models.CharField(
        max_length=10, null=True, blank=True, default='po',
        verbose_name="Translation Format (po)"
    )
    created_by = models.EmailField(null=True)
    maintainers = models.TextField(null=True, blank=True)

    @property
    def package_details_json(self):
        return self.str2json(self.package_details_json_str)

    @property
    def package_name_mapping_json(self):
        return self.str2json(self.package_name_mapping_json_str)

    @property
    def release_branch_mapping_json(self):
        return self.str2json(self.release_branch_mapping)

    @property
    def package_latest_builds_json(self):
        return self.str2json(self.package_latest_builds)

    @property
    def release_branch_mapping_health(self):
        release_branch_mapping_dict = \
            self.str2json(self.release_branch_mapping)
        if not release_branch_mapping_dict:
            return False
        for release, mapping in release_branch_mapping_dict.items():
            if isinstance(mapping, dict):
                for k, v in mapping.items():
                    if not mapping.get(k):
                        return False
        return True

    @property
    def stats_diff_json(self):
        return self.str2json(self.stats_diff)

    @property
    def stats_diff_health(self):
        stats_diff_dict = self.str2json(self.stats_diff)
        if not stats_diff_dict:
            return True
        for release, diff in stats_diff_dict.items():
            if stats_diff_dict.get(release):
                return False
        return True

    @property
    def maintainers_json(self):
        return self.str2json(self.maintainers)

    def __str__(self):
        return self.package_name

    class Meta:
        db_table = TABLE_PREFIX + 'packages'
        verbose_name = "Package"
dashboard/models.py
class Platform(ModelMixin, models.Model):
    """
    Translation Platforms Model
    """
    platform_id = models.AutoField(primary_key=True)
    engine_name = models.CharField(
        max_length=200, verbose_name="Platform Engine"
    )
    subject = models.CharField(
        max_length=200, null=True, verbose_name="Platform Subject"
    )
    api_url = models.URLField(max_length=500, unique=True, verbose_name="Server URL")
    platform_slug = models.CharField(
        max_length=400, unique=True, verbose_name="Platform SLUG"
    )
    server_status = models.BooleanField(verbose_name="Enable/Disable")
    ci_status = models.BooleanField(verbose_name="CI Enable/Disable", default=False)
    projects_json_str = models.TextField(null=True, blank=True)
    projects_last_updated = models.DateTimeField(null=True)
    auth_login_id = models.CharField(
        max_length=200, null=True, blank=True, verbose_name="Auth User"
    )
    auth_token_key = models.CharField(
        max_length=200, null=True, blank=True, verbose_name="Auth Password/Token"
    )
    token_api_json_str = models.TextField(null=True, blank=True, verbose_name="Auth Token JSON")
    token_expiry = models.DateTimeField(null=True, blank=True, verbose_name="Auth Token Expiry")

    @property
    def projects_json(self):
        return self.str2json(self.projects_json_str)

    @property
    def token_api_json(self):
        return self.str2json(self.token_api_json_str)

    @property
    def token_status(self):
        if not self.token_expiry:
            return
        return self.token_expiry > timezone.now()

    def __str__(self):
        return "{0} {1}".format(self.engine_name, self.subject)

    class Meta:
        db_table = TABLE_PREFIX + 'platforms'
        verbose_name = "Translation Platform"
dashboard/models.py
class Language(models.Model):
    """
    Language Model
    """
    locale_id = models.CharField(
        max_length=50, primary_key=True, verbose_name="Locale ID"
    )
    lang_name = models.CharField(
        max_length=400, unique=True, verbose_name="Language Name"
    )
    locale_alias = models.CharField(
        max_length=50, unique=True, null=True, blank=True, verbose_name="Locale Alias"
    )
    locale_script = models.CharField(
        max_length=100, null=True, blank=True, verbose_name="Locale Script"
    )
    lang_status = models.BooleanField(verbose_name="Enable/Disable")

    def __str__(self):
        return self.lang_name

    class Meta:
        db_table = TABLE_PREFIX + 'languages'
        verbose_name = "Language"
dashboard/models.py
class Visitor(models.Model):
    """
    Visitors Model
    """
    visitor_id = models.AutoField(primary_key=True)
    visitor_ip = models.GenericIPAddressField()
    visitor_user_agent = models.CharField(max_length=500)
    visitor_accept = models.CharField(max_length=500, null=True, blank=True)
    visitor_encoding = models.CharField(max_length=500, null=True, blank=True)
    visitor_language = models.CharField(max_length=500, null=True, blank=True)
    visitor_host = models.CharField(max_length=500, null=True, blank=True)
    first_visit_time = models.DateTimeField()
    last_visit_time = models.DateTimeField()

    def save(self, *args, **kwargs):
        if not self.visitor_id:
            self.first_visit_time = timezone.now()
        self.last_visit_time = timezone.now()
        return super(Visitor, self).save(*args, **kwargs)

    def __str__(self):
        return "%s: %s" % (str(self.visitor_ip), self.visitor_user_agent)

    class Meta:
        db_table = TABLE_PREFIX + 'visitors'
        verbose_name = "Visitor"
dashboard/models.py
class Release(ModelMixin, models.Model):
    """
    Releases Model
    """
    release_id = models.AutoField(primary_key=True)
    release_name = models.CharField(max_length=500, verbose_name="Release Name")
    release_slug = models.CharField(max_length=500, unique=True, verbose_name="Release SLUG")
    product_slug = models.ForeignKey(
        Product, on_delete=models.PROTECT,
        to_field='product_slug', verbose_name="Product"
    )
    language_set_slug = models.ForeignKey(
        LanguageSet, on_delete=models.PROTECT,
        to_field='lang_set_slug', verbose_name="Language Set"
    )
    scm_branch = models.CharField(max_length=100, null=True, blank=True, verbose_name="SCM Branch Name")
    created_on = models.DateTimeField()
    current_phase = models.CharField(max_length=200, null=True, verbose_name="Current Phase")
    calendar_url = models.URLField(max_length=500, unique=True, null=True, verbose_name="Calender iCal URL")
    schedule_json_str = models.TextField(null=True, blank=True)
    sync_calendar = models.BooleanField(default=True, verbose_name="Sync Calender")
    notifications_flag = models.BooleanField(default=True, verbose_name="Notification")
    track_trans_flag = models.BooleanField(default=True, verbose_name="Track Translation")
    created_by = models.EmailField(null=True)

    @property
    def schedule_json(self):
        return self.str2json(self.schedule_json_str)

    def __str__(self):
        return self.release_name

    class Meta:
        db_table = TABLE_PREFIX + 'releases'
        verbose_name_plural = "Release"
dashboard/models.py
class Product(models.Model):
    """
    Product Model
    """
    product_id = models.AutoField(primary_key=True)
    product_name = models.CharField(
        max_length=200, verbose_name="Product Name"
    )
    product_slug = models.CharField(
        max_length=400, unique=True, verbose_name="Product SLUG"
    )
    product_url = models.URLField(
        max_length=500, unique=True, verbose_name="Product URL", null=True
    )
    product_api_url = models.URLField(
        max_length=500, verbose_name="Product API URL", null=True
    )
    product_server = models.URLField(
        max_length=500, verbose_name="Product Server"
    )
    product_build_system = models.CharField(
        max_length=200, null=True, verbose_name="Release Build System"
    )
    product_build_tags = ArrayField(
        models.CharField(max_length=200, blank=True),
        default=list, null=True, verbose_name="Release Build Tags"
    )
    product_build_tags_last_updated = models.DateTimeField(null=True)
    src_pkg_format = models.CharField(
        max_length=50, null=True, verbose_name="Source Package Format"
    )
    top_url = models.URLField(max_length=500, verbose_name="Top URL")
    web_url = models.URLField(max_length=500, null=True, verbose_name="Web URL")
    krb_service = models.CharField(
        max_length=200, null=True, blank=True, verbose_name="Kerberos Service"
    )
    auth_type = models.CharField(max_length=200, null=True, blank=True, verbose_name="Auth Type")
    amqp_server = models.CharField(
        max_length=500, null=True, blank=True, verbose_name="AMQP Server"
    )
    msgbus_exchange = models.CharField(
        max_length=200, null=True, blank=True, verbose_name="Message Bus Exchange"
    )
    major_milestones = ArrayField(
        models.CharField(max_length=1000, blank=True),
        default=list, null=True, verbose_name="Major Milestones"
    )
    product_phases = ArrayField(
        models.CharField(max_length=200, blank=True),
        default=list, null=True, verbose_name="Release Stream Phases"
    )
    product_status = models.BooleanField(verbose_name="Enable/Disable")

    def __str__(self):
        return self.product_name

    class Meta:
        db_table = TABLE_PREFIX + 'products'
        verbose_name = "Product"
dashboard/constants.py
TRANSIFEX_SLUGS = ('TNFXPUB', )
dashboard/constants.py
RELSTREAM_SLUGS = ('RHEL', 'fedora', 'RHV', 'satellite')
dashboard/models.py
class CIPipeline(ModelMixin, models.Model):
    """
    Continuous Integration Pipeline Model
    """
    ci_pipeline_id = models.AutoField(primary_key=True)
    ci_pipeline_uuid = models.UUIDField(default=uuid4, unique=True, editable=False)
    ci_package = models.ForeignKey(
        Package, on_delete=models.PROTECT, verbose_name="Package"
    )
    ci_platform = models.ForeignKey(
        Platform, on_delete=models.PROTECT, verbose_name="Platform"
    )
    ci_release = models.ForeignKey(
        Release, on_delete=models.PROTECT, verbose_name="Release", null=True
    )
    ci_push_job_template = models.ForeignKey(
        JobTemplate, on_delete=models.PROTECT, verbose_name="Push Job Template",
        related_name="push_template", null=True
    )
    ci_pull_job_template = models.ForeignKey(
        JobTemplate, on_delete=models.PROTECT, verbose_name="Pull Job Template",
        related_name="pull_template", null=True
    )
    ci_project_web_url = models.URLField(max_length=500, null=True, blank=True,
                                         verbose_name="Platform Project URL")
    ci_project_details_json_str = models.TextField(null=True, blank=True)
    ci_platform_jobs_json_str = models.TextField(null=True, blank=True)
    ci_project_analyses_json_str = models.TextField(null=True, blank=True)
    ci_project_import_settings_json_str = models.TextField(null=True, blank=True)
    ci_project_assign_templates_json_str = models.TextField(null=True, blank=True)
    ci_project_workflow_steps_json_str = models.TextField(null=True, blank=True)
    ci_project_providers_json_str = models.TextField(null=True, blank=True)
    ci_project_term_bases_json_str = models.TextField(null=True, blank=True)
    ci_project_qa_checks_json_str = models.TextField(null=True, blank=True)
    ci_project_trans_memory_json_str = models.TextField(null=True, blank=True)
    ci_pipeline_last_updated = models.DateTimeField(null=True, blank=True)
    ci_pipeline_visibility = models.BooleanField(
        default=True, verbose_name='CI Pipeline Visibility'
    )

    @property
    def ci_project_details_json(self):
        return self.str2json(self.ci_project_details_json_str)

    @property
    def ci_platform_jobs_json(self):
        return self.str2json(self.ci_platform_jobs_json_str)

    @property
    def ci_project_analyses_json(self):
        return self.str2json(self.ci_project_analyses_json_str)

    @property
    def ci_project_import_settings_json(self):
        return self.str2json(self.ci_project_import_settings_json_str)

    @property
    def ci_project_assign_templates_json(self):
        return self.str2json(self.ci_project_assign_templates_json_str)

    @property
    def ci_project_workflow_steps_json(self):
        return self.str2json(self.ci_project_workflow_steps_json_str)

    @property
    def ci_project_providers_json(self):
        return self.str2json(self.ci_project_providers_json_str)

    @property
    def ci_project_term_bases_json(self):
        return self.str2json(self.ci_project_term_bases_json_str)

    @property
    def ci_project_qa_checks_json(self):
        return self.str2json(self.ci_project_qa_checks_json_str)

    @property
    def ci_project_trans_memory_json(self):
        return self.str2json(self.ci_project_trans_memory_json_str)

    def __str__(self):
        return "{} | {}".format(
            str(self.ci_pipeline_uuid)[:8],
            self.ci_package.package_name
        )

    class Meta:
        db_table = TABLE_PREFIX + 'cipipeline'
        verbose_name = "CI Pipeline"
dashboard/constants.py
MEMSOURCE_SLUGS = ('MSRCPUB', )
dashboard/constants.py
TRANSPLATFORM_ENGINES = ('damnedlies', 'transifex', 'zanata', 'weblate', 'memsource')
dashboard/constants.py
WEBLATE_SLUGS = ('WLTEPUB', 'WLTEFED')
dashboard/constants.py
DAMNEDLIES_SLUGS = ('DMLSPUB', )
dashboard/models.py
class LanguageSet(models.Model):
    """
    Language Set Model
    """
    lang_set_id = models.AutoField(primary_key=True)
    lang_set_name = models.CharField(
        max_length=1000, verbose_name="Language Set Name"
    )
    lang_set_slug = models.CharField(
        max_length=400, unique=True, verbose_name="Language Set SLUG"
    )
    lang_set_color = models.CharField(
        max_length=100, unique=True, verbose_name="Tag Colour"
    )
    locale_ids = ArrayField(
        models.CharField(max_length=50, blank=True),
        default=list, null=True, verbose_name="Locale IDs"
    )

    def __str__(self):
        return self.lang_set_name

    class Meta:
        db_table = TABLE_PREFIX + 'langset'
        verbose_name = "Language Set"


Question: from django import forms
from django.contrib import admin
from dashboard.forms import TextArrayField
from dashboard.constants import (
    TRANSPLATFORM_ENGINES, RELSTREAM_SLUGS, TRANSIFEX_SLUGS, ZANATA_SLUGS,
    DAMNEDLIES_SLUGS, WEBLATE_SLUGS, MEMSOURCE_SLUGS
)
from dashboard.models import (
    Language, LanguageSet, Platform, Product, Release,
    Package, Visitor, CIPipeline
)
from dashboard.managers.inventory import InventoryManager
# Copyright 2016 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

# django

# dashboard

ENGINE_CHOICES = tuple([(engine, engine.upper())
                        for engine in TRANSPLATFORM_ENGINES])

RELSTR_CHOICES = tuple([(relstream, relstream)
                        for relstream in RELSTREAM_SLUGS])

all_platform_slugs = []

Answer: all_platform_slugs.extend(TRANSIFEX_SLUGS)