File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ class User(models.Model):
11
11
_lng = models .FloatField (default = 0 )
12
12
_permissions = models .CharField (max_length = 30 , blank = True )
13
13
14
+ @property
15
+ def reverse_username (self ):
16
+ return self .username [::- 1 ]
17
+
14
18
def location (self ):
15
19
return self ._lat , self ._lng
16
20
Original file line number Diff line number Diff line change @@ -80,6 +80,14 @@ class UserIndex(AlgoliaIndex):
80
80
obj = index .get_raw_record (self .user )
81
81
self .assertEqual (obj ['objectID' ], 'algolia' )
82
82
83
+ def test_custom_objectID_property (self ):
84
+ class UserIndex (AlgoliaIndex ):
85
+ custom_objectID = 'reverse_username'
86
+
87
+ index = UserIndex (User , self .client , settings .ALGOLIA )
88
+ obj = index .get_raw_record (self .user )
89
+ self .assertEqual (obj ['objectID' ], 'ailogla' )
90
+
83
91
def test_invalid_custom_objectID (self ):
84
92
class UserIndex (AlgoliaIndex ):
85
93
custom_objectID = 'uid'
You can’t perform that action at this time.
0 commit comments