From c729b6b91629dcbc50d26875e1e3dc558e5200df Mon Sep 17 00:00:00 2001 From: Tehom Date: Sat, 30 Jun 2018 02:31:47 -0400 Subject: [PATCH] Add on missing values and values_list methods while we're at it, for the same reasons. --- evennia/typeclasses/managers.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/evennia/typeclasses/managers.py b/evennia/typeclasses/managers.py index d6a08de16d..be9a6dd2c4 100644 --- a/evennia/typeclasses/managers.py +++ b/evennia/typeclasses/managers.py @@ -621,7 +621,7 @@ class TypeclassManager(TypedObjectManager): def annotate(self, *args, **kwargs): """ - Overload annotate method to first call .all() to filter on typeclass before annotating. + Overload annotate method to filter on typeclass before annotating. Args: *args (any): Positional arguments passed along to queryset annotate method. **kwargs (any): Keyword arguments passed along to queryset annotate method. @@ -631,6 +631,30 @@ class TypeclassManager(TypedObjectManager): """ return super(TypeclassManager, self).filter(db_typeclass_path=self.model.path).annotate(*args, **kwargs) + def values(self, *args, **kwargs): + """ + Overload values method to filter on typeclass first. + Args: + *args (any): Positional arguments passed along to values method. + **kwargs (any): Keyword arguments passed along to values method. + + Returns: + Queryset of values dictionaries, just filtered by typeclass first. + """ + return super(TypeclassManager, self).filter(db_typeclass_path=self.model.path).values(*args, **kwargs) + + def values_list(self, *args, **kwargs): + """ + Overload values method to filter on typeclass first. + Args: + *args (any): Positional arguments passed along to values_list method. + **kwargs (any): Keyword arguments passed along to values_list method. + + Returns: + Queryset of value_list tuples, just filtered by typeclass first. + """ + return super(TypeclassManager, self).filter(db_typeclass_path=self.model.path).values_list(*args, **kwargs) + def _get_subclasses(self, cls): """ Recursively get all subclasses to a class.