konova/konova/models.py
mipel 5e48bac013 Intervention Detail View
* adds (WIP) detail view for interventions
* renames typo in conservations_file_number to conservation_file_number
* adds simple has_access check for intervention objects for given users
* renames occurences of "Registered" to "Recorded" (verzeichnen)
* adds an informing message for detail view of intervention objects which are not editable for a user
* adds GeometryAdmin
* adds fallback DEFAULT_SRID for Geometry model
* adds translations
2021-07-22 13:19:14 +02:00

73 lines
2.1 KiB
Python

"""
Author: Michel Peltriaux
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 17.11.20
"""
import uuid
from django.contrib.auth.models import User
from django.contrib.gis.db.models import MultiPolygonField
from django.db import models
from konova.settings import DEFAULT_SRID
class BaseResource(models.Model):
"""
A basic resource model, which defines attributes for every derived model
"""
id = models.UUIDField(
primary_key=True,
default=uuid.uuid4,
)
created_on = models.DateTimeField(auto_now_add=True, null=True)
created_by = models.ForeignKey(User, null=True, on_delete=models.SET_NULL, related_name="+")
class Meta:
abstract = True
class BaseObject(BaseResource):
"""
A basic object model, which specifies BaseResource.
Mainly used for intervention, compensation, ecoaccount
"""
identifier = models.CharField(max_length=1000, null=True, blank=True)
title = models.CharField(max_length=1000, null=True, blank=True)
deleted_on = models.DateTimeField(null=True, blank=True)
deleted_by = models.ForeignKey(User, null=True, blank=True, on_delete=models.SET_NULL, related_name="+")
comment = models.TextField(null=True, blank=True)
class Meta:
abstract = True
class Deadline(BaseResource):
"""
Defines a deadline, which can be used to define dates with a semantic meaning
"""
type = models.CharField(max_length=500, null=True, blank=True)
date = models.DateField(null=True, blank=True)
def __str__(self):
return self.type
class Document(BaseResource):
"""
Documents can be attached to compensation or intervention for uploading legal documents or pictures.
"""
date_of_creation = models.DateField()
document = models.FileField()
comment = models.TextField()
class Geometry(BaseResource):
"""
Outsourced geometry model so multiple versions of the same object can refer to the same geometry if it is not changed
"""
geom = MultiPolygonField(null=True, blank=True, srid=DEFAULT_SRID)