Skip to content

Commit

Permalink
Codestyle improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
cristian-g committed Jul 13, 2019
1 parent 0d6fa23 commit b860010
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 556 deletions.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -130,6 +130,11 @@ Otherwise, in case you are just developing, just run ```yarn``` in order to inst
- Open-source alpha release (June) - Done
- Beta release (July)

## Compatibility

- Odoo v12
- Vue Storefront v1.9.2

## The license

Odoo module for Vue Storefront source code is completely free and released under the [MIT License](https://github.com/cristian-g/vsf-odoo/blob/master/LICENSE).
Expand Down
2 changes: 1 addition & 1 deletion __manifest__.py
@@ -1,6 +1,6 @@
{
'name': 'Vue Storefront API',
'version': '0.0.1',
'version': '0.0.2',
'category': 'API',
'author': 'Cristian González Ruz',
'website': 'http://cristiangonzalez.com',
Expand Down
203 changes: 3 additions & 200 deletions common.py
Expand Up @@ -8,8 +8,7 @@
color_attribute_name = "Color"

def valid_response(data, status=200):
"""Valid Response
This will be return when the http request was successfully processed."""
"""Valid response - This will be returned when the http request is successfully processed."""
hits = []
for hit in data:
hits.append({
Expand All @@ -26,185 +25,7 @@ def valid_response(data, status=200):
'total': len(data),
'took': 7,
'start': 0,
'perPage': len(data),
"aggregations":{
"agg_terms_price":{
"doc_count_error_upper_bound":0,
"sum_other_doc_count":1,
"buckets":[
{
"key":42,
"doc_count":1
},
{
"key":45,
"doc_count":1
},
{
"key":47,
"doc_count":1
},
{
"key":49,
"doc_count":1
},
{
"key":51,
"doc_count":1
},
{
"key":56.9900016784668,
"doc_count":1
},
{
"key":60,
"doc_count":1
},
{
"key":65,
"doc_count":1
},
{
"key":66,
"doc_count":1
},
{
"key":72,
"doc_count":1
}
]
},
"agg_terms_erin_recommends":{
"doc_count_error_upper_bound":0,
"sum_other_doc_count":0,
"buckets":[
{
"key":0,
"doc_count":9
},
{
"key":1,
"doc_count":2
}
]
},
"agg_terms_color_options":{
"doc_count_error_upper_bound":0,
"sum_other_doc_count":0,
"buckets":[
{
"key":49,
"doc_count":6
},
{
"key":58,
"doc_count":6
},
{
"key":50,
"doc_count":5
},
{
"key":53,
"doc_count":5
},
{
"key":56,
"doc_count":4
},
{
"key":60,
"doc_count":3
},
{
"key":57,
"doc_count":2
},
{
"key":52,
"doc_count":1
},
{
"key":59,
"doc_count":1
}
]
},
"agg_range_price":{
"buckets":[
{
"key":"0.0-50.0",
"from":0,
"to":50,
"doc_count":4
},
{
"key":"50.0-100.0",
"from":50,
"to":100,
"doc_count":7
},
{
"key":"100.0-150.0",
"from":100,
"to":150,
"doc_count":0
},
{
"key":"150.0-*",
"from":150,
"doc_count":0
}
]
},
"agg_terms_size_options":{
"doc_count_error_upper_bound":0,
"sum_other_doc_count":0,
"buckets":[
{
"key":167,
"doc_count":11
},
{
"key":168,
"doc_count":11
},
{
"key":169,
"doc_count":11
},
{
"key":170,
"doc_count":11
},
{
"key":171,
"doc_count":11
}
]
},
"agg_terms_color":{
"doc_count_error_upper_bound":0,
"sum_other_doc_count":0,
"buckets":[

]
},
"agg_terms_erin_recommends_options":{
"doc_count_error_upper_bound":0,
"sum_other_doc_count":0,
"buckets":[

]
},
"agg_terms_size":{
"doc_count_error_upper_bound":0,
"sum_other_doc_count":0,
"buckets":[

]
}
}
'perPage': len(data)
}
return werkzeug.wrappers.Response(
status=status,
Expand All @@ -214,14 +35,6 @@ def valid_response(data, status=200):
('Access-Control-Allow-Methods', 'GET, POST, OPTIONS'),
('Access-Control-Allow-Headers', 'CONTENT-TYPE'),
('Access-Control-Allow-Methods', 'GET'),
#('Access-Control-Allow-Origin', 'http://localhost:3000'),
#('Cache-Control: no-cache', 'private'),
#('Connection', 'keep-alive'),
#('Content-Encoding', 'gzip'),
#('Content-Type: text/html', 'charset=UTF-8'),
#('Date', 'Wed, 13 Mar 2019 18:18:47 GMT'),
#('Server', 'nginx/1.13.6'),
#('Transfer-Encoding', 'chunked'),
],
response=json.dumps(data),
)
Expand All @@ -235,21 +48,12 @@ def simple_response(data, status=200):
('Access-Control-Allow-Methods', 'GET, POST, OPTIONS'),
('Access-Control-Allow-Headers', 'CONTENT-TYPE'),
('Access-Control-Allow-Methods', 'GET'),
#('Access-Control-Allow-Origin', 'http://localhost:3000'),
#('Cache-Control: no-cache', 'private'),
#('Connection', 'keep-alive'),
#('Content-Encoding', 'gzip'),
#('Content-Type: text/html', 'charset=UTF-8'),
#('Date', 'Wed, 13 Mar 2019 18:18:47 GMT'),
#('Server', 'nginx/1.13.6'),
#('Transfer-Encoding', 'chunked'),
],
response=json.dumps(data),
)

def invalid_response(typ, message=None, status=400):
"""Invalid Response
This will be the return value whenever the server runs into an error
"""Invalid response - This will be the returned value whenever the server runs into an error
either from the client or the server."""
return werkzeug.wrappers.Response(
status=status,
Expand All @@ -260,7 +64,6 @@ def invalid_response(typ, message=None, status=400):
}),
)


def extract_arguments(payload, offset=0, limit=0, order=None):
"""."""
fields, domain = [], []
Expand Down

0 comments on commit b860010

Please sign in to comment.