-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic decorators for realm connection Add realm_connection decorator to ResponseProcessor and SessionManager Add initial documentation structure Remove django-tenant-schemas dependency from project (make it as optional)
- Loading branch information
Showing
23 changed files
with
375 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
## [0.6.0] - 2020-02-12 | ||
|
||
### Added | ||
|
||
- Add ValidationError handling | ||
- Add basic decorators for realm connection | ||
- Add realm_connection decorator to ResponseProcessor and SessionManager | ||
- Add initial documentation structure | ||
|
||
### Removed | ||
|
||
- Remove django-tenant-schemas dependency from project (make it as optional) | ||
|
||
|
||
[0.6.0]: https://github.com/weltlink/django-quickbooks/compare/0.5...0.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from django.db import connection | ||
|
||
from django_quickbooks.settings import qbwc_settings | ||
|
||
|
||
def realm_connection(): | ||
return qbwc_settings.REALM_CONNECTION_DECORATOR | ||
|
||
|
||
def base_realm_connection(func): | ||
def connect(realm, *args, **kwargs): | ||
return func(realm, *args, **kwargs) | ||
|
||
return connect | ||
|
||
|
||
def base_realm_tenant_connection(func): | ||
def connect(realm, *args, **kwargs): | ||
if hasattr(realm, 'schema_name') and hasattr(connection, 'set_schema'): | ||
connection.set_schema(realm.schema_name) | ||
return func(realm, *args, **kwargs) | ||
|
||
return connect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,54 @@ | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
|
||
class ValidationCode: | ||
REQUIRED = 'required' | ||
MIN_LENGTH = 'min_length' | ||
MAX_LENGTH = 'max_length' | ||
INVALID_TYPE = 'invalid_type' | ||
|
||
|
||
VALIDATION_MESSAGES = { | ||
ValidationCode.REQUIRED: _('This field is required'), | ||
ValidationCode.MIN_LENGTH: _('The minimum length for the field is %s'), | ||
ValidationCode.MAX_LENGTH: _('The maximum length for the field is %s'), | ||
ValidationCode.INVALID_TYPE: _('Invalid type %s for the field type %s'), | ||
} | ||
|
||
|
||
def _get_error_details(detail, code): | ||
return {code: detail} | ||
|
||
|
||
class QbException(Exception): | ||
def __init__(self, error): | ||
self.error = error | ||
|
||
|
||
class ValidationError(Exception): | ||
pass | ||
default_detail = _('Invalid attribute.') | ||
default_code = 'invalid' | ||
|
||
def __init__(self, detail=None, code=None): | ||
if detail is None: | ||
detail = self.default_detail | ||
if code is None: | ||
code = self.default_code | ||
|
||
# Several errors may be collected together, thus | ||
if not isinstance(detail, dict) and not isinstance(detail, list): | ||
detail = [detail] | ||
|
||
self.detail = _get_error_details(detail, code) | ||
|
||
|
||
class ValidationOptionNotFound(Exception): | ||
class ValidationOptionNotFound(QbException): | ||
pass | ||
|
||
|
||
class QBXMLParseError(Exception): | ||
class QBXMLParseError(QbException): | ||
pass | ||
|
||
|
||
class QBXMLStatusError(Exception): | ||
class QBXMLStatusError(QbException): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.