Ejemplo n.º 1
0
class Video(models.Model):
    uuid = models.UUIDField(primary_key=True,
                            editable=False,
                            default=uuid.uuid4)
    name = models.CharField(max_length=80)
    created = models.DateTimeField(auto_now_add=True)
    thumbnail = models.FilePathField(
        max_length=260,
        path=str(VIDEO_ROOT),
        null=True,
        blank=True,
    )
    url = models.FilePathField(
        max_length=260,
        path=str(VIDEO_ROOT),
        null=True,
        blank=True,
    )
Ejemplo n.º 2
0
class DrawCollection(models.Model):
    reference = models.CharField(max_length=10,
                                 unique=True,
                                 db_index=True,
                                 editable=False,
                                 default=gen_ref)
    date = models.DateField(auto_now_add=True)
    pathshp = models.FilePathField(path=settings.BASE_DIR + '/shapefile')
    status = models.BooleanField(default=False)
    owner = models.ForeignKey('auth.User', related_name='draw', null=True)

    objects = DrawManager()

    class Meta:
        permissions = (('view_draw', 'View draw'), )
Ejemplo n.º 3
0
class ManualNewsCurationProject(cm.ParticipationProject):
    url = models.URLField(blank=False)
    screenshot_filename = models.FilePathField(max_length=500, blank=True)
    first_paragraph = models.TextField(blank=False)
    tags = models.ManyToManyField(cm.Tag)

    def update_items(self):
        existing_query_set = NewsArticleItem.objects.filter(participation_project=self, is_active=True)
        num_existing_items = existing_query_set.update(name=self.name)
        if num_existing_items == 0:
            item = NewsArticleItem()
            item.name = self.name
            item.participation_project = self
            item.save()
        else:
            for item in existing_query_set:
                item.set_relevant_tags()
Ejemplo n.º 4
0
class Asset(models.Model):
    '''  Image file asset -- built for MOC data '''
    volume = models.TextField(max_length=256, null=True)
    product_id = models.TextField(
        max_length=512, null=True
    )  # only meaningful if this asset is associated with a single product

    parents = models.ManyToManyField('Asset',
                                     symmetrical=False,
                                     related_name='children')
    is_original = models.BooleanField(default=False)
    relative_file_path = models.FilePathField(
        max_length=4096
    )  #4096 being the linux kernel's default maximum absolute path length
    name = models.TextField(max_length=512, null=True)

    status = models.TextField(max_length=128, null=True)
    md5_check = models.BooleanField(null=True)
    has_errors = models.BooleanField(default=False)
    class_label = models.TextField(max_length=512, null=True)
    creator_job = models.ForeignKey('jobs.Job',
                                    null=True,
                                    related_name='output_assets')

    # MOC specific stuff
    instrument_name = models.TextField(max_length=128, null=True)
    center_latitude = models.FloatField(null=True)
    min_latitude = models.FloatField(null=True)
    max_latitude = models.FloatField(null=True)
    if not settings.DISABLE_GEO:
        footprint = models.PolygonField(null=True, srid=949900)

    def __unicode__(self):
        if self.name:
            rep = self.name
        elif self.product_id:
            rep = self.product_id
        else:
            rep = self.id
        return "<Asset: %s>" % rep

    @property
    def file_path(self, dataroot=DATA_ROOT):
        """ Read only attribute: to set the file path, use relative_file_path """
        #return os.path.join(DATA_ROOT, self.volume.lower(), self.file_name.lower())
        return os.path.join(DATA_ROOT, self.relative_file_path)
Ejemplo n.º 5
0
class ParticipationItem(models.Model):
    name = models.CharField(max_length = 500)
    creation_time = models.DateTimeField(auto_now_add=True)
    participation_project = models.ForeignKey('ParticipationProject', on_delete=models.CASCADE)
    display_image_file = models.FilePathField(max_length=500, blank=True)
    visits = models.IntegerField(default=0)
    tags = models.ManyToManyField('Tag')
    is_active = models.BooleanField(default=True)

    def participate_link(self):
        app = get_app_for_model(self.get_inherited_instance().__class__)
        return "/apps/"+app.label+"/participate/"+str(self.id)

    def get_inherited_instance(self):
        ans = self
        for t in [get_item_subclass_test(app) for app in get_registered_participation_apps()]:
            try:
                ans = t(self)
            except:
                continue
            else:
                return ans
        raise Exception("unknown subclass type")

    def set_relavent_tags(self):
        raise Exception("set_relevant_tags() method needs to be implemented by all ParticipationItem subclasses.")

    def get_inline_display(self):
        return self.name

    def set_display_image(self):
        """
        Overwrite this function with app-specific method 
        for setting an item's display image.
        It can take a long time, since it will be run by workers, not by web server
        """
        return None
Ejemplo n.º 6
0
class Raster(models.Model):
    layer = models.ForeignKey(Layer)
    filepath = models.FilePathField(path=rastdir, recursive=True)

    def __unicode__(self):
        return u"Raster layer %s" % (self.layer)