Beispiel #1
0
class Resource(TimeStampedModel):
    uuid = UUIDField(primary_key=True)
    bundle = models.ForeignKey(Bundle, related_name='resources')
    status = models.SmallIntegerField(default=STATUS_INIT)

    compiler_warnings = jsonfield.JSONField(null=True, blank=True)
    compiler_errors = jsonfield.JSONField(null=True, blank=True)

    source = models.TextField()
    source_map = models.TextField()
    source_processed = models.TextField()

    objects = models.Manager()
    api = ResourceManager()

    @property
    def source_size(self):
        return file_size_format(len(self.source))

    @property
    def source_processed_size(self):
        return file_size_format(len(self.source_processed))

    @property
    def is_processed(self):
        return True if self.status > STATUS_RUNNING else False

    class Meta:
        db_table = 'app_resource'
Beispiel #2
0
class Resource(models.Model):
    name = models.CharField(max_length=255)
    url = models.TextField(max_length=MAX_URL_LENGTH)
    is_readonly = models.BooleanField(default=True)

    objects = ResourceManager()

    def __unicode__(self):
        return u"Resource %s with url %s" % (self.name, self.url)