-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* FEATURE: REST API * REFACTOR: disable nexted write * FEATURE: add owner filter - wip * FEATURE: add repo events and statistics - wip * FIX: add repo size unit to statistic * FEATURE: add openapi schema * FEATURE: update requirements * FEATURE: API * FIX: update deps * STYLE: fix pep * FIX: move migrations * FEATURE: bump release Co-authored-by: Benjamin Pereto <[email protected]>
- Loading branch information
Showing
41 changed files
with
865 additions
and
98 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
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,2 @@ | ||
borgbackup==1.1.14 | ||
mysql-connector==2.2.9 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,6 @@ | ||
# | ||
# This file is autogenerated by pip-compile | ||
# To update, run: | ||
# | ||
# pip-compile requirements-dev.txt | ||
# | ||
astroid==2.4.1 # via -r requirements-dev.txt, pylint | ||
certifi==2020.4.5.1 # via -r requirements-dev.txt | ||
chardet==3.0.4 # via -r requirements-dev.txt | ||
commonmark==0.9.1 # via -r requirements-dev.txt | ||
coverage==5.1 # via -r requirements-dev.txt | ||
docutils==0.16 # via -r requirements-dev.txt | ||
idna==2.9 # via -r requirements-dev.txt | ||
isort==4.3.21 # via -r requirements-dev.txt, pylint | ||
lazy-object-proxy==1.4.3 # via -r requirements-dev.txt, astroid | ||
markupsafe==1.1.1 # via -r requirements-dev.txt | ||
mccabe==0.6.1 # via -r requirements-dev.txt, pylama, pylint | ||
pycodestyle==2.5.0 # via -r requirements-dev.txt, pylama | ||
pydocstyle==5.0.2 # via -r requirements-dev.txt, pylama | ||
pyflakes==2.2.0 # via -r requirements-dev.txt, pylama | ||
pylama==7.7.1 # via -r requirements-dev.txt | ||
pylint-django==2.0.15 # via -r requirements-dev.txt | ||
pylint-plugin-utils==0.6 # via -r requirements-dev.txt, pylint-django | ||
pylint==2.5.2 # via -r requirements-dev.txt, pylint-django, pylint-plugin-utils | ||
pyparsing==2.4.7 # via -r requirements-dev.txt | ||
pytz==2020.1 # via -r requirements-dev.txt | ||
six==1.14.0 # via -r requirements-dev.txt, astroid | ||
snowballstemmer==2.0.0 # via pydocstyle | ||
toml==0.10.0 # via -r requirements-dev.txt, pylint | ||
urllib3==1.25.9 # via -r requirements-dev.txt | ||
wrapt==1.12.1 # via -r requirements-dev.txt, astroid | ||
pylint | ||
astroid | ||
pylama | ||
pylint-django | ||
pylint-plugin-utils | ||
coverage |
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 @@ | ||
celery==5.0.5 | ||
django-celery-beat==2.1.0 | ||
django-crispy-forms==1.10.0 | ||
django-extensions==3.1.0 | ||
django-ldapdb==1.5.1 | ||
django-login-required-middleware==0.5.0 | ||
django-polymorphic==3.0.0 | ||
django==3.1.4 | ||
djangorestframework-queryfields==1.0.0 | ||
djangorestframework==3.12.2 | ||
environs==9.2.0 | ||
inotify==0.2.10 | ||
mysqlclient==2.0.2 | ||
pyyaml==5.3.1 | ||
redis==3.5.3 | ||
requests==2.25.1 | ||
rules==2.2 | ||
sshpubkeys==3.1.0 | ||
uritemplate==3.0.1 |
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 @@ | ||
default_app_config = 'api.apps.ApiConfig' |
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,8 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class ApiConfig(AppConfig): | ||
""" | ||
django app config for drf api | ||
""" | ||
name = 'api' |
Empty file.
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,94 @@ | ||
''' | ||
Definition of the REST framework serializers. | ||
''' | ||
|
||
__all__ = ( | ||
'SimpleModelSerializer', | ||
'SimpleHyperlinkedModelSerializer', | ||
) | ||
|
||
from drf_queryfields import QueryFieldsMixin | ||
from rest_framework.serializers import (HyperlinkedModelSerializer, | ||
HyperlinkedRelatedField, | ||
ModelSerializer, ReadOnlyField) | ||
from rest_framework.utils.field_mapping import get_nested_relation_kwargs | ||
|
||
# pylint: disable=redefined-builtin | ||
|
||
NAMESPACE = 'api' | ||
|
||
|
||
class SimpleModelSerializer(QueryFieldsMixin, ModelSerializer): # pylint: disable=too-few-public-methods | ||
''' | ||
A REST framework `ModelSerializer` on dope, which automatically initializes | ||
the Meta class of the serializer, based on the arguments provided in the | ||
constructor. | ||
''' | ||
namespace = NAMESPACE | ||
|
||
def __init__(self, *args, model=None, fields=None, **kwargs): | ||
''' | ||
Initialize the Meta class before initializing the serializer. | ||
''' | ||
|
||
if not hasattr(self, 'Meta'): | ||
self.Meta = type('Meta', (), {'model': model, 'fields': fields}) # pylint: disable=invalid-name | ||
|
||
super().__init__(*args, **kwargs) | ||
|
||
def build_url_field(self, field_name, model_class): | ||
''' | ||
Create a field representing the object's own URL. | ||
Please note this method is overloaded to add the namespace to the view | ||
name. | ||
''' | ||
field_class, field_kwargs = super().build_url_field(field_name, model_class) | ||
field_kwargs['view_name'] = '{}:{}'.format(self.namespace, field_kwargs['view_name']) | ||
return field_class, field_kwargs | ||
|
||
def build_relational_field(self, field_name, relation_info): | ||
field_class, field_kwargs = super().build_relational_field(field_name, relation_info) | ||
|
||
if hasattr(field_kwargs, 'view_name'): | ||
field_kwargs['view_name'] = '{}:{}'.format(self.namespace, field_kwargs['view_name']) | ||
|
||
return field_class, field_kwargs | ||
|
||
|
||
class SimpleHyperlinkedRelatedField(HyperlinkedRelatedField): | ||
""" | ||
A REST framework `HyperlinkedRelatedField` to support namespaces | ||
""" | ||
|
||
namespace = NAMESPACE | ||
|
||
def __init__(self, *args, **kwargs): | ||
kwargs['view_name'] = self.namespace + ':' + kwargs['view_name'] | ||
super().__init__(*args, **kwargs) | ||
|
||
|
||
class SimpleHyperlinkedModelSerializer(SimpleModelSerializer, HyperlinkedModelSerializer): # pylint: disable=too-few-public-methods | ||
''' | ||
A REST framework `HyperlinkedModelSerializer` on dope, which automatically | ||
initializes the Meta class of the serializer, based on the arguments | ||
provided in the constructor. | ||
''' | ||
serializer_related_field = SimpleHyperlinkedRelatedField | ||
|
||
id = ReadOnlyField() | ||
|
||
def build_nested_field(self, field_name, relation_info, nested_depth): | ||
""" | ||
Create nested fields for forward and reverse relationships. | ||
""" | ||
class NestedSerializer(SimpleHyperlinkedModelSerializer): # pylint: disable=too-few-public-methods,missing-docstring | ||
class Meta: # pylint: disable=too-few-public-methods,missing-docstring | ||
model = relation_info.related_model | ||
depth = nested_depth - 1 | ||
fields = '__all__' | ||
|
||
field_class = NestedSerializer | ||
field_kwargs = get_nested_relation_kwargs(relation_info) | ||
|
||
return field_class, field_kwargs |
Oops, something went wrong.