Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
gm-serializer
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gushitong
gm-serializer
Commits
da9adda2
Commit
da9adda2
authored
Jul 12, 2017
by
gushitong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix
parent
2c6c19d5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
34 deletions
+4
-34
__init__.py
gm_serializer/__init__.py
+1
-1
accessor.py
gm_serializer/fields/accessor.py
+3
-0
__init__.py
gm_serializer/serializers/__init__.py
+0
-2
validator.py
gm_serializer/serializers/validator.py
+0
-31
No files found.
gm_serializer/__init__.py
View file @
da9adda2
__version__
=
'0.0.
3
'
__version__
=
'0.0.
4
'
__author__
=
'gushitong@gmei.com'
gm_serializer/fields/accessor.py
View file @
da9adda2
...
...
@@ -56,7 +56,10 @@ class MagicAccessor(CacheAccessor):
return
DictWrapper
(
obj
)
logger
.
debug
(
"Magic CacheMiss:
%
s"
%
self
.
pk_list
)
try
:
obj
=
self
.
manager
(
pk_list
=
self
.
pk_list
)[
0
]
except
IndexError
:
return
None
self
.
cache
[
obj
[
'id'
]]
=
obj
return
DictWrapper
(
obj
)
...
...
gm_serializer/serializers/__init__.py
View file @
da9adda2
...
...
@@ -2,6 +2,5 @@
from
rest_framework.serializers
import
*
from
.serializer
import
MagicSerializer
from
.field
import
MagicField
from
.validator
import
BlacklistValidator
,
FilterWordValidator
from
gm_serializer.error
import
MagicObjNotExist
,
MultiMagicObjFound
\ No newline at end of file
gm_serializer/serializers/validator.py
deleted
100644 → 0
View file @
2c6c19d5
from
rest_framework
import
serializers
from
gm_serializer.utils
import
RPCMixin
class
BlacklistValidator
(
RPCMixin
):
def
__call__
(
self
,
value
):
try
:
r
=
self
.
call_rpc
(
'api/user/in_blacklist'
,
user_id
=
value
)
except
:
return
False
if
r
:
raise
serializers
.
ValidationError
(
"User in blacklist."
)
class
FilterWordValidator
(
RPCMixin
):
def
__init__
(
self
,
filter_type
=
None
):
self
.
filter_type
=
filter_type
def
__call__
(
self
,
value
):
try
:
r
=
self
.
call_rpc
(
'api/filterWord/list'
,
filter_type
=
self
.
filter_type
)
except
:
return
False
if
r
:
raise
serializers
.
ValidationError
(
"Content contains sensitive words."
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment