diff --git a/.travis.yml b/.travis.yml index 9b1fb2277..0a580df42 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/doc/upgrade.rst b/doc/upgrade.rst index b8e272ecb..48c5b3170 100644 --- a/doc/upgrade.rst +++ b/doc/upgrade.rst @@ -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 diff --git a/modoboa/admin/api.py b/modoboa/admin/api.py index f7002bedb..27432a663 100644 --- a/modoboa/admin/api.py +++ b/modoboa/admin/api.py @@ -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, ] diff --git a/modoboa/admin/serializers.py b/modoboa/admin/serializers.py index 5c6aee1b9..5a0608874 100644 --- a/modoboa/admin/serializers.py +++ b/modoboa/admin/serializers.py @@ -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 diff --git a/modoboa/core/commands/templates/settings.py.tpl b/modoboa/core/commands/templates/settings.py.tpl index 4d281cfe0..4f3b09009 100644 --- a/modoboa/core/commands/templates/settings.py.tpl +++ b/modoboa/core/commands/templates/settings.py.tpl @@ -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 diff --git a/modoboa/core/templates/core/api_access.html b/modoboa/core/templates/core/api_access.html index d0669a7b6..b2bae6495 100644 --- a/modoboa/core/templates/core/api_access.html +++ b/modoboa/core/templates/core/api_access.html @@ -2,6 +2,12 @@