From c698b0798ba0ce202b3ba34771d5222fbffbfdc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Barrag=C3=A1n=20Merino?= Date: Wed, 7 Jun 2017 20:22:46 +0200 Subject: [PATCH] Upgrade requirements.txt --- requirements-devel.txt | 14 ++-- requirements.txt | 68 +++++++++---------- taiga/base/api/views.py | 1 - taiga/base/db/models/fields/json.py | 57 +--------------- taiga/base/exceptions.py | 20 +++--- taiga/base/utils/contenttypes.py | 4 +- taiga/base/utils/db.py | 1 - .../migrations/0003_auto_20170607_2320.py | 23 +++++++ taiga/external_apps/models.py | 5 +- taiga/mdrender/service.py | 2 +- tests/integration/test_memberships.py | 1 - 11 files changed, 82 insertions(+), 114 deletions(-) create mode 100644 taiga/external_apps/migrations/0003_auto_20170607_2320.py diff --git a/requirements-devel.txt b/requirements-devel.txt index ac4f42fe..fd85d617 100644 --- a/requirements-devel.txt +++ b/requirements-devel.txt @@ -1,13 +1,11 @@ -r requirements.txt -factory_boy==2.8.1 -py==1.4.32 -pytest==3.0.6 -pytest-django==3.1.2 -pytest-pythonpath==0.7.1 - -coverage==4.3.4 +coverage==4.4.1 coveralls==1.1 django-slowdown==0.0.1 - +factory_boy==2.8.1 +py==1.4.34 +pytest-django==3.1.2 +pytest-pythonpath==0.7.1 +pytest==3.1.1 transifex-client==0.12.4 diff --git a/requirements.txt b/requirements.txt index 493f2e46..6deed4bd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,43 +1,43 @@ -Django==1.10.6 #djangorestframework==2.3.13 # It's not necessary since Taiga 1.7 +CairoSVG==2.0.3 +Django==1.11.2 +Markdown==2.6.8 +Pillow==4.1.1 +PyJWT==1.5.0 +Unidecode==0.4.20 +amqp==2.1.4 +asana==0.6.5 +bleach==2.0.0 +celery==4.0.2 +cryptography==1.9 +cssutils==1.0.2 +diff-match-patch==20121119 +django-ipware==1.1.6 +django-jinja==2.3.1 django-picklefield==0.3.2 django-sampledatahelper==0.4.1 -gunicorn==19.6.0 -psycopg2==2.7 -Pillow==3.4.2 -pytz==2016.10 -six==1.10.0 -amqp==2.1.4 -djmail==1.0.1 -django-jinja==2.2.2 -jinja2==2.9.5 -pygments==2.2.0 django-sites==0.9 -Markdown==2.6.8 -fn==0.4.3 -diff-match-patch==20121119 -requests==2.13.0 -requests-oauthlib==0.8.0 -webcolors==1.7 django-sr==0.0.4 -easy-thumbnails==2.3 -celery==4.0.2 -redis==2.10.5 -Unidecode==0.4.20 -raven==6.0.0 -bleach==1.5.0 -django-ipware==1.1.6 -premailer==3.0.1 -cssutils==1.0.1 # Compatible with python 3.5 -lxml==3.7.3 +djmail==1.0.1 +easy-thumbnails==2.4.1 +fn==0.4.3 git+https://github.com/Xof/django-pglocks.git +gunicorn==19.7.1 +jinja2==2.9.6 +lxml==3.8.0 +netaddr==0.7.19 +premailer==3.0.1 +psd-tools==1.4 +psycopg2==2.7.1 +pygments==2.2.0 pyjwkest==1.3.2 python-dateutil==2.6.0 -netaddr==0.7.19 -serpy==0.1.1 -psd-tools==1.4 -CairoSVG==2.0.1 python-magic==0.4.13 -cryptography==1.7.1 -PyJWT==1.4.2 -asana==0.6.2 +pytz==2017.2 +raven==6.1.0 +redis==2.10.5 +requests-oauthlib==0.8.0 +requests==2.17.3 +serpy==0.1.1 +six==1.10.0 +webcolors==1.7 diff --git a/taiga/base/api/views.py b/taiga/base/api/views.py index cc42966b..f3040c4c 100644 --- a/taiga/base/api/views.py +++ b/taiga/base/api/views.py @@ -456,7 +456,6 @@ class APIView(View): handler = self.http_method_not_allowed response = handler(request, *args, **kwargs) - except Exception as exc: response = self.handle_exception(exc) diff --git a/taiga/base/db/models/fields/json.py b/taiga/base/db/models/fields/json.py index aa4fbe05..82d6e305 100644 --- a/taiga/base/db/models/fields/json.py +++ b/taiga/base/db/models/fields/json.py @@ -20,63 +20,10 @@ from django.core.serializers.json import DjangoJSONEncoder from django.contrib.postgres.fields import JSONField as DjangoJSONField -# NOTE: After upgrade Django to the future release (1.11) change -# class JSONField(FutureDjangoJSONField): -# to -# class JSONField(DjangoJSONField): -# and remove the classes JsonAdapter and FutureDjangoJSONField - -import json -from psycopg2.extras import Json -from django.core import exceptions - - -class JsonAdapter(Json): - """ - Customized psycopg2.extras.Json to allow for a custom encoder. - """ - def __init__(self, adapted, dumps=None, encoder=None): - self.encoder = encoder - super().__init__(adapted, dumps=dumps) - - def dumps(self, obj): - options = {'cls': self.encoder} if self.encoder else {} - return json.dumps(obj, **options) - - -class FutureDjangoJSONField(DjangoJSONField): - def __init__(self, verbose_name=None, name=None, encoder=None, **kwargs): - if encoder and not callable(encoder): - raise ValueError("The encoder parameter must be a callable object.") - self.encoder = encoder - super().__init__(verbose_name, name, **kwargs) - - def deconstruct(self): - name, path, args, kwargs = super().deconstruct() - if self.encoder is not None: - kwargs['encoder'] = self.encoder - return name, path, args, kwargs - - def get_prep_value(self, value): - if value is not None: - return JsonAdapter(value, encoder=self.encoder) - return value - - def validate(self, value, model_instance): - super().validate(value, model_instance) - options = {'cls': self.encoder} if self.encoder else {} - try: - json.dumps(value, **options) - except TypeError: - raise exceptions.ValidationError( - self.error_messages['invalid'], - code='invalid', - params={'value': value}, - ) - __all__ = ["JSONField"] -class JSONField(FutureDjangoJSONField): + +class JSONField(DjangoJSONField): def __init__(self, verbose_name=None, name=None, encoder=DjangoJSONEncoder, **kwargs): super().__init__(verbose_name, name, encoder, **kwargs) diff --git a/taiga/base/exceptions.py b/taiga/base/exceptions.py index 12310baa..17c940d5 100644 --- a/taiga/base/exceptions.py +++ b/taiga/base/exceptions.py @@ -252,17 +252,17 @@ def exception_handler(exc): """ if isinstance(exc, APIException): - headers = {} - if getattr(exc, "auth_header", None): - headers["WWW-Authenticate"] = exc.auth_header - if getattr(exc, "wait", None): - headers["X-Throttle-Wait-Seconds"] = "%d" % exc.wait - if getattr(exc, "project_data", None): - headers["Taiga-Info-Project-Memberships"] = exc.project_data["total_memberships"] - headers["Taiga-Info-Project-Is-Private"] = exc.project_data["is_private"] + res = response.Response(format_exception(exc), status=exc.status_code) - detail = format_exception(exc) - return response.Response(detail, status=exc.status_code, headers=headers) + if getattr(exc, "auth_header", None): + res["WWW-Authenticate"] = exc.auth_header + if getattr(exc, "wait", None): + res["X-Throttle-Wait-Seconds"] = "%d" % exc.wait + if getattr(exc, "project_data", None): + res["Taiga-Info-Project-Memberships"] = exc.project_data["total_memberships"] + res["Taiga-Info-Project-Is-Private"] = exc.project_data["is_private"] + + return res elif isinstance(exc, Http404): return response.NotFound({'_error_message': str(exc)}) diff --git a/taiga/base/utils/contenttypes.py b/taiga/base/utils/contenttypes.py index bfdd5ab3..0a6399a6 100644 --- a/taiga/base/utils/contenttypes.py +++ b/taiga/base/utils/contenttypes.py @@ -17,9 +17,9 @@ # along with this program. If not, see . from django.apps import apps -from django.contrib.contenttypes.management import update_contenttypes +from django.contrib.contenttypes.management import create_contenttypes def update_all_contenttypes(**kwargs): for app_config in apps.get_app_configs(): - update_contenttypes(app_config, **kwargs) + create_contenttypes(app_config, **kwargs) diff --git a/taiga/base/utils/db.py b/taiga/base/utils/db.py index 809c9d9c..24d386ed 100644 --- a/taiga/base/utils/db.py +++ b/taiga/base/utils/db.py @@ -155,7 +155,6 @@ def update_attr_in_bulk_for_ids(values, attr, model): try: cursor.execute(sql) except DatabaseError: - print("retries", 0) if retries < max_retries: _run_sql(retries + 1) diff --git a/taiga/external_apps/migrations/0003_auto_20170607_2320.py b/taiga/external_apps/migrations/0003_auto_20170607_2320.py new file mode 100644 index 00000000..75907982 --- /dev/null +++ b/taiga/external_apps/migrations/0003_auto_20170607_2320.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.2 on 2017-06-07 23:20 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('external_apps', '0002_remove_application_key'), + ] + + operations = [ + migrations.AlterModelOptions( + name='application', + options={'ordering': ['name', 'id'], 'verbose_name': 'application', 'verbose_name_plural': 'applications'}, + ), + migrations.AlterModelOptions( + name='applicationtoken', + options={'ordering': ['application', 'user'], 'verbose_name': 'application token', 'verbose_name_plural': 'application tolens'}, + ), + ] diff --git a/taiga/external_apps/models.py b/taiga/external_apps/models.py index c87159d5..c0a40466 100644 --- a/taiga/external_apps/models.py +++ b/taiga/external_apps/models.py @@ -43,7 +43,7 @@ class Application(models.Model): class Meta: verbose_name = "application" verbose_name_plural = "applications" - ordering = ["name"] + ordering = ["name", "id"] def __str__(self): return self.name @@ -64,6 +64,9 @@ class ApplicationToken(models.Model): state = models.CharField(max_length=255, null=True, blank=True, default="") class Meta: + verbose_name = "application token" + verbose_name_plural = "application tolens" + ordering = ["application", "user",] unique_together = ("application", "user",) def __str__(self): diff --git a/taiga/mdrender/service.py b/taiga/mdrender/service.py index 3a6a5908..0865bdd4 100644 --- a/taiga/mdrender/service.py +++ b/taiga/mdrender/service.py @@ -22,7 +22,7 @@ import bleach # BEGIN PATCH import html5lib -from html5lib.serializer.htmlserializer import HTMLSerializer +from html5lib.serializer import HTMLSerializer def _serialize(domtree): diff --git a/tests/integration/test_memberships.py b/tests/integration/test_memberships.py index ad2e70f3..93467422 100644 --- a/tests/integration/test_memberships.py +++ b/tests/integration/test_memberships.py @@ -227,7 +227,6 @@ def test_api_create_bulk_members_with_allowed_and_unallowed_domain(client, setti client.login(project.owner) response = client.json.post(url, json.dumps(data)) - print(response.data) assert response.status_code == 400 assert "username" in response.data["bulk_memberships"][0] assert "username" not in response.data["bulk_memberships"][1]