コード例 #1
0
class Parametro(models.Model):
    codigo = models.IntegerField(default=0)
    Nome = models.CharField(max_length=100)
    Classe_FK = models.ForeignKey(Classe,
                                  null=True,
                                  blank=True,
                                  default=None,
                                  verbose_name="Classe")
    Planilha = models.CharField(max_length=200, default='')
    jan = models.IntegerField(default=0)
    fev = models.IntegerField(default=0)
    mar = models.IntegerField(default=0)
    abr = models.IntegerField(default=0)
    mai = models.IntegerField(default=0)
    jun = models.IntegerField(default=0)
    jul = models.IntegerField(default=0)
    ago = models.IntegerField(default=0)
    stb = models.IntegerField(default=0)
    out = models.IntegerField(default=0)
    nov = models.IntegerField(default=0)
    dez = models.IntegerField(default=0)
    tot = models.IntegerField(default=0)
    unidade = models.CharField(max_length=15, blank=True, default='')
    corGrafico = ColorPickerField(
        help_text="Clique no campo para abrir o colorpicker.", max_length=7)

    class Meta:
        ordering = [
            'Nome',
        ]

    def __unicode__(self):
        return u'{0}'.format(self.Nome)
コード例 #2
0
class Locality(models.Model):
    """
    Represents Locality, a part of District area as a geospatial boundary

    Relates to :model:`locations.GatewayType`
    Relates to :model:`locations.Region`
    """

    region = models.ForeignKey(Region)
    cad_code = models.CharField(max_length=11L)
    cas_code = models.CharField(max_length=11L)
    cas_code_un = models.CharField(max_length=11L)
    name = models.CharField(max_length=128L)
    cas_village_name = models.CharField(max_length=128L)
    p_code = models.CharField(max_length=32L, blank=True, null=True)
    gateway = models.ForeignKey(GatewayType,
                                blank=True,
                                null=True,
                                verbose_name='Admin type')
    color = ColorPickerField(null=True, blank=True, default=get_random_color)

    geom = models.MultiPolygonField(null=True, blank=True)
    objects = models.GeoManager()

    def __unicode__(self):
        return self.name

    class Meta:
        verbose_name = 'Sub-district'
        ordering = ['name']
コード例 #3
0
ファイル: models.py プロジェクト: stefanfoulis/etools
class Sector(models.Model):
    """
    Represents a sector
    """

    name = models.CharField(max_length=45L, unique=True)
    description = models.CharField(
        max_length=256L,
        blank=True,
        null=True
    )
    alternate_id = models.IntegerField(
        blank=True,
        null=True
    )
    alternate_name = models.CharField(
        max_length=255,
        blank=True,
        null=True
    )
    dashboard = models.BooleanField(
        default=False
    )
    color = ColorPickerField(null=True, blank=True)

    class Meta:
        ordering = ['name']

    def __unicode__(self):
        return u'{} {}'.format(
            self.alternate_id if self.alternate_id else '',
            self.name
        )
コード例 #4
0
class Region(models.Model):
    """
    Represents a district, a part of Admin area as a geospatial boundary

    Relates to :model:`locations.GatewayType`
    Relates to :model:`locations.Governorate`
    """

    governorate = models.ForeignKey(Governorate)
    name = models.CharField(max_length=45L)
    p_code = models.CharField(max_length=32L, blank=True, null=True)
    gateway = models.ForeignKey(GatewayType,
                                blank=True,
                                null=True,
                                verbose_name='Admin type')
    color = ColorPickerField(null=True, blank=True, default=get_random_color)

    geom = models.MultiPolygonField(null=True, blank=True)
    objects = models.GeoManager()

    def __unicode__(self):
        return self.name

    class Meta:
        verbose_name = 'District'
        ordering = ['name']
コード例 #5
0
ファイル: models.py プロジェクト: FrauBluher/ShR2
class Tier(models.Model):
    """
   A class that defines the cost and threshold of a :class:`webapp.models.RatePlan`.

   A :class:`webapp.models.RatePlan` typically has 4-5 :class:`webapp.models.Tier` objects
   as a relation. These objects keep track of the cost modifier as well as the KWh threshold
   for a given device.
   """

    rate_plan = models.ForeignKey(RatePlan)
    """ This object is related to a :class:`webapp.models.RatePlan`."""

    tier_level = models.IntegerField(blank=True, null=True)
    """ An Integer, starting at 1, indicating the current level of the device."""

    max_percentage_of_baseline = models.FloatField(
        help_text="blank for no maximum", blank=True, null=True)
    """ This defines the threshold for a given :class:`webapp.models.Tier`. I.e. 100% - 130%"""

    rate = models.FloatField(help_text="$", blank=True, null=True)
    """ The actual cost of a KWh at this level."""

    chart_color = ColorPickerField()
    """ Color used by charts when graphing a :class:`webapp.models.Tier`."""
    def __unicode__(self):
        return 'Tier ' + str(self.tier_level)
コード例 #6
0
class CarouselEntry(TranslatableModel):
    translations = TranslatedFields(
        text_over_image=models.CharField(_('image text'), max_length=255),
        navigation_entry=models.CharField(_('navigation entry'),
                                          max_length=30),
    )

    image = ImageCropField(_('image'), upload_to='carousel')
    cropped = ImageRatioField('image',
                              '{0}x{1}'.format(IMAGE_WIDTH, IMAGE_HEIGHT),
                              size_warning=True)
    order = models.PositiveIntegerField(unique=True)
    text_background_color = ColorPickerField(blank=True)

    objects = CarouselEntryManager()

    def __unicode__(self):
        return self.navigation_entry_translated()

    def text_over_image_translated(self):
        try:
            return self.text_over_image
        except:
            return self.translations.all()[0].text_over_image

    text_over_image_translated.short_description = 'Image Text'

    def navigation_entry_translated(self):
        try:
            return self.navigation_entry
        except:
            return self.translations.all()[0].navigation_entry

    navigation_entry_translated.short_description = 'Navigation Text'

    def cropped_img_url(self):
        return get_thumbnailer(self.image).get_thumbnail({
            'size': (IMAGE_WIDTH, IMAGE_HEIGHT),
            'box':
            self.cropped,
            'crop':
            True,
            'detail':
            True,
        }).url

    def image_display_in_admin(self):
        return "<a href='{0}'><img src='{0}' width='{1}' height='{2}'></a>".format(
            self.cropped_img_url(), IMAGE_WIDTH / 3, IMAGE_HEIGHT / 3)

    image_display_in_admin.allow_tags = True
    image_display_in_admin.short_description = 'Image Preview'

    def carousel_entry_id(self):
        return 'entry{}'.format(self.order)

    class Meta:
        verbose_name_plural = _('carousel entries')
        ordering = ('order', )
コード例 #7
0
ファイル: models.py プロジェクト: berkoab/bikurcholim
class Services(models.Model):
	service = models.CharField(max_length=50)
	color = ColorPickerField(null=True, blank=True)
	class Meta:
		verbose_name_plural = "Services"
		ordering = ('service',)
	def __str__(self):
		return self.service
コード例 #8
0
class Country(models.Model):
    region = models.IntegerField(choices=CHOICE_REGION)
    name = models.CharField(max_length=250)
    latitud = models.FloatField(blank=True, null=True)
    longitud = models.FloatField(blank=True, null=True)
    color = ColorPickerField()

    def __str__(self):
        return self.name
コード例 #9
0
ファイル: models.py プロジェクト: softcoder32/hyperkitty
class ThreadCategory(models.Model):
    name = models.CharField(max_length=255, db_index=True, unique=True)
    color = ColorPickerField()

    class Meta:
        verbose_name_plural = "Thread categories"

    def __unicode__(self):
        return u'Thread category "%s"' % (unicode(self.name))
コード例 #10
0
ファイル: models.py プロジェクト: yannhowe/serf
class Category(models.Model):
    class Meta:
        verbose_name_plural = "categories"

    name = models.CharField(max_length=80)
    description = models.TextField(max_length=1200)
    color = ColorPickerField()

    def __str__(self):
        return self.name
コード例 #11
0
ファイル: models.py プロジェクト: berkoab/bikurcholim
class Houses(models.Model):
	name = models.CharField(max_length=50)
	address = models.CharField(max_length=200, null=True, blank=True)
	phone_number = models.CharField(max_length=50, null=True, blank=True)
	color = ColorPickerField(null=True, blank=True)
	class Meta:
		verbose_name_plural = "Houses"
		ordering = ('name',)
	def __str__(self):
		return self.name
コード例 #12
0
ファイル: models.py プロジェクト: berlyseria/djattendance
class BadgePrintSettings(SingletonModel):
    banner_color = ColorPickerField(blank=True, null=True)

    def __unicode__(self):
        try:
            return u"Badge Printing Configuration"
        except AttributeError as e:
            return str(self.id) + ": " + str(e)

    class Meta:
        verbose_name = "Badge Printing Configuration"
コード例 #13
0
ファイル: models.py プロジェクト: FrauBluher/ShR2
class CircuitType(models.Model):
   """
   Describes a Circuit Type. A Circuit Type is related to a list of :class:`microdata.models.Appliance` and acts as a set of objects to discover within a circuit.
   """
   name = models.CharField(max_length=50, unique=True)
   appliances = models.ManyToManyField(Appliance, blank=True)
   chart_color = ColorPickerField()
   """ This field defines what color the chart will assign the circuit when it is being displayed. Modifiable via the admin interface. """

   def __unicode__(self):
      return self.name
コード例 #14
0
ファイル: models.py プロジェクト: FrauBluher/ShR2
class Appliance(models.Model):
   """
   Describes a single Appliance. In the future, this model will have describing attributes that give the user helpful information when visualizing.
   """
   serial = models.IntegerField(unique=True)
   name = models.CharField(max_length=50, unique=True)
   chart_color = ColorPickerField()
   """ This field defines what color the chart will assign the appliance when it is being displayed. Modifiable via the admin interface. """

   def __unicode__(self):
      return self.name
コード例 #15
0
class EventType(models.Model):
    # Events may be of several different types that one may like to distinguish
    # between (e.g. exercise, course, meeting, social, etc.).
    #
    # TagTypes also have EventTypes as an exercise may have different tags to a
    # meeting.

    title = models.CharField(max_length=64)
    description = models.TextField(blank=True)
    color = ColorPickerField(default="#ffffff")

    def __unicode__(self):
        return self.title
コード例 #16
0
ファイル: models.py プロジェクト: dreglad/studiorec
class TopImageExtension(PageExtension):
    SIZES_CHOICES = (('short', _('Short')), ('large', _('Large')))
    DEFAULT_IMAGE = '..{}images/camera-bg.jpg'.format(settings.STATIC_URL)
    image = models.ImageField(upload_to="headers/",
                              default=DEFAULT_IMAGE,
                              verbose_name=_(u'image'),
                              null=True,
                              blank=True)
    size = models.CharField(_('size'),
                            max_length=16,
                            choices=SIZES_CHOICES,
                            default=SIZES_CHOICES[0])
    color = ColorPickerField(default="#1f3549")
コード例 #17
0
class TypePolygon(models.Model):
    old_id = models.IntegerField(verbose_name=_(u'Old id'),
                                 default=0,
                                 db_index=True)
    #  rothermel = models.ForeignKey(Rothermel, blank=True, default=False)
    name = models.CharField(max_length=250, verbose_name=_(u'Polygon type'))
    is_pub = models.BooleanField(verbose_name=u'Active', default=False)
    fill_color = ColorPickerField(verbose_name=u'Filling color',
                                  blank=True,
                                  default="#ff0000")
    border_color = ColorPickerField(verbose_name=u'Border color',
                                    blank=True,
                                    default="#000000")

    def __unicode__(self):
        return self.name

    @property
    def fill_color_rect(self):
        if (self.fill_color):
            return mark_safe(
                u'<div style="width: 25px; height: 25px; background:' +
                unicode(self.fill_color) + u' "></div>')
        else:
            return u'not determined'

    @property
    def border_color_rect(self):
        if (self.fill_color):
            return mark_safe(
                u'<div style="width: 25px; height: 25px; background:' +
                unicode(self.border_color) + u' "></div>')
        else:
            return u'not determined'

    class Meta:
        verbose_name = _(u'Polygon type')
        verbose_name_plural = _(u'Polygon types')
コード例 #18
0
class TypePolygon(models.Model):
    rothermel = models.ForeignKey(Rothermel, blank=True, default=False)
    name = models.CharField(max_length=250, verbose_name=_(u'Polygon type'))
    is_pub = models.BooleanField(verbose_name=u'Active', default=False)
    fill_color = ColorPickerField(verbose_name=u'Filling color',
                                  blank=True,
                                  default="#ff0000")
    border_color = ColorPickerField(verbose_name=u'Border color',
                                    blank=True,
                                    default="#000000")

    def __unicode__(self):
        return getattr(translation_pool.annotate_with_translations(self), 'translations', []) \
             and unicode(translation_pool.annotate_with_translations(self).translations[0]) or u'No translations'

    @property
    def fill_color_rect(self):
        if (self.fill_color):
            return mark_safe(
                u'<div style="width: 25px; height: 25px; background:' +
                unicode(self.fill_color) + u' "></div>')
        else:
            return u'not determined'

    @property
    def border_color_rect(self):
        if (self.fill_color):
            return mark_safe(
                u'<div style="width: 25px; height: 25px; background:' +
                unicode(self.border_color) + u' "></div>')
        else:
            return u'not determined'

    class Meta:
        verbose_name = _(u'Polygon type')
        verbose_name_plural = _(u'Polygon types')
コード例 #19
0
class CartoDBTable(MPTTModel):
    """
    Represents a table in CartoDB, it is used to import lacations

    Relates to :model:`locations.GatewayType`
    """

    domain = models.CharField(max_length=254)
    api_key = models.CharField(max_length=254)
    table_name = models.CharField(max_length=254)
    display_name = models.CharField(max_length=254, null=True, blank=True)
    location_type = models.ForeignKey(GatewayType)
    name_col = models.CharField(max_length=254, default='name')
    pcode_col = models.CharField(max_length=254, default='pcode')
    parent_code_col = models.CharField(max_length=254, null=True, blank=True)
    parent = TreeForeignKey('self',
                            null=True,
                            blank=True,
                            related_name='children',
                            db_index=True)
    color = ColorPickerField(null=True, blank=True, default=get_random_color)

    def __unicode__(self):
        return self.table_name
コード例 #20
0
ファイル: models.py プロジェクト: hgw/rhizome.org
class FeaturedObject(models.Model):
    """
    Model for generating featured objects for the featured set
    """
    featured_set = models.ForeignKey(FeaturedSet)
    content_type = models.ForeignKey(ContentType, limit_choices_to=featured_object_choices, blank=True, null=True)
    object_id = models.PositiveIntegerField(blank=True, null=True, db_index=True)
    content_object = generic.GenericForeignKey('content_type','object_id')
    image = models.ImageField(upload_to='frontpage/images/', null=True, blank=True, help_text='300px high')
    title = models.CharField(max_length=40, blank=True, null=True) 
    description = models.CharField(max_length=225, blank=True, null=True) 
    byline = models.CharField(max_length=60, blank=True, null=True) 
    url = models.URLField(blank=True, null=True)

    title_color = ColorPickerField(max_length=40, blank=True, null='')
    text_color = ColorPickerField(max_length=40, blank=True, null='')
    byline_color = ColorPickerField(max_length=40, blank=True, null='')

    def __unicode__(self):
        return self.get_title()

    def get_title(self):
        if self.title:
            return self.title

        if hasattr(self.content_object, 'subtitle'):
            if self.content_object.subtitle:
                return self.content_object.subtitle

        if self.content_object:
            return self.content_object.title
        return ''

    def get_byline(self):
        if self.byline:
            return ('#', self.byline)

        if self.ct == 'artworkstub':
            return (self.content_object.user.get_profile().get_absolute_url(), self.content_object.get_artist())

        if self.ct == 'post':
            authors = self.content_object.get_authors()
            if authors:
                return (authors[0].get_profile().get_absolute_url(), authors[0].get_profile()) 
            return ('', self.content_object.byline)

        if self.ct in ['rhizevent', 'exhibition']:
            curators = self.content_object.curator.all()
            if curators:
                return (curators[0].get_profile().get_absolute_url(), curators[0].get_profile())
            return (self.content_object.curator_other_link, self.content_object.curator_other)
            

    def get_description(self):
        if self.description:
            return self.description

        if self.ct == 'artworkstub':
            if self.content_object.summary:
                return self.content_object.summary
            return self.content_object.description

        if self.ct == 'rhizomeuser':
            return self.content_object.description

        if self.ct == 'post':
            return self.content_object.tease

        if self.ct == 'exhibition':
            return self.content_object.description

        if self.ct == 'rhizevent':
            return self.content_object.summary