Merge pull request #1079 from modoboa/feature/drf_36

DRF 3.6.2
This commit is contained in:
Antoine Nguyen
2017-03-16 17:23:29 +01:00
committed by GitHub
9 changed files with 43 additions and 57 deletions
+2 -1
View File
@@ -24,9 +24,10 @@ before_install:
- if [[ $DB = 'MYSQL' ]]; then pip install -q mysqlclient; fi
install:
- python setup.py -q develop
- pip install -q -r requirements.txt
- pip install -q -r ldap-requirements.txt
- pip install -q -r test-requirements.txt
- pip install -e .
before_script:
- if [[ $DB = 'POSTGRESQL' ]]; then psql -c 'create database modoboa_test;' -U postgres; fi
+19 -4
View File
@@ -87,12 +87,14 @@ Specific instructions
1.7.2
=====
CKeditor is now embedded by default (thanks to the ``django-ckeditor``
package) and some configuration changes are required to make it work.
API documentation has evolved (because of the upgrade to Django Rest
Framework 3.6) and CKeditor is now embedded by default (thanks to the
``django-ckeditor`` package). Some configuration changes are
required.
Edit your :file:`settings.py` file and apply the following modifications:
* Add ``ckeditor`` and ``ckeditor_uploader`` to ``INSTALLED_APPS``
* Update the ``INSTALLED_APPS`` variable as follows:
.. sourcecode:: python
@@ -106,10 +108,23 @@ Edit your :file:`settings.py` file and apply the following modifications:
'reversion',
'ckeditor',
'ckeditor_uploader',
'rest_framework',
'rest_framework.authtoken',
'rest_framework_swagger',
)
* Update the ``REST_FRAMEWORK`` variable as follows:
.. sourcecode:: python
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
),
}
* Remove the ``SWAGGER_SETTINGS`` variable
* Add the following content
.. sourcecode:: python
+2 -28
View File
@@ -120,35 +120,9 @@ class AccountViewSet(viewsets.ModelViewSet):
class AliasViewSet(viewsets.ModelViewSet):
"""ViewSet for Alias.
---
"""
create:
serializer: modoboa.admin.serializers.AliasSerializer
parameters:
- name: recipients
description: recipient(s) of the alias
required: true
type: array[string]
paramType: form
update:
serializer: modoboa.admin.serializers.AliasSerializer
parameters:
- name: recipients
description: recipient(s) of the alias
required: true
type: array[string]
paramType: form
partial_update:
serializer: modoboa.admin.serializers.AliasSerializer
parameters:
- name: recipients
description: recipient(s) of the alias
required: true
type: array[string]
paramType: form
Create a new alias instance.
"""
permission_classes = [IsAuthenticated, DjangoModelPermissions, ]
+3 -2
View File
@@ -2,7 +2,7 @@
from django.core.exceptions import ValidationError
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext as _, ugettext_lazy
from rest_framework import serializers
from passwords import validators
@@ -317,7 +317,8 @@ class AliasSerializer(serializers.ModelSerializer):
address = lib_fields.DRFEmailFieldUTF8AndEmptyUser()
recipients = serializers.ListField(
child=lib_fields.DRFEmailFieldUTF8AndEmptyUser(),
allow_empty=False)
allow_empty=False,
help_text=ugettext_lazy("A list of recipient"))
class Meta:
model = admin_models.Alias
@@ -50,8 +50,8 @@ INSTALLED_APPS = (
'reversion',
'ckeditor',
'ckeditor_uploader',
'rest_framework',
'rest_framework.authtoken',
'rest_framework_swagger',
{% if devmode %} 'djangobower',{% endif %}
)
@@ -167,25 +167,8 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
)
}
SWAGGER_SETTINGS = {
"is_authenticated": False,
"api_version": "1.0",
"exclude_namespaces": [],
"info": {
"contact": "contact@modoboa.com",
"description": (
"Modoboa API, requires a valid token. To obtain a token, login "
"as super administrator, go to 'User settings > API' and enable "
"API access. Click on 'Update' and wait for page refresh."
),
"title": "Modoboa API documentation",
}
}
# Modoboa settings
@@ -2,6 +2,12 @@
<h2>{% trans "API access" %} <small>{% trans "Control your access to Modoboa API" %}</small></h2>
<hr>
<div class="alert alert-info">
{% url "api-docs:docs-index" as api_doc_url %}
{% blocktrans with url=api_doc_url trimmed %}
A documentation of the API is available <strong><a href="{{ url }}" target="_blank">here</a></strong>.
{% endblocktrans %}
</div>
{% if user.auth_token %}
<div class="panel panel-default">
<div class="panel-heading">
+4 -1
View File
@@ -5,11 +5,14 @@ from django.views.i18n import JavaScriptCatalog
from django.contrib.auth.decorators import login_required
from ckeditor_uploader import views as cku_views
from rest_framework.documentation import include_docs_urls
from modoboa.admin.views.user import forward
from modoboa.core.extensions import exts_pool
from modoboa.core import signals as core_signals
API_TITLE = 'Modoboa API'
urlpatterns = [
url(r'^jsi18n/$', JavaScriptCatalog.as_view(), name='javascript-catalog'),
url(r'^ckeditor/upload/', login_required(cku_views.upload),
@@ -33,8 +36,8 @@ if extra_routes:
# API urls
urlpatterns += [
url("^docs/api/", include_docs_urls(title=API_TITLE)),
url("^api/v1/", include("modoboa.urls_api", namespace="external_api")),
url("^docs/api/", include('rest_framework_swagger.urls')),
]
if settings.DEBUG:
+3 -2
View File
@@ -8,8 +8,9 @@ django-xforwardedfor-middleware
dj-database-url
djangorestframework==3.5.3
django-rest-swagger==0.3.10
coreapi==2.3.0
coreapi-cli==1.0.6
djangorestframework==3.6.2
argparse
# bcrypt requires libffi-dev
+2
View File
@@ -45,6 +45,7 @@ INSTALLED_APPS = (
'django.contrib.sites',
'django.contrib.staticfiles',
'reversion',
'rest_framework',
'rest_framework.authtoken'
)
@@ -141,6 +142,7 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',