From be063a7032971db7c00a160595e69e1e67dd2c9f Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 22 Oct 2024 12:45:25 +0200 Subject: ✨ permissions refactoring: adapt admin pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/models_common.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'ishtar_common/models_common.py') diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index cd6c266ef..e92d7d55d 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2626,7 +2626,7 @@ class GeoVectorData(Imported, OwnPerms): if not precision and rounded: precision = 6 - r = re.compile(r"(\d+)\.(\d{6})(\d*)") + # AFAC: r = re.compile(r"(\d+)\.(\d{6})(\d*)") new_collection = [] for feat in collection: geom_type = feat["geometry"].get("type", None) @@ -3068,18 +3068,15 @@ class GeographicItem(models.Model): class PermissionRequest(models.Model): - name = models.CharField(_("Name"), max_length=200) - slug = models.SlugField(_("Slug"), unique=True) model = models.ForeignKey(ContentType, related_name="permissions", verbose_name=_("Model"), on_delete=models.CASCADE) + name = models.CharField(_("Name"), max_length=200) + slug = models.SlugField(_("Slug"), unique=True) request = models.TextField( _("Request"), blank=True, null=False, default="", help_text=_("Use 'text' request used in Ishtar search input") ) - limit_to_attached_areas = models.BooleanField( - _("Limit request to attached areas"), default=False, - help_text=_("Request is limited to areas attached to the ishtar user") - ) + active = models.BooleanField(_("Active"), default=True) include_associated_items = models.BooleanField( _("Include associated items"), default=True, help_text=_("All items associated items match the request") @@ -3091,12 +3088,20 @@ class PermissionRequest(models.Model): "For instance, match is done for all finds associated with own " "context records") ) - active = models.BooleanField(_("Active"), default=True) + limit_to_attached_areas = models.BooleanField( + _("Limit request to attached areas"), default=False, + help_text=_("Request is limited to areas attached to the ishtar user") + ) + + ADMIN_SECTION = _("Account") class Meta: verbose_name = _("Permission request") verbose_name_plural = _("Permissions requests") + def __str__(self): + return f"{self.model} - {self.name}" + class SerializeItem: SERIALIZE_EXCLUDE = ["search_vector"] -- cgit v1.2.3