How to use the django.db.models.BooleanField function in Django

To help you get started, we’ve selected a few Django examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DrkSephy / technetium / technetium / technetium / bitbucket / models.py View on Github external
from django.contrib.auth.models import User
from django.db import models


class Subscription(models.Model):
    """
    Django Model for repository subscriptions.
    Foreign Key on User. Explanation and examples:
    """
    user = models.ForeignKey(User)
    repo_id = models.IntegerField(max_length=15)
    repository = models.CharField(max_length=100)
    slug_url = models.CharField(max_length=120)
    owner = models.CharField(max_length=50)
    subscribed = models.BooleanField(default=False)

    class Meta:
        unique_together = ('user', 'repo_id')
        verbose_name = "Repository Subscription"

    def __unicode__(self):
        return "%s: %s" % (self.user, self.repository)
github thehub / hubplus / apps / plus_contacts / models.py View on Github external
#from apps.plus_lib.countryfield import CountryField creates a circular import loop
CountryField = models.CharField

class Contact(models.Model):
    """Use this for the sign-up / invited sign-up process, provisional users"""
    first_name = models.CharField(max_length=60)
    last_name = models.CharField(max_length=60)
    email_address = models.CharField(max_length=255)  # unique=True) --> removing this requirement, I don't see why there can't be the same contact in more than user's contacts. Also it should be possible for a user to make more than one application e.g. to two different groups. We should then validate when creating users that the email address used isn't that of an existing user.
    organisation = models.CharField(max_length=255)
    address = models.CharField(null=True, max_length=300, default='') 
    country = CountryField(null=True, max_length=2, default='')
    post_or_zip = models.CharField(null=True, max_length=30, default="")
    find_out = models.TextField()
    
    has_accepted_application = models.BooleanField(default=False)
    user = models.ForeignKey(User, null=True, related_name="user_contacts")

    def get_display_name(self):
        return self.first_name + " " + self.last_name

    def get_user(self):
        if self.user:
            return self.user
        else:
            try:
                user_match = User.objects.get(email_address=self.email_address)
                self.user = user_match
                self.save()
                return self.user
            except User.DoesNotExist:
                return None
github squidsoup / django-crowdsourcing / crowdsourcing / models.py View on Github external
thanks = models.TextField(
        blank=True,
        help_text="When a user submits the survey, display this message.")

    require_login = models.BooleanField(default=False)
    allow_multiple_submissions = models.BooleanField(default=False)
    moderate_submissions = models.BooleanField(
        default=local_settings.MODERATE_SUBMISSIONS,
        help_text=_("If checked, all submissions will start as NOT public and "
                    "you will have to manually make them public. If your "
                    "survey doesn't show any results, it may be because this "
                    "option is checked."))
    allow_comments = models.BooleanField(
        default=False,
        help_text="Allow comments on user submissions.")
    allow_voting = models.BooleanField(
        default=False,
        help_text="Users can vote on submissions.")
    archive_policy = models.IntegerField(
        choices=ARCHIVE_POLICY_CHOICES,
        default=ARCHIVE_POLICY_CHOICES.IMMEDIATE,
        help_text=_("At what point will Crowdsourcing make the results "
                    "public? immediate: All results are immediately public. "
                    "post-close: Results are public on or after the "
                    "\"ends at\" option documented below. never: Results are "
                    "never public."))
    starts_at = models.DateTimeField(default=datetime.datetime.now)
    survey_date = models.DateField(blank=True, null=True, editable=False)
    ends_at = models.DateTimeField(null=True, blank=True)
    has_script = models.BooleanField(default=False,
                                     help_text="If enabled, template will render script tag for STATIC_URL/surveys/slug-name.js")
    is_published = models.BooleanField(default=False)
github ngageoint / scale / scale / recipe / models.py View on Github external
:keyword revision_num: The current revision number of the definition, starts at one
    :type revision_num: :class:`django.db.models.IntegerField`
    :keyword created: When the recipe type was created
    :type created: :class:`django.db.models.DateTimeField`
    :keyword deprecated: When the recipe type was deprecated (no longer active)
    :type deprecated: :class:`django.db.models.DateTimeField`
    :keyword last_modified: When the recipe type was last modified
    :type last_modified: :class:`django.db.models.DateTimeField`
    """

    name = models.CharField(unique=True, max_length=50)
    title = models.CharField(blank=True, max_length=50, null=True)
    description = models.CharField(blank=True, max_length=500, null=True)

    is_system = models.BooleanField(default=False)
    is_active = models.BooleanField(default=True)
    definition = django.contrib.postgres.fields.JSONField(default=dict)
    revision_num = models.IntegerField(default=1)

    created = models.DateTimeField(auto_now_add=True)
    deprecated = models.DateTimeField(blank=True, null=True)
    last_modified = models.DateTimeField(auto_now=True)

    objects = RecipeTypeManager()

    def get_definition(self):
        """Returns the definition for this recipe type

        :returns: The definition for this recipe type
        :rtype: :class:`recipe.definition.definition.RecipeDefinition`
        """
github MahjongRepository / mahjong-portal / server / online / models.py View on Github external
from django.contrib.postgres.fields import JSONField
from django.db import models

from mahjong_portal.models import BaseModel
from tournament.models import Tournament


class TournamentStatus(BaseModel):
    tournament = models.ForeignKey(Tournament, on_delete=models.CASCADE)

    current_round = models.PositiveSmallIntegerField(null=True, blank=True)
    end_break_time = models.DateTimeField(null=True, blank=True)
    registration_closed = models.BooleanField(default=False)

    def __unicode__(self):
        return self.tournament.name


class TournamentPlayers(BaseModel):
    tournament = models.ForeignKey(Tournament, on_delete=models.CASCADE)

    telegram_username = models.CharField(max_length=32, null=True, blank=True)
    discord_username = models.CharField(max_length=32, null=True, blank=True)
    tenhou_username = models.CharField(max_length=8)

    pantheon_id = models.PositiveIntegerField(null=True, blank=True)
    added_to_pantheon = models.BooleanField(default=False)
    enabled_in_pantheon = models.BooleanField(default=True)
github bethlakshmi / GBE2 / expo / gbe / migrations / 0013_conferenceday_open_to_public.py View on Github external
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('gbe', '0012_auto_20170705_2241'),
    ]

    operations = [
        migrations.AddField(
            model_name='conferenceday',
            name='open_to_public',
            field=models.BooleanField(default=True),
        ),
github onepercentclub / onepercentclub-site / apps / projects / models.py View on Github external
blank=True, null=True)

    video_url = models.URLField(
        _('video'), max_length=100, blank=True, null=True, default='',
        help_text=_("Do you have a video pitch or a short movie that "
                    "explains your project? Cool! We can't wait to see it! "
                    "You can paste the link to YouTube or Vimeo video here"))

    popularity = models.FloatField(null=False, default=0)
    is_campaign = models.BooleanField(default=False, help_text=_("Project is part of a campaign and gets special promotion."))

    skip_monthly = models.BooleanField(_("Skip monthly"),
                                       help_text=_("Skip this project when running monthly donations"),
                                       default=False)

    allow_overfunding = models.BooleanField(default=True)
    story = models.TextField(_("story"), help_text=_("This is the help text for the story field"), blank=True,
                             null=True)

    # TODO: Remove these fields?
    effects = models.TextField(_("effects"), help_text=_("What will be the Impact? How will your Smart Idea change the lives of people?"), blank=True, null=True)
    for_who = models.TextField(_("for who"), help_text=_("Describe your target group"), blank=True, null=True)
    future = models.TextField(_("future"), help_text=_("How will this project be self-sufficient and sustainable in the long term?"), blank=True, null=True)

    date_submitted = models.DateTimeField(_('Campaign Submitted'), null=True, blank=True)
    campaign_started = models.DateTimeField(_('Campaign Started'), null=True, blank=True)
    campaign_ended = models.DateTimeField(_('Campaign Ended'), null=True, blank=True)
    campaign_funded = models.DateTimeField(_('Campaign Funded'), null=True, blank=True)

    mchanga_account = models.CharField(_('M-Changa account'), help_text=_('Id or keyword for the M-Changa fundraiser'), max_length=100, null=True, blank=True)

    @property
github wagtail / wagtail / wagtail / core / migrations / 0001_squashed_0041.py View on Github external
('auth', '0001_initial'),
        ('contenttypes', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Page',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('path', models.CharField(max_length=255, unique=True)),
                ('depth', models.PositiveIntegerField()),
                ('numchild', models.PositiveIntegerField(default=0)),
                ('title', models.CharField(help_text="The page title as you'd like it to be seen by the public", max_length=255, verbose_name='title')),
                ('slug', models.SlugField(allow_unicode=True, help_text='The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/', max_length=255, verbose_name='slug')),
                ('live', models.BooleanField(default=True, editable=False, verbose_name='live')),
                ('has_unpublished_changes', models.BooleanField(default=False, editable=False, verbose_name='has unpublished changes')),
                ('url_path', models.TextField(blank=True, editable=False, verbose_name='URL path')),
                ('seo_title', models.CharField(blank=True, help_text="Optional. 'Search Engine Friendly' title. This will appear at the top of the browser window.", max_length=255, verbose_name='page title')),
                ('show_in_menus', models.BooleanField(default=False, help_text='Whether a link to this page will appear in automatically generated menus', verbose_name='show in menus')),
                ('search_description', models.TextField(blank=True, verbose_name='search description')),
                ('go_live_at', models.DateTimeField(blank=True, null=True, verbose_name='go live date/time')),
                ('expire_at', models.DateTimeField(blank=True, null=True, verbose_name='expiry date/time')),
                ('expired', models.BooleanField(default=False, editable=False, verbose_name='expired')),
                ('content_type', models.ForeignKey(on_delete=models.SET(wagtail.core.models.get_default_page_content_type), related_name='pages', to='contenttypes.ContentType', verbose_name='content type')),
                ('owner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='owned_pages', to=settings.AUTH_USER_MODEL, verbose_name='owner')),
                ('locked', models.BooleanField(default=False, editable=False, verbose_name='locked')),
                ('latest_revision_created_at', models.DateTimeField(editable=False, null=True, verbose_name='latest revision created at')),
                ('first_published_at', models.DateTimeField(blank=True, db_index=True, null=True, verbose_name='first published at')),
                ('draft_title', models.CharField(editable=False, max_length=255)),
                ('last_published_at', models.DateTimeField(editable=False, null=True, verbose_name='last published at')),
            ],
github MasterFacilityList / mfl_api / facilities / models / facility_models.py View on Github external
help_text="This field allows a more detailed description of how to"
        "locate the facility e.g Joy medical clinic is in Jubilee Plaza"
        "7th Floor")
    number_of_beds = models.PositiveIntegerField(
        default=0,
        help_text="The number of beds that a facilty has. e.g 0")
    number_of_cots = models.PositiveIntegerField(
        default=0,
        help_text="The number of cots that a facility has e.g 0")
    open_whole_day = models.BooleanField(
        default=False,
        help_text="Is the facility open 24 hours a day?")
    open_whole_week = models.BooleanField(
        default=False,
        help_text="Is the facility open the entire week?")
    is_classified = models.BooleanField(
        default=False,
        help_text="Should the facility geo-codes be visible to the public?"
        "Certain facilities are kept 'off-the-map'")
    is_published = models.BooleanField(
        default=False,
        help_text="Should be True if the facility is to be seen on the "
        "public MFL site")
    facility_type = models.OneToOneField(
        FacilityType,
        help_text="This depends on who owns the facilty. For MOH facilities,"
        "type is the gazetted classification of the facilty."
        "For Non-MOH check under the respective owners.",
        on_delete=models.PROTECT)
    operation_status = models.OneToOneField(
        FacilityStatus,
        help_text="Indicates whether the facility"