Skip to content

Commit

Permalink
Passage à Django 1.8 minimal (il reste plein de warnings mais ça marche)
Browse files Browse the repository at this point in the history
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 jazzband/django-oauth-toolkit#204
  • Loading branch information
SpaceFox committed Apr 14, 2015
1 parent ccbc6b0 commit 5eac50b
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```


Expand Down
2 changes: 1 addition & 1 deletion doc/source/back-end-code/arborescence-back.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,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
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PyYAML==3.11
django-debug-toolbar==1.2.2
django-debug-toolbar==1.3
flake8==2.3.0
autopep8==1.1.1
sphinx==1.2.3
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pygments==2.0.2
python-social-auth==0.2.2

# Explicit dependencies (references in code)
django==1.7.7
django==1.8.0
coverage==3.7.1
django-crispy-forms==1.4.0
django-haystack==2.3.1
Expand All @@ -23,7 +23,7 @@ easy-thumbnails==2.2
djangorestframework==3.1.1
djangorestframework-xml==1.0.1
django-filter==0.9.2
django-oauth-toolkit==0.7.2
django-oauth-toolkit==0.8.0
drf-extensions==0.2.7
django-rest-swagger==0.2.9
django-cors-headers==1.0.0
2 changes: 1 addition & 1 deletion server/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ npm run build
# Update application data
source ../bin/activate
pip install --upgrade --use-mirrors -r requirements.txt
python manage.py migrate
python manage.py migrate --fake-initial
python manage.py compilemessages
# Collect all staticfiles from dist/ and python packages to static/
python manage.py collectstatic --noinput --clear
Expand Down
2 changes: 1 addition & 1 deletion templates/pages/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h3>{% trans "Système / Back-end" %}</h3>
<h4>{% trans "Site" %}</h4>
<ul>
<li><a href="http://www.python.org/">Python 2.7</a></li>
<li><a href="https://www.djangoproject.com/">Django 1.7</a></li>
<li><a href="https://www.djangoproject.com/">Django 1.8</a></li>
</ul>

<h4>HTTP(S) + WSGI</h4>
Expand Down
75 changes: 75 additions & 0 deletions zds/migrations/oauth2_provider/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
Empty file.
10 changes: 10 additions & 0 deletions zds/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,16 @@
# 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',
}

# Load the production settings, overwrite the existing ones if needed
try:
from settings_prod import *
Expand Down
20 changes: 20 additions & 0 deletions zds/utils/migrations/0002_auto_20150414_2256.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
2 changes: 1 addition & 1 deletion zds/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 5eac50b

Please sign in to comment.