Source code for geonode.resource.models

#########################################################################
#
# Copyright (C) 2021 OSGeo
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#########################################################################
import uuid

from django.db import models
from django.conf import settings
from django.utils.translation import gettext_lazy as _

from geonode.resource.enumerator import ExecutionRequestAction


[docs] class ExecutionRequest(models.Model):
[docs] STATUS_READY = "ready"
[docs] STATUS_FAILED = "failed"
[docs] STATUS_RUNNING = "running"
[docs] STATUS_FINISHED = "finished"
[docs] STATUS_CHOICES = [ (STATUS_READY, _("ready")), (STATUS_FAILED, _("failed")), (STATUS_RUNNING, _("running")), (STATUS_FINISHED, _("finished")), ]
[docs] ACTION_CHOICES = [(str(v.value), str(v.value)) for v in ExecutionRequestAction]
[docs] exec_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
[docs] user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL)
[docs] status = models.CharField(max_length=50, choices=STATUS_CHOICES, default=STATUS_READY)
[docs] func_name = models.CharField(max_length=100)
[docs] created = models.DateTimeField(auto_now_add=True)
[docs] finished = models.DateTimeField(null=True)
[docs] last_updated = models.DateTimeField(auto_now=True)
[docs] input_params = models.JSONField(blank=True, default=dict)
[docs] output_params = models.JSONField(blank=True, default=dict)
[docs] geonode_resource = models.ForeignKey("base.ResourceBase", null=True, on_delete=models.SET_NULL)
[docs] step = models.CharField(max_length=250, null=True, default=None)
[docs] log = models.TextField(null=True, default=None)
[docs] name = models.CharField( max_length=250, null=True, default=None, help_text="Human readable name for the execution request" )
[docs] action = models.CharField( max_length=50, choices=ACTION_CHOICES, default=ExecutionRequestAction.UNKNOWN.value, null=True )
[docs] source = models.CharField(max_length=250, null=True, default=None)