You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ke...@apache.org on 2021/10/08 20:41:36 UTC
[allura] 03/04: Special property hinting
This is an automated email from the ASF dual-hosted git repository.
kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 76104cbd79742abd46b48f2a9cd6a75ed2e3253f
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Wed Sep 29 10:00:38 2021 -0400
Special property hinting
---
Allura/allura/model/auth.py | 7 ++++---
Allura/allura/model/discuss.py | 3 ++-
Allura/allura/model/notification.py | 4 ++--
Allura/allura/model/oauth.py | 7 ++++---
Allura/allura/model/project.py | 2 +-
ForgeFeedback/forgefeedback/model/feedback.py | 2 +-
ForgeFiles/forgefiles/model/files.py | 3 ++-
ForgeTracker/forgetracker/model/ticket.py | 4 ++--
8 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index f33bb38..add60ac 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -33,6 +33,7 @@ import re
from pytz import timezone
import pymongo
from pymongo.errors import DuplicateKeyError
+from bson import ObjectId
from tg import config
from tg import tmpl_context as c, app_globals as g
from tg import request
@@ -277,7 +278,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
))
# Additional top-level fields can/should be accessed with get/set_pref also
# Not sure why we didn't put them within the 'preferences' dictionary :(
- display_name = FieldPropertyDisplayName(str)
+ display_name: str = FieldPropertyDisplayName(str)
# Personal data
sex = FieldProperty(
S.OneOf('Male', 'Female', 'Other', 'Unknown',
@@ -861,7 +862,7 @@ class ProjectRole(MappedClass):
query: 'Query[ProjectRole]'
_id = FieldProperty(S.ObjectId)
- user_id = AlluraUserProperty(if_missing=None)
+ user_id: ObjectId = AlluraUserProperty(if_missing=None)
project_id = ForeignIdProperty('Project', if_missing=None)
name = FieldProperty(str)
roles = FieldProperty([S.ObjectId])
@@ -1079,7 +1080,7 @@ class UserLoginDetails(MappedClass):
query: 'Query[UserLoginDetails]'
_id = FieldProperty(S.ObjectId)
- user_id = AlluraUserProperty(required=True)
+ user_id: ObjectId = AlluraUserProperty(required=True)
ip = FieldProperty(str)
ua = FieldProperty(str)
extra = FieldProperty({
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index f0b4bc1..cfcc1e1 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -33,6 +33,7 @@ from ming.orm.base import session
from ming.orm.property import (FieldProperty, RelationProperty,
ForeignIdProperty)
from ming.utils import LazyProperty
+from bson import ObjectId
from allura.lib import helpers as h
from allura.lib import security
@@ -529,7 +530,7 @@ class Post(Message, VersionedArtifact, ActivityObject, ReactableArtifact):
status = FieldProperty(schema.OneOf('ok', 'pending', 'spam',
if_missing='pending'))
last_edit_date = FieldProperty(datetime, if_missing=None)
- last_edit_by_id = AlluraUserProperty()
+ last_edit_by_id: ObjectId = AlluraUserProperty()
edit_count = FieldProperty(int, if_missing=0)
spam_check_id = FieldProperty(str, if_missing='')
text_cache = FieldProperty(MarkdownCache)
diff --git a/Allura/allura/model/notification.py b/Allura/allura/model/notification.py
index 558f426..97314d4 100644
--- a/Allura/allura/model/notification.py
+++ b/Allura/allura/model/notification.py
@@ -104,7 +104,7 @@ class Notification(MappedClass):
subject = FieldProperty(str)
text = FieldProperty(str)
link = FieldProperty(str)
- author_id = AlluraUserProperty()
+ author_id: ObjectId = AlluraUserProperty()
feed_meta = FieldProperty(S.Deprecated)
artifact_reference = FieldProperty(S.Deprecated)
pubdate = FieldProperty(datetime, if_missing=datetime.utcnow)
@@ -412,7 +412,7 @@ class Mailbox(MappedClass):
query: 'Query[Mailbox]'
_id = FieldProperty(S.ObjectId)
- user_id = AlluraUserProperty(if_missing=lambda: c.user._id)
+ user_id: ObjectId = AlluraUserProperty(if_missing=lambda: c.user._id)
project_id = ForeignIdProperty('Project', if_missing=lambda: c.project._id)
app_config_id = ForeignIdProperty(
'AppConfig', if_missing=lambda: c.app.config._id)
diff --git a/Allura/allura/model/oauth.py b/Allura/allura/model/oauth.py
index c661bb0..cd585c5 100644
--- a/Allura/allura/model/oauth.py
+++ b/Allura/allura/model/oauth.py
@@ -29,6 +29,7 @@ import pymongo
from ming import schema as S
from ming.orm import FieldProperty, RelationProperty, ForeignIdProperty, session
from ming.orm.declarative import MappedClass
+from bson import ObjectId
from allura.lib import helpers as h
from .session import main_orm_session
@@ -75,7 +76,7 @@ class OAuthConsumerToken(OAuthToken):
query: 'Query[OAuthConsumerToken]'
type = FieldProperty(str, if_missing='consumer')
- user_id = AlluraUserProperty(if_missing=lambda: c.user._id)
+ user_id: ObjectId = AlluraUserProperty(if_missing=lambda: c.user._id)
name = FieldProperty(str)
description = FieldProperty(str, if_missing='')
description_cache = FieldProperty(MarkdownCache)
@@ -121,7 +122,7 @@ class OAuthRequestToken(OAuthToken):
type = FieldProperty(str, if_missing='request')
consumer_token_id = ForeignIdProperty('OAuthConsumerToken')
- user_id = AlluraUserProperty(if_missing=lambda: c.user._id)
+ user_id: ObjectId = AlluraUserProperty(if_missing=lambda: c.user._id)
callback = FieldProperty(str)
validation_pin = FieldProperty(str)
@@ -138,7 +139,7 @@ class OAuthAccessToken(OAuthToken):
type = FieldProperty(str, if_missing='access')
consumer_token_id = ForeignIdProperty('OAuthConsumerToken')
request_token_id = ForeignIdProperty('OAuthToken')
- user_id = AlluraUserProperty(if_missing=lambda: c.user._id)
+ user_id: ObjectId = AlluraUserProperty(if_missing=lambda: c.user._id)
is_bearer = FieldProperty(bool, if_missing=False)
user = RelationProperty('User')
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index de1ff2f..694e0eb 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -229,7 +229,7 @@ class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject):
parent_id = FieldProperty(S.ObjectId, if_missing=None)
neighborhood_id = ForeignIdProperty(Neighborhood)
shortname = FieldProperty(str)
- name = ProjectNameFieldProperty(str)
+ name: str = ProjectNameFieldProperty(str)
show_download_button = FieldProperty(S.Deprecated)
short_description = FieldProperty(str, if_missing='')
summary = FieldProperty(str, if_missing='')
diff --git a/ForgeFeedback/forgefeedback/model/feedback.py b/ForgeFeedback/forgefeedback/model/feedback.py
index 2e30ca8..5d12523 100644
--- a/ForgeFeedback/forgefeedback/model/feedback.py
+++ b/ForgeFeedback/forgefeedback/model/feedback.py
@@ -60,7 +60,7 @@ class Feedback(VersionedArtifact, ActivityObject):
created_date = FieldProperty(datetime, if_missing=datetime.utcnow)
rating = FieldProperty(str, if_missing='')
description = FieldProperty(str, if_missing='')
- reported_by_id = AlluraUserProperty(if_missing=lambda: c.user._id)
+ reported_by_id: ObjectId = AlluraUserProperty(if_missing=lambda: c.user._id)
project_id = ForeignIdProperty('Project', if_missing=lambda: c.project._id)
reported_by = RelationProperty(User, via='reported_by_id')
diff --git a/ForgeFiles/forgefiles/model/files.py b/ForgeFiles/forgefiles/model/files.py
index c5af9de..e5090e5 100755
--- a/ForgeFiles/forgefiles/model/files.py
+++ b/ForgeFiles/forgefiles/model/files.py
@@ -29,6 +29,7 @@ import typing
from ming import schema as S
from ming.orm import Mapper
from ming.orm import FieldProperty, ForeignIdProperty, RelationProperty
+from bson import ObjectId
from tg import tmpl_context as c
@@ -173,7 +174,7 @@ class UploadFiles(File):
parent_folder_id = ForeignIdProperty('UploadFolder')
created_date = FieldProperty(datetime, if_missing=datetime.utcnow)
mod_date = FieldProperty(datetime, if_missing=datetime.utcnow)
- author_id = AlluraUserProperty(if_missing=lambda: c.user._id)
+ author_id: ObjectId = AlluraUserProperty(if_missing=lambda: c.user._id)
parent_folder = RelationProperty('UploadFolder', via='parent_folder_id')
linked_to_download = FieldProperty(bool, if_missing=False)
path = FieldProperty(str)
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 404223f..7033407 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -669,8 +669,8 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
summary = FieldProperty(str)
description = FieldProperty(str, if_missing='')
description_cache = FieldProperty(MarkdownCache)
- reported_by_id = AlluraUserProperty(if_missing=lambda: c.user._id)
- assigned_to_id = AlluraUserProperty(if_missing=None)
+ reported_by_id: ObjectId = AlluraUserProperty(if_missing=lambda: c.user._id)
+ assigned_to_id: ObjectId = AlluraUserProperty(if_missing=None)
milestone = FieldProperty(str, if_missing='')
status = FieldProperty(str, if_missing='')
custom_fields = FieldProperty({str: None})