From 3ce40128b76c3ab14cb1c7d120738d255105c6e8 Mon Sep 17 00:00:00 2001 From: SpaceFox Date: Tue, 14 Apr 2015 23:15:00 +0200 Subject: [PATCH] =?UTF-8?q?Passage=20=C3=A0=20Django=201.8=20minimal=20(il?= =?UTF-8?q?=20reste=20plein=20de=20warnings=20mais=20=C3=A7a=20marche)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Impacts directs obligatoires : - Une relation en base change de nom pour être python-compatible (et donc sa migration en base) - On doit maintenant préciser le paramètre --fake-initial lors d'une migration de MAJ (cf https://docs.djangoproject.com/en/1.8/ref/django-admin/#django-admin-option---fake-initial) - Debug Toolbar en v1.3 - Fix pour que oauth fonctionne, cf https://github.com/evonove/django-oauth-toolkit/issues/204 --- CONTRIBUTING.md | 2 +- README.md | 2 +- .../back-end-code/arborescence-back.rst | 2 +- requirements-dev.txt | 4 +- requirements.txt | 4 +- scripts/deploy.sh | 2 +- templates/pages/about.html | 2 +- .../oauth2_provider/0001_initial.py | 75 +++++++++++++++++++ zds/migrations/oauth2_provider/__init__.py | 0 zds/settings.py | 13 +++- .../migrations/0002_auto_20150414_2256.py | 20 +++++ zds/utils/models.py | 2 +- 12 files changed, 115 insertions(+), 13 deletions(-) create mode 100644 zds/migrations/oauth2_provider/0001_initial.py create mode 100644 zds/migrations/oauth2_provider/__init__.py create mode 100644 zds/utils/migrations/0002_auto_20150414_2256.py diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cddb208324..b885d99618 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,7 +48,7 @@ Tous les détails sur le workflow se trouvent [sur la page dédiée](http://zds- | Nouvelle Fonctionnalité ? | [oui|non] | Tickets (_issues_) concernés | [Liste de tickets séparés par des virgules] ``` -* Ajoutez des notes de QA (Quality Assurance). Ces notes doivent permettent à un testeur de comprendre ce que vous avez modifié, ce qu'il faut tester en priorité et les pièges auxquels il doit s'attendre et donc sur lesquels porter une attention particulière. Précisez tout particulièrement s'il est nécessaire d'effectuer une action de gestion préalable, comme `python manage.py migrate`, `python manage.py loaddata fixture/*.yaml` ou `npm run gulp -- build`. +* Ajoutez des notes de QA (Quality Assurance). Ces notes doivent permettent à un testeur de comprendre ce que vous avez modifié, ce qu'il faut tester en priorité et les pièges auxquels il doit s'attendre et donc sur lesquels porter une attention particulière. Précisez tout particulièrement s'il est nécessaire d'effectuer une action de gestion préalable, comme `python manage.py migrate --fake-initial`, `python manage.py loaddata fixture/*.yaml` ou `npm run gulp -- build`. ## Les commits * Pour les commits, nous suivons le même ordre d'idée des standards Git, à savoir : diff --git a/README.md b/README.md index 175b29a193..a1ed9f53e3 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Après avoir mis à jour votre dépôt, vous devez exécuter les commandes suiva ```console pip install --upgrade -r requirements.txt -r requirements-dev.txt -python manage.py migrate +python manage.py migrate --fake-initial ``` diff --git a/doc/source/back-end-code/arborescence-back.rst b/doc/source/back-end-code/arborescence-back.rst index f06008d166..f5cbf95764 100644 --- a/doc/source/back-end-code/arborescence-back.rst +++ b/doc/source/back-end-code/arborescence-back.rst @@ -106,7 +106,7 @@ Cela permettra aux autres développeurs de répercuter les modifications en util .. sourcecode:: bash - python manage.py migrate + python manage.py migrate --fake-initial API diff --git a/requirements-dev.txt b/requirements-dev.txt index 8fa79e2bf7..e82c71d443 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,6 +2,6 @@ PyYAML==3.11 django-debug-toolbar==1.3.0 flake8==2.4.0 autopep8==1.1.1 -sphinx==1.3.1 -sphinx_rtd_theme==0.1.8 +sphinx==1.2.3 +sphinx_rtd_theme==0.1.6 fake-factory==0.5.0 diff --git a/requirements.txt b/requirements.txt index d25cac29f6..c262e73cb0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ pygments==2.0.2 python-social-auth==0.2.9 # Explicit dependencies (references in code) -django==1.7.10 +django==1.8.0 coverage==4.0.1 django-crispy-forms==1.4.0 django-haystack==2.3.1 @@ -31,5 +31,5 @@ drf-extensions==0.2.7 django-rest-swagger==0.2.9 django-cors-headers==1.0.0 -# Zep 12 dependency +# Zep 12 dependency django-uuslug==1.0.3 diff --git a/scripts/deploy.sh b/scripts/deploy.sh index a2b8388bb4..5ea42baa7b 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -31,7 +31,7 @@ cd /opt/zdsenv/ZesteDeSavoir/ # Maintenance mode sudo rm /etc/nginx/sites-enabled/zestedesavoir sudo ln -s /etc/nginx/sites-available/zds-maintenance /etc/nginx/sites-enabled/zds-maintenance -sudo systemctl reload nginx.service +sudo service nginx reload # Delete old branch if exists git checkout prod diff --git a/templates/pages/about.html b/templates/pages/about.html index b6c6f0d8d3..7c35b04749 100644 --- a/templates/pages/about.html +++ b/templates/pages/about.html @@ -66,7 +66,7 @@

{% trans "Système / Back-end" %}

{% trans "Site" %}

HTTP(S) + WSGI

diff --git a/zds/migrations/oauth2_provider/0001_initial.py b/zds/migrations/oauth2_provider/0001_initial.py new file mode 100644 index 0000000000..470c9ce0a1 --- /dev/null +++ b/zds/migrations/oauth2_provider/0001_initial.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import oauth2_provider.validators +import oauth2_provider.generators +from django.conf import settings + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='AccessToken', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('token', models.CharField(max_length=255, db_index=True)), + ('expires', models.DateTimeField()), + ('scope', models.TextField(blank=True)), + ], + ), + migrations.CreateModel( + name='Application', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('client_id', models.CharField(default=oauth2_provider.generators.generate_client_id, unique=True, max_length=100, db_index=True)), + ('redirect_uris', models.TextField(help_text='Allowed URIs list, space separated', blank=True, validators=[oauth2_provider.validators.validate_uris])), + ('client_type', models.CharField(max_length=32, choices=[('confidential', 'Confidential'), ('public', 'Public')])), + ('authorization_grant_type', models.CharField(max_length=32, choices=[('authorization-code', 'Authorization code'), ('implicit', 'Implicit'), ('password', 'Resource owner password-based'), ('client-credentials', 'Client credentials')])), + ('client_secret', models.CharField(default=oauth2_provider.generators.generate_client_secret, max_length=255, db_index=True, blank=True)), + ('name', models.CharField(max_length=255, blank=True)), + ('skip_authorization', models.BooleanField(default=False)), + ('user', models.ForeignKey(related_name='oauth2_provider_application', to=settings.AUTH_USER_MODEL)), + ], + options={ + 'abstract': False, + }, + ), + migrations.CreateModel( + name='Grant', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('code', models.CharField(max_length=255, db_index=True)), + ('expires', models.DateTimeField()), + ('redirect_uri', models.CharField(max_length=255)), + ('scope', models.TextField(blank=True)), + ('application', models.ForeignKey(to=settings.OAUTH2_PROVIDER_APPLICATION_MODEL)), + ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.CreateModel( + name='RefreshToken', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('token', models.CharField(max_length=255, db_index=True)), + ('access_token', models.OneToOneField(related_name='refresh_token', to='oauth2_provider.AccessToken')), + ('application', models.ForeignKey(to=settings.OAUTH2_PROVIDER_APPLICATION_MODEL)), + ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.AddField( + model_name='accesstoken', + name='application', + field=models.ForeignKey(to=settings.OAUTH2_PROVIDER_APPLICATION_MODEL), + ), + migrations.AddField( + model_name='accesstoken', + name='user', + field=models.ForeignKey(blank=True, to=settings.AUTH_USER_MODEL, null=True), + ), + ] diff --git a/zds/migrations/oauth2_provider/__init__.py b/zds/migrations/oauth2_provider/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/zds/settings.py b/zds/settings.py index 84ff7baebd..ad3d0a31f1 100644 --- a/zds/settings.py +++ b/zds/settings.py @@ -174,7 +174,6 @@ 'zds.gallery', 'zds.mp', 'zds.article', - 'zds.forum', 'zds.tutorial', 'zds.tutorialv2', @@ -360,6 +359,7 @@ # Fake mails (in console) EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' +from django.contrib.messages import constants as message_constants MESSAGE_TAGS = { message_constants.DEBUG: 'debug', message_constants.INFO: 'info', @@ -539,10 +539,17 @@ # See http://daniel.hepper.net/blog/2014/04/fixing-1_6-w001-when-upgrading-from-django-1-5-to-1-7/ TEST_RUNNER = 'django.test.runner.DiscoverRunner' +# makemigrations requires this for some reason or it errors +# Just set to the default value +OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application' + +# tell django where to put the oauth2 migrations +MIGRATION_MODULES = { + # key: app name, value: a fully qualified package name, not the usual `app_label.something_else` + 'oauth2_provider': 'zds.migrations.oauth2_provider', +} # Properly handle HTTPS vs HTTP SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') -# /!\ WARNING : It will probably open security holes in your site if the proxy behing isn't well configured -# Read the docs for further informations - https://docs.djangoproject.com/en/1.7/ref/settings/#secure-proxy-ssl-header # Load the production settings, overwrite the existing ones if needed try: diff --git a/zds/utils/migrations/0002_auto_20150414_2256.py b/zds/utils/migrations/0002_auto_20150414_2256.py new file mode 100644 index 0000000000..bdc09e6d48 --- /dev/null +++ b/zds/utils/migrations/0002_auto_20150414_2256.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +from django.conf import settings + + +class Migration(migrations.Migration): + + dependencies = [ + ('utils', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='comment', + name='editor', + field=models.ForeignKey(related_name='comments-editor+', verbose_name=b'Editeur', blank=True, to=settings.AUTH_USER_MODEL, null=True), + ), + ] diff --git a/zds/utils/models.py b/zds/utils/models.py index f586d9960b..2b7677d35f 100644 --- a/zds/utils/models.py +++ b/zds/utils/models.py @@ -176,7 +176,7 @@ class Meta: author = models.ForeignKey(User, verbose_name='Auteur', related_name='comments', db_index=True) editor = models.ForeignKey(User, verbose_name='Editeur', - related_name='comments-editor', + related_name='comments-editor+', null=True, blank=True) ip_address = models.CharField('Adresse IP de l\'auteur ', max_length=39)