Source

django-helper / django_helper / models.py

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

APP_NAMES = []
for app in settings.INSTALLED_APPS:
    APP_NAMES.append((app, app))

class Middleware(models.Model):
    name = models.CharField(max_length=40)
    app_name = models.CharField(max_length=60, choices=APP_NAMES)
    process_request = models.BooleanField()
    process_view = models.BooleanField()
    process_template_response = models.BooleanField()
    process_response = models.BooleanField()
    process_exception = models.BooleanField()
    description = models.TextField()
    added_on = models.DateField(auto_now_add=True)
    def __unicode__(self):
        return u"%s" % self.name

class ContextProcessor(models.Model):
    name = models.SlugField()
    app_name = models.CharField(max_length=60, choices=APP_NAMES)
    required_middleware = models.ManyToManyField(Middleware, blank=True)
    description = models.TextField()
    added_on = models.DateField(auto_now_add=True)
    def __unicode__(self):
        return u"%s" % self.name

class TemplateTag(models.Model):
    TYPE_LIST = (
        ('Tag', (
            (1, 'Custom'),
            (2, 'simple_tag'),
            (3, 'inclusion_tag'),
            (4, 'assignment_tag'),
            (5, 'Block'),
                 )
         ),
        ('Filter', (
            (51, 'Integer'),
            (52, 'String'),
            (53, 'Object'),
            (54, 'Other'),
                    )
         )
    )
    tag_name = models.SlugField()  # Use SlugField as it fits most of the validation checks for how a tag is formatted.
    tag_type = models.PositiveSmallIntegerField(choices=TYPE_LIST)
    app_name = models.CharField(max_length=60, choices=APP_NAMES)
    parameters = models.CharField(max_length=60, blank=True)
    takes_context = models.BooleanField()
    required_context = models.ManyToManyField(ContextProcessor, blank=True)
    template = models.CharField(max_length=80, blank=True, help_text='Template used by the tag/filter, if any.')
    examples = models.TextField()
    description = models.TextField()
    added_on = models.DateField(auto_now_add=True)
    def __unicode__(self):
        return u"%s" % self.tag_name
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.