How to use the django.db.models.TextField 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 aparsons / bag-of-holding / project / boh / models.py View on Github external
if date.today() >= self.engagement.start_date:
                return True
        return False

    def is_past_due(self):
        """If the activity is not closed by the parent engagement's end date."""
        if self.status == Activity.PENDING_STATUS or self.status == Activity.OPEN_STATUS:
            if date.today() > self.engagement.end_date:
                return True
        return False


class Comment(TimeStampedModel, models.Model):
    """Abstract message about an engagement or activity."""

    message = models.TextField()

    user = models.ForeignKey(settings.AUTH_USER_MODEL)

    def __str__(self):
        return self.message

    class Meta:
        abstract = True


class EngagementComment(Comment):
    """Comment for a specific engagement."""

    engagement = models.ForeignKey(Engagement)
github archerysec / archerysec / webscanners / models.py View on Github external
body = models.TextField(blank=True)
    false_positive = models.TextField(blank=True)
    cwe = models.TextField(blank=True)
    ref_key = models.TextField(blank=True)
    ref_value = models.TextField(blank=True)
    vector_input_key = models.TextField(blank=True)
    vector_input_values = models.TextField(blank=True)
    vector_source_key = models.TextField(blank=True)
    vector_source_values = models.TextField(blank=True)
    page_body_data = models.TextField(blank=True)
    request_url = models.TextField(blank=True)
    request_method = models.TextField(blank=True)
    request_raw = models.TextField(blank=True)
    response_ip = models.TextField(blank=True)
    response_raw_headers = models.TextField(blank=True)
    jira_ticket = models.TextField(null=True, blank=True)
    vuln_status = models.TextField(null=True, blank=True)
    dup_hash = models.TextField(null=True, blank=True)
    vuln_duplicate = models.TextField(null=True, blank=True)
    false_positive_hash = models.TextField(null=True, blank=True)
    scanner = models.TextField(default='Arachni', editable=False)


class task_schedule_db(models.Model):
    task_id = models.TextField(blank=True, null=True)
    target = models.TextField(blank=True, null=True)
    schedule_time = models.TextField(blank=True, null=True)
    project_id = models.TextField(blank=True, null=True)
    scanner = models.TextField(blank=True, null=True)
    periodic_task = models.TextField(blank=True, null=True)
github lino-framework / lino / lino / modlib / thirds / models.py View on Github external
from django.conf import settings

from lino.api import dd
from lino import mixins
from lino.modlib.contacts import models as contacts
from lino.modlib.gfks.mixins import Controllable


@dd.python_2_unicode_compatible
class Third(mixins.Sequenced, contacts.PartnerDocument, Controllable):

    class Meta(object):
        verbose_name = _("Third Party")
        verbose_name_plural = _('Third Parties')

    remark = models.TextField(_("Remark"), blank=True, null=True)

    def summary_row(self, ar, **kw):
        #~ s = ui.href_to(self)
        return ["(", str(self.seqno), ") "] + list(contacts.PartnerDocument.summary_row(self, ar, **kw))

    def __str__(self):
        return str(self.seqno)
        #~ return unicode(self.get_partner())


class Thirds(dd.Table):
    model = Third
    #~ order_by = ["modified"]
    column_names = "owner_type owner_id seqno person company *"
github ericls / FairyBBS / forum / models.py View on Github external
class mention(models.Model):
    sender = models.ForeignKey(User, related_name='sent_mentions')
    receiver = models.ForeignKey(User, related_name='received_mentions')
    post = models.ForeignKey(post, blank=True, null=True)
    topic = models.ForeignKey(topic, blank=True, null=True)
    content = models.TextField(blank=True, null=True)
    read = models.BooleanField(default=False)
    time_created = models.DateTimeField(auto_now_add=True)


class appendix(models.Model):
    topic = models.ForeignKey(topic)
    time_created = models.DateTimeField(auto_now_add=True)
    content = models.TextField()
    content_rendered = models.TextField()

    def __unicode__(self):
        return self.topic.title + '-Appendix'

    def save(self, *args, **kwargs):
        if not self.content:
            self.content = ''
        self.content_rendered = markdown.markdown(self.content, ['codehilite'],
                                                  safe_mode='escape')
        super(appendix, self).save(*args, **kwargs)
github mhacks / mhacks-admin / MHacks / models.py View on Github external
self.deleted = True
        from datetime import datetime
        from pytz import utc
        self.last_updated = datetime.now(tz=utc)
        self.save(using=using, update_fields=['deleted', 'last_updated'])
        return 1

    class Meta:
        abstract = True


class Floor(Any):
    name = models.CharField(max_length=60)
    index = models.IntegerField(unique=True)
    image = models.URLField()
    description = models.TextField(blank=True)
    offset_fraction = models.FloatField(default=1.0)
    aspect_ratio = models.FloatField(default=1.0)

    def __unicode__(self):
        return '{} displayed at index {}'.format(self.name, str(self.index))


class Location(Any):
    name = models.CharField(max_length=60)
    floor = models.ForeignKey(Floor, on_delete=models.PROTECT, null=True, blank=True)

    def __unicode__(self):
        if self.floor:
            return "{} on the {}".format(self.name, str(self.floor.name))
        return self.name
github 20tab / upy / upy / contrib / newsletter / models.py View on Github external
dig = hmac.new(b'%s' % settings.UPY_SECRET_KEY, msg=tohash, digestmod=hashlib.sha256).digest()
            self.secret_key = base64.b64encode(dig).decode().replace("/","_")
        super(Contact,self).save( *args, **kwargs)
    
    class Meta:
        verbose_name = _(u"Contact")
        verbose_name_plural = _(u"Contacts")
        ordering = [u'email',u'surname',u'name']


class List(UPYNL):
    """
    A list groupes some contacts
    """
    name = models.CharField(max_length = 150, help_text = _(u"Insert list's name"), verbose_name = _(u"Name"))
    description = models.TextField(null = True, blank = True, help_text = _(u"Set list's description"), 
                                    verbose_name = _(u"Description"))
    priority = models.CharField(max_length = 150, help_text = _(u"Set list's priority"), 
                                    verbose_name = _(u"Priority"), choices = ([("%s"% n,n) for n in range(1,11)]))
    contacts = models.ManyToManyField(u"Contact", help_text = _(u"A list of contacts to associate"), 
                                    verbose_name = _(u"Contacts"))
    publication =models.ForeignKey(Publication,  help_text = _(u"Set the Publication for this list"), 
                                    verbose_name = _(u"Publication"))
    test = models.BooleanField(default = False, help_text = _(u"Check if this list is a test list"),
                                verbose_name = _(u"Test"))
       
    def __unicode__(self):
        return u"%s" % (self.name)
    
    class Meta:
        verbose_name = _(u"List")
        verbose_name_plural = _(u"Lists")
github morlandi / django-task / example / tasks / migrations / 0001_initial.py View on Github external
},
        ),
        migrations.CreateModel(
            name='SendEmailTask',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True, verbose_name='id')),
                ('description', models.CharField(blank=True, max_length=256, verbose_name='description')),
                ('created_on', models.DateTimeField(auto_now_add=True, verbose_name='created on')),
                ('started_on', models.DateTimeField(null=True, verbose_name='started on')),
                ('completed_on', models.DateTimeField(null=True, verbose_name='completed on')),
                ('job_id', models.CharField(blank=True, max_length=128, verbose_name='job id')),
                ('status', models.CharField(choices=[('PENDING', 'PENDING'), ('RECEIVED', 'RECEIVED'), ('STARTED', 'STARTED'), ('PROGESS', 'PROGESS'), ('SUCCESS', 'SUCCESS'), ('FAILURE', 'FAILURE'), ('REVOKED', 'REVOKED'), ('REJECTED', 'REJECTED'), ('RETRY', 'RETRY'), ('IGNORED', 'IGNORED'), ('REJECTED', 'REJECTED')], db_index=True, default='PENDING', max_length=128, verbose_name='status')),
                ('mode', models.CharField(choices=[('UNKNOWN', 'UNKNOWN'), ('SYNC', 'SYNC'), ('ASYNC', 'ASYNC')], db_index=True, default='UNKNOWN', max_length=128, verbose_name='mode')),
                ('failure_reason', models.CharField(blank=True, max_length=256, verbose_name='failure reason')),
                ('progress', models.IntegerField(blank=True, null=True, verbose_name='progress')),
                ('log_text', models.TextField(blank=True, verbose_name='log text')),
                ('sender', models.CharField(max_length=256)),
                ('recipients', models.TextField(help_text='put addresses in separate rows')),
                ('subject', models.CharField(max_length=256)),
                ('message', models.TextField(blank=True)),
                ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ('-created_on',),
                'get_latest_by': 'created_on',
                'abstract': False,
            },
github theonion / django-bulbs / bulbs / sections / models.py View on Github external
from json_field import JSONField

from bulbs.content.custom_search import custom_search_model
from bulbs.content.models import Content, ElasticsearchImageField
from .managers import SectionIndexableManager, SectionManager


es = Elasticsearch(settings.ES_CONNECTIONS["default"]["hosts"])


class Section(Indexable):

    name = models.CharField(max_length=255, unique=True)
    slug = models.SlugField(max_length=255, blank=True, editable=True, unique=True)
    description = models.TextField(default="", blank=True)
    embed_code = models.TextField(default="", blank=True)
    section_logo = ImageField(null=True, blank=True)
    twitter_handle = models.CharField(max_length=255, blank=True)
    promoted = models.BooleanField(default=False)
    query = JSONField(default={}, blank=True)

    objects = SectionManager()
    search_objects = SectionIndexableManager()

    class Mapping:
        name = field.String(analyzer="autocomplete",
                            fields={"raw": field.String(index="not_analyzed")})
        slug = field.String(index="not_analyzed")
        section_logo = ElasticsearchImageField()
        query = field.Object(enabled=False)

    def __unicode__(self):
github bihealth / sodar_core / filesfolders / models.py View on Github external
elif self.folder:
            return self.folder.has_in_path(folder)

        return False


# File -------------------------------------------------------------------------


class FileData(models.Model):
    """Class for storing actual file data in the Postgres database, needed by
    django-db-file-storage"""

    #: File data
    bytes = models.TextField()

    #: File name
    file_name = models.CharField(max_length=255)

    # Content type
    content_type = models.CharField(max_length=255)


class FileManager(FilesfoldersManager):
    """Manager for custom table-level File queries"""

    def get_folder_readme(
        self, project_pk, folder_pk, mimetype='text/markdown'
    ):
        """
        Return the readme file for a folder or None if not found
github MapStory / mapstory / mapstory / storypins / models.py View on Github external
print 'copy from', source_id, source.storypin_set.all()
        print 'to target', target.id
        for ann in source.storypin_set.all():
            ann.map = target
            ann.pk = None
            copies.append(ann)
        print copies
        StoryPin.objects.bulk_create(copies)
        print 'yeah'


class StoryPin(models.Model):
    objects = StoryPinManager()

    map = models.ForeignKey(Map)
    title = models.TextField()
    content = models.TextField(blank=True, null=True)
    media = models.TextField(blank=True, null=True)
    the_geom = models.TextField(blank=True, null=True)
    start_time = models.BigIntegerField(blank=True, null=True)
    end_time = models.BigIntegerField(blank=True, null=True)
    in_timeline = models.BooleanField(default=False)
    in_map = models.BooleanField(default=False)
    appearance = models.TextField(blank=True, null=True)
    auto_show = models.BooleanField(default=False)
    pause_playback = models.BooleanField(default=False)

    def _timefmt(self, val):
        return datetime.isoformat(datetime.utcfromtimestamp(val))

    def set_start(self, val):
        self.start_time = parse_date_time(val)