Skip to content

Commit 19b1232

Browse files
committed
Merge branch 'develop': v1.0.0
2 parents 4eda75c + 91dcbf5 commit 19b1232

31 files changed

+685
-640
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
dist: trusty
21
language: python
32
python:
43
- '3.6'
54
- '3.7'
6-
- 'pypy'
5+
- '3.8'
76
install:
87
- pip install -r requirements.txt
98
- pip install coveralls coverage

CHANGELOG.rst

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Changelog
22
*********
33

4+
5+
**1.0.0**
6+
=========
7+
8+
Changes
9+
=======
10+
11+
* Rename Flask-REST-JSONAPI to Flask-COMBO-JSONAPI #- `@mahenzon`_
12+
13+
414
**0.1.1**
515
=========
616

@@ -21,14 +31,14 @@ Bug Fixes
2131
* Fix sorting in plugin `PostgreSqlJSONB`_ #- `@Znbiz`_
2232
* Improved model fields check for options(load_only) in `Permission`_ #- `@Znbiz`_
2333
* Implement disable_global_decorators, minor refactor and upgrade events, update docs in plugin
24-
`EventPlugin`_ #- `@Suren Khorenyan`_
34+
`EventPlugin`_ #- `@mahenzon`_
2535
* typo permission_for_path -> permission_for_patch and create get_decorators_for_resource
26-
in plugin `Permission`_ #- `@Suren Khorenyan`_
27-
* Create status util #- `@Suren Khorenyan`_
28-
* Refactor api spec params for get in plugin `ApiSpecPlugin`_ #- `@Suren Khorenyan`_
29-
* Fix permission plugin initialization #- `@Suren Khorenyan`_
30-
* Constant splitter for filters, sorts and includes #- `@Suren Khorenyan`_
31-
* Configure setup, update .gitignore #- `@Suren Khorenyan`_
36+
in plugin `Permission`_ #- `@mahenzon`_
37+
* Create status util #- `@mahenzon`_
38+
* Refactor api spec params for get in plugin `ApiSpecPlugin`_ #- `@mahenzon`_
39+
* Fix permission plugin initialization #- `@mahenzon`_
40+
* Constant splitter for filters, sorts and includes #- `@mahenzon`_
41+
* Configure setup, update .gitignore #- `@mahenzon`_
3242

3343
**0.1.0**
3444
=========
@@ -49,6 +59,6 @@ Enhancements
4959
.. _`ApiSpecPlugin`: https://github.com/AdCombo/ComboJSONAPI/docs/api_spec_plugin.rst
5060
.. _`Permission`: https://github.com/AdCombo/ComboJSONAPI/docs/permission_plugin.rst
5161

52-
.. _`@Suren Khorenyan`: https://github.com/mahenzon
62+
.. _`@mahenzon`: https://github.com/mahenzon
5363
.. _`@Znbiz`: https://github.com/znbiz
5464
.. _`@Yakov Shapovalov`: https://github.com/photovirus

README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
.. image:: https://travis-ci.org/AdCombo/combojsonapi.svg?branch=develop
2+
:target: https://travis-ci.org/AdCombo/combojsonapi
3+
.. image:: https://coveralls.io/repos/github/AdCombo/combojsonapi/badge.svg?branch=develop
4+
:target: https://coveralls.io/github/AdCombo/combojsonapi?branch=develop
5+
16
ComboJSONAPI
27
============
38
ComboJSONAPI is a set of plugins made for `Flask-JSONAPI <https://github.com/AdCombo/flask-jsonapi>`_ module.

combojsonapi/event/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from combojsonapi.event.plugin import EventSchema, EventPlugin
22

33
__all__ = [
4-
'EventSchema',
5-
'EventPlugin',
4+
"EventSchema",
5+
"EventPlugin",
66
]

combojsonapi/event/plugin.py

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
from marshmallow import Schema
55

6-
from flask_rest_jsonapi.plugin import BasePlugin
7-
from flask_rest_jsonapi.resource import Resource
8-
from flask_rest_jsonapi.utils import SPLIT_REL
9-
from flask_rest_jsonapi.exceptions import PluginMethodNotImplementedError
6+
from flask_combo_jsonapi.plugin import BasePlugin
7+
from flask_combo_jsonapi.resource import Resource
8+
from flask_combo_jsonapi.utils import SPLIT_REL
9+
from flask_combo_jsonapi.exceptions import PluginMethodNotImplementedError
1010

1111
from combojsonapi.utils import get_decorators_for_resource
1212

@@ -16,7 +16,6 @@ class EventSchema(Schema):
1616

1717

1818
class EventPlugin(BasePlugin):
19-
2019
def __init__(self, trailing_slash: bool = True):
2120
"""
2221
@@ -25,6 +24,7 @@ def __init__(self, trailing_slash: bool = True):
2524
self.trailing_slash = trailing_slash
2625

2726
"""Plugin for events routes in json_api"""
27+
2828
@classmethod
2929
def _events_with_methods(cls, cls_events) -> Generator[Tuple[Any, str], None, None]:
3030
"""
@@ -35,35 +35,39 @@ def _events_with_methods(cls, cls_events) -> Generator[Tuple[Any, str], None, No
3535
"""
3636
for attr_name in dir(cls_events):
3737
method = None
38-
if attr_name.startswith('event_get_'):
39-
method = 'GET'
40-
elif attr_name.startswith('event_'):
38+
if attr_name.startswith("event_get_"):
39+
method = "GET"
40+
elif attr_name.startswith("event_"):
4141
# Processing all other events. May be event_post_smth or just event_smth
42-
method = 'POST'
42+
method = "POST"
4343
if method is not None:
4444
yield getattr(cls_events, attr_name), method
4545

4646
def _create_event_resource(self, base_resource, event, method, view, urls, self_json_api, **kwargs):
4747
# noinspection PyTypeChecker
48-
new_resource: Resource = type(event.__name__, (base_resource,), {
49-
'methods': [method],
50-
'schema': None,
51-
method.lower(): event,
52-
'event': True,
53-
})
48+
new_resource: Resource = type(
49+
event.__name__,
50+
(base_resource,),
51+
{
52+
"methods": [method],
53+
"schema": None,
54+
method.lower(): event,
55+
"event": True,
56+
},
57+
)
5458

5559
new_resource.decorators = get_decorators_for_resource(base_resource, self_json_api)
5660

57-
i_view = f'{view}_{event.__name__}'
61+
i_view = f"{view}_{event.__name__}"
5862
view_func = new_resource.as_view(i_view)
5963

60-
url_rule_options = kwargs.get('url_rule_options') or {}
64+
url_rule_options = kwargs.get("url_rule_options") or {}
6165

6266
event_urls = []
6367
for i_url in urls:
6468
i_new_url = urllib.parse.urljoin(i_url, event.__name__)
65-
i_new_url = i_new_url[:-1] if i_new_url[-1] == '/' else i_new_url
66-
i_new_url = i_new_url + '/' if self.trailing_slash else i_new_url
69+
i_new_url = i_new_url[:-1] if i_new_url[-1] == "/" else i_new_url
70+
i_new_url = i_new_url + "/" if self.trailing_slash else i_new_url
6771
event_urls.append(i_new_url)
6872
event_urls = tuple(event_urls)
6973

@@ -75,12 +79,14 @@ def _create_event_resource(self, base_resource, event, method, view, urls, self_
7579
for url in event_urls:
7680
self_json_api.app.add_url_rule(url, view_func=view_func, **url_rule_options)
7781
else:
78-
self_json_api.resources.append({
79-
'resource': new_resource,
80-
'view': i_view,
81-
'urls': event_urls,
82-
'url_rule_options': url_rule_options,
83-
})
82+
self_json_api.resources.append(
83+
{
84+
"resource": new_resource,
85+
"view": i_view,
86+
"urls": event_urls,
87+
"url_rule_options": url_rule_options,
88+
}
89+
)
8490

8591
self_json_api.resource_registry.append(new_resource)
8692

@@ -106,7 +112,7 @@ def before_route(self, resource=None, view=None, urls=None, self_json_api=None,
106112
:param kwargs:
107113
:return:
108114
"""
109-
if not hasattr(resource, 'events'):
115+
if not hasattr(resource, "events"):
110116
return
111117

112118
for event, method in self._events_with_methods(resource.events):

combojsonapi/permission/__init__.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
from combojsonapi.permission.permission_system import (PermissionToMapper, PermissionFields, PermissionForPatch,
2-
PermissionForPost, PermissionForGet, PermissionUser,
3-
PermissionMixin)
1+
from combojsonapi.permission.permission_system import (
2+
PermissionToMapper,
3+
PermissionFields,
4+
PermissionForPatch,
5+
PermissionForPost,
6+
PermissionForGet,
7+
PermissionUser,
8+
PermissionMixin,
9+
)
410

511
from combojsonapi.permission.permission_plugin import PermissionPlugin
612

713
__all__ = [
8-
'PermissionPlugin',
9-
'PermissionToMapper',
10-
'PermissionFields',
11-
'PermissionForPatch',
12-
'PermissionForPost',
13-
'PermissionForGet',
14-
'PermissionUser',
15-
'PermissionMixin',
14+
"PermissionPlugin",
15+
"PermissionToMapper",
16+
"PermissionFields",
17+
"PermissionForPatch",
18+
"PermissionForPost",
19+
"PermissionForGet",
20+
"PermissionUser",
21+
"PermissionMixin",
1622
]

0 commit comments

Comments
 (0)