Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
django-branding / branding / fields.py
Size: Mime:
from django.db import models
from django.db.models import BLANK_CHOICE_DASH

from branding.models import FeatureAccess


class FeatureAccessField(models.CharField):
    def __init__(self, *args, **kwargs):
        kwargs["max_length"] = 20
        kwargs["default"] = ""
        kwargs["null"] = True
        kwargs["blank"] = True
        kwargs["choices"] = [("", "-")] + [(access.keyword, access.keyword) for access in FeatureAccess.objects.all()]
        super(FeatureAccessField, self).__init__(*args, **kwargs)

    def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH,
                    limit_choices_to=None):
        from branding.models import FeatureAccess
        return [("", "-")] + [(access.keyword, access.keyword) for access in FeatureAccess.objects.all()]