This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 46cb8e64ff63948921d55a3c2c902dbe8681e83f
Author: Dave Brondsema <[email protected]>
AuthorDate: Tue May 5 13:35:57 2026 -0400

    [#8603] change AlluraUserProperty User reference so that ShortUrl doesn't 
error strangely on shorturl.create_user = c.user._id (tests were always passing 
too, weird)
---
 Allura/allura/model/auth.py                   |  2 +-
 ForgeShortUrl/forgeshorturl/model/shorturl.py | 12 +++++-------
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index b3eee63fc..feb9e950c 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -71,7 +71,7 @@ class AlluraUserProperty(ForeignIdProperty):
     '''
 
     def __init__(self, **kwargs):
-        super().__init__('User', allow_none=True, **kwargs)
+        super().__init__(User, allow_none=True, **kwargs)
 
 
 class EmailAddress(MappedClass):
diff --git a/ForgeShortUrl/forgeshorturl/model/shorturl.py 
b/ForgeShortUrl/forgeshorturl/model/shorturl.py
index 8da0aef9b..a4c4c9daf 100644
--- a/ForgeShortUrl/forgeshorturl/model/shorturl.py
+++ b/ForgeShortUrl/forgeshorturl/model/shorturl.py
@@ -17,11 +17,12 @@
 
 import typing
 import pymongo
+from bson import ObjectId
 from tg import config
 from tg import tmpl_context as c
-from ming.odm import FieldProperty, session
+from ming.odm import FieldProperty, session, RelationProperty
 from datetime import datetime
-from allura.model.auth import User
+from allura.model.auth import User, AlluraUserProperty
 from allura import model as M
 
 if typing.TYPE_CHECKING:
@@ -41,14 +42,11 @@ class __mongometa__:
     short_name = FieldProperty(str)
     description = FieldProperty(str)
     private = FieldProperty(bool)
-    create_user = M.AlluraUserProperty()
+    create_user: ObjectId = AlluraUserProperty()
+    user = RelationProperty(User, via='create_user')
     created = FieldProperty(datetime, if_missing=datetime.utcnow)
     last_updated = FieldProperty(datetime, if_missing=datetime.utcnow)
 
-    @property
-    def user(self):
-        return User.query.get(_id=self.create_user)
-
     @classmethod
     def upsert(cls, shortname):
         u = cls.query.get(short_name=shortname, app_config_id=c.app.config._id)

Reply via email to